import mmpose | |
import os | |
from mmpose.apis import MMPoseInferencer | |
print("[INFO]: Imported modules!") | |
import gradio as gr | |
import numpy as np | |
inferencer = MMPoseInferencer('human') | |
print("[INFO]: Downloaded models!") | |
def poses(photo): | |
result_generator = inferencer(photo, | |
vis_out_dir =".", | |
return_vis=True, | |
thickness=2) | |
print("[INFO]: Visualizing results!") | |
print(os.listdir()) | |
print(result_generator[0]) | |
#print("[INFO]: Type of vis is ", type(result_generator['visualization'])) | |
#print("[INFO]: Vis is ", type(result_generator['visualization'])) | |
# The MMPoseInferencer API employs a lazy inference approach, | |
# creating a prediction generator when given input | |
#result = next(result_generator) | |
return "000000.mp4" | |
# # 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.Video(source="webcam"), | |
outputs=gr.Video()) | |
demo.launch(server_name="0.0.0.0", server_port=7860) | |
if __name__ == "__main__": | |
run() |