diff --git a/projects/rtmpose/app.py b/projects/rtmpose/app.py index 416e169e4f..6b5be8f9bb 100644 --- a/projects/rtmpose/app.py +++ b/projects/rtmpose/app.py @@ -3,19 +3,31 @@ import os from functools import partial -import gradio as gr - # prepare environment project_path = os.path.join(os.path.dirname(os.path.abspath(__file__))) mmpose_path = project_path.split('/projects', 1)[0] os.system('python -m pip install Openmim') +os.system('python -m pip install openxlab') +os.system('python -m pip install gradio==3.38.0') + os.system('python -m mim install "mmcv>=2.0.0"') os.system('python -m mim install "mmengine>=0.9.0"') os.system('python -m mim install "mmdet>=3.0.0"') os.system(f'python -m mim install -e {mmpose_path}') + +import gradio as gr # noqa +from openxlab.model import download # noqa + from mmpose.apis import MMPoseInferencer # noqa +# download checkpoints +download(model_repo='mmpose/RTMPose', model_name='dwpose-l') +download(model_repo='mmpose/RTMPose', model_name='RTMW-x') +download(model_repo='mmpose/RTMPose', model_name='RTMO-l') +download(model_repo='mmpose/RTMPose', model_name='RTMPose-l-body8') +download(model_repo='mmpose/RTMPose', model_name='RTMPose-m-face6') + models = [ 'rtmpose | body', 'rtmo | body', 'rtmpose | face', 'dwpose | wholebody', 'rtmw | wholebody' @@ -115,12 +127,7 @@ def predict(input, input_img = gr.Image(type='numpy') button = gr.Button('Inference', variant='primary') hm = gr.Checkbox(label='draw-heatmap', info='Whether to draw heatmap') - model_type = gr.Dropdown([ - 'rtmpose | body', 'rtmo | body', 'rtmpose | face', - 'dwpose | wholebody', 'rtmw | wholebody' - ], - label='Model | Keypoint Type', - info='Body / Face / Wholebody') + model_type = gr.Dropdown(models, label='Model | Keypoint Type') gr.Markdown('## News') for news in news_list[::-1]: @@ -138,12 +145,7 @@ def predict(input, input_img = gr.Image(source='webcam', type='numpy') button = gr.Button('Inference', variant='primary') hm = gr.Checkbox(label='draw-heatmap', info='Whether to draw heatmap') - model_type = gr.Dropdown([ - 'rtmpose | body', 'rtmo | body', 'rtmpose | face', - 'dwpose | wholebody', 'rtmw | wholebody' - ], - label='Model | Keypoint Type', - info='Body / Face / Wholebody') + model_type = gr.Dropdown(models, label='Model | Keypoint Type') gr.Markdown('## News') for news in news_list[::-1]: @@ -161,12 +163,7 @@ def predict(input, input_video = gr.Video(type='mp4') button = gr.Button('Inference', variant='primary') hm = gr.Checkbox(label='draw-heatmap', info='Whether to draw heatmap') - model_type = gr.Dropdown([ - 'rtmpose | body', 'rtmo | body', 'rtmpose | face', - 'dwpose | wholebody', 'rtmw | wholebody' - ], - label='Model | Keypoint type', - info='Body / Face / Wholebody') + model_type = gr.Dropdown(models, label='Model | Keypoint type') gr.Markdown('## News') for news in news_list[::-1]: @@ -184,12 +181,7 @@ def predict(input, input_video = gr.Video(source='webcam', format='mp4') button = gr.Button('Inference', variant='primary') hm = gr.Checkbox(label='draw-heatmap', info='Whether to draw heatmap') - model_type = gr.Dropdown([ - 'rtmpose | body', 'rtmo | body', 'rtmpose | face', - 'dwpose | wholebody', 'rtmw | wholebody' - ], - label='Model | Keypoint Type', - info='Body / Face / Wholebody') + model_type = gr.Dropdown(models, label='Model | Keypoint Type') gr.Markdown('## News') for news in news_list[::-1]: