File size: 3,218 Bytes
7206ed3 d62a8dc 7206ed3 d62a8dc 7206ed3 d62a8dc 7206ed3 d62a8dc 7206ed3 d62a8dc 7206ed3 6630510 d62a8dc 7206ed3 d62a8dc 7206ed3 d62a8dc | 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | import gradio as gr
def gradio_inputs_for_MD_DLC(md_models_list, dlc_models_list):
# Input image
gr_image_input = gr.Image(type="pil", label="Input Image")
# Models
gr_mega_model_input = gr.Dropdown(
choices=md_models_list,
value="md_v5a",
type="value",
label="Select Detector model",
)
gr_dlc_model_input = gr.Dropdown(
choices=dlc_models_list,
value="superanimal_quadruped_dlcrnet",
type="value",
label="Select DeepLabCut model",
)
# Other inputs
gr_dlc_only_checkbox = gr.Checkbox(
value=False,
label="Run DLClive only, directly on input image?",
)
gr_str_labels_checkbox = gr.Checkbox(
value=True,
label="Show bodypart labels?",
)
# Gradio Slider signature is (minimum, maximum, value, step, ...)
gr_slider_conf_bboxes = gr.Slider(
minimum=0,
maximum=1,
value=0.2,
step=0.05,
label="Set confidence threshold for animal detections",
)
gr_slider_conf_keypoints = gr.Slider(
minimum=0,
maximum=1,
value=0.4,
step=0.05,
label="Set confidence threshold for keypoints",
)
# Data viz
gr_keypt_color = gr.ColorPicker(
value="#862db7",
label="Choose color for keypoint label",
)
gr_labels_font_style = gr.Dropdown(
choices=["amiko", "animals", "nature", "painter", "zen"],
value="amiko",
type="value",
label="Select keypoint label font",
)
gr_slider_font_size = gr.Slider(
minimum=5,
maximum=30,
value=8,
step=1,
label="Set font size",
)
gr_slider_marker_size = gr.Slider(
minimum=1,
maximum=20,
value=9,
step=1,
label="Set marker size",
)
return [
gr_image_input,
gr_mega_model_input,
gr_dlc_model_input,
gr_dlc_only_checkbox,
gr_str_labels_checkbox,
gr_slider_conf_bboxes,
gr_slider_conf_keypoints,
gr_labels_font_style,
gr_slider_font_size,
gr_keypt_color,
gr_slider_marker_size,
]
def gradio_outputs_for_MD_DLC():
gr_image_output = gr.Image(type="pil", label="Output Image")
gr_file_download = gr.File(label="Download JSON file")
return [gr_image_output, gr_file_download]
def gradio_description_and_examples():
title = "DeepLabCut Model Zoo SuperAnimals"
description = (
"Test the SuperAnimal models from the "
"<a href='http://www.mackenziemathislab.org/dlc-modelzoo'>"
"DeepLabCut ModelZoo Project</a>, and read more on arXiv: "
"https://arxiv.org/abs/2203.07436! Simply upload an image and see how it does. "
"Want to run on videos on the cloud or locally? See the "
"<a href='http://www.mackenziemathislab.org/dlc-modelzoo'>DeepLabCut ModelZoo</a>."
)
examples = [[
"examples/dog.jpeg",
"md_v5a",
"superanimal_quadruped_dlcrnet",
False,
True,
0.5,
0.0,
"amiko",
9,
"#ff0000",
3,
]]
return [title, description, examples] |