Spaces:
Runtime error
Runtime error
File size: 1,722 Bytes
8478e62 828ef5a 8478e62 |
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import gradio as gr
from facemesh import mp_face_mesh_fn
from facedetect import mp_face_detect_fn
from handposedetect import mp_hand_pose_detect_fn
from posestimate import mp_pose_estimation_fn
from holistic import mp_holistic_fn
def run_mediapipe(image, soln_type):
if soln_type == 'facemesh':
annotated_image = mp_face_mesh_fn(image)
elif soln_type == 'facedetect':
annotated_image = mp_face_detect_fn(image)
elif soln_type == 'handpose':
annotated_image = mp_hand_pose_detect_fn(image)
elif soln_type == 'pose estimate':
annotated_image = mp_pose_estimation_fn(image)
elif soln_type == 'holistic':
annotated_image = mp_holistic_fn(image)
return annotated_image
def main():
solutions = [
'facedetect',
'facemesh',
'handpose',
'pose estimate',
'holistic'
]
sample_images = [
["examples/0.jpg", solutions[0]],
["examples/1.jpg", solutions[1]],
["examples/2.png", solutions[2]],
["examples/3.jpg", solutions[3]],
["examples/4.jpg", solutions[4]],
]
iface = gr.Interface(
fn=run_mediapipe,
inputs=[
gr.inputs.Image(label="Input Image"),
gr.inputs.Radio(
solutions,
type='value',
default=solutions[0],
label='Solutions'
),
],
outputs=gr.outputs.Image(label="MediaPipe"),
title="Google MediaPipe Demo",
description="Few solutions of <a href='https://mediapipe.dev/'>Google MediaPipe</a> are presented here.",
examples=sample_images
)
iface.launch()
if __name__ == '__main__':
main()
|