File size: 1,716 Bytes
b9cc655
 
 
0e66889
 
 
 
 
 
 
 
 
 
b9cc655
 
 
 
775d1c1
b9cc655
 
775d1c1
b9cc655
775d1c1
b9cc655
0e66889
b9cc655
 
 
 
 
 
0e66889
4049301
b9cc655
0e66889
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from keypoints_extraction import predict_pose
from calculate_measures import calculate_all_measures
from calculate_masks import calculate_seg_mask

import os
os.system("pip install xtcocotools>=1.12")
os.system("pip install 'mmengine>=0.6.0'")
os.system("pip install 'mmcv>=2.0.0rc4,<2.1.0'")
os.system("pip install 'mmdet>=3.0.0,<4.0.0'")
os.system("pip install 'mmpose'")

import gradio as gr

def generate_output(front_img, side_img):
    # TODO: These file names will need to be unique in case of multiple requests at once, and they will need to be deleted after the function is done.
    front_keypoint_result = predict_pose(front_img, "front.jpg")
    side_keypoint_result = predict_pose(side_img, "side.jpg")

    front_seg_mask = calculate_seg_mask(front_img)
    side_rcnn_mask = calculate_seg_mask(side_img)

    measures = calculate_all_measures(front_keypoint_result, side_keypoint_result, front_seg_mask, side_rcnn_mask)

    return (front_keypoint_result[0], front_keypoint_result[1], side_keypoint_result[0], side_keypoint_result[1])

input_image_front = gr.inputs.Image(type='pil', label="Front Image")
input_image_side = gr.inputs.Image(type='pil', label="Side Image")
output_image_front = gr.outputs.Image(type="pil", label="Front Output Image")
output_text_front = gr.outputs.Textbox(label="Front Output Text")
output_image_side = gr.outputs.Image(type="pil", label="Front Output Image")
output_text_side = gr.outputs.Textbox(label="Side Output Text")

title = "MMPose detection for ShopByShape"
iface = gr.Interface(fn=generate_output, inputs=[input_image_front, input_image_side], outputs=[output_image_front, output_text_front, output_image_side, output_text_side], title=title)
iface.launch()