File size: 1,341 Bytes
afd2199
577bb6b
afd2199
577bb6b
31fdeeb
afd2199
 
cd41c0c
afd2199
fa05982
c76c2fc
 
afd2199
c76c2fc
fa05982
 
afd2199
 
c76c2fc
 
577bb6b
cd41c0c
 
afd2199
 
 
 
 
 
 
 
 
 
 
31fdeeb
c76c2fc
fa05982
31fdeeb
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
import mmpose
import os
from mmpose.apis import MMPoseInferencer

print("[INFO]: Imported modules!")

import gradio as gr
import numpy as np

def poses(photo):
    inferencer = MMPoseInferencer('human')

    print("[INFO]: Downloaded models!")
    print(photo)
    result_generator = inferencer(photo, 
                                  out_dir =".")

    print("[INFO]: Visualizing results!")
    # The MMPoseInferencer API employs a lazy inference approach,
    # creating a prediction generator when given input
    result = next(result_generator)
    output = np.array(result["visualization"])
    return output

# # specify detection model by alias
# # the available aliases include 'human', 'hand', 'face', 'animal',
# # as well as any additional aliases defined in mmdet
# inferencer = MMPoseInferencer(
#     # suppose the pose estimator is trained on custom dataset
#     pose2d='custom_human_pose_estimator.py',
#     pose2d_weights='custom_human_pose_estimator.pth',
#     det_model='human'
# )
    
def run():
    #https://github.com/open-mmlab/mmpose/blob/main/docs/en/user_guides/inference.md
    demo = gr.Interface(fn=poses, 
                        inputs=gr.Image(source="webcam"),
                        outputs=gr.Image())


    demo.launch(server_name="0.0.0.0", server_port=7860)


if __name__ == "__main__":
    run()