MMpose / main.py
xmrt's picture
visualization
cd41c0c
raw
history blame
No virus
1.34 kB
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()