Spaces:
Paused
Paused
File size: 4,957 Bytes
884c49d ba8c2bf 884c49d 8595531 884c49d ba8c2bf 884c49d 8595531 884c49d f0573ed 884c49d ba8c2bf 884c49d f0573ed 884c49d 2abf433 592750c 8595531 592750c 884c49d 8595531 884c49d |
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
import gradio as gr
from demo import automask_image_app, automask_video_app
def image_app():
with gr.Blocks():
with gr.Row():
with gr.Column():
seg_automask_image_file = gr.Image(type="filepath").style(height=260)
with gr.Row():
with gr.Column():
seg_automask_image_model_type = gr.Dropdown(
choices=[
"vit_h",
"vit_l",
"vit_b",
],
value="vit_l",
label="Model Type",
)
seg_automask_image_points_per_side = gr.Slider(
minimum=0,
maximum=32,
step=2,
value=16,
label="Points per Side",
)
seg_automask_image_points_per_batch = gr.Slider(
minimum=0,
maximum=64,
step=2,
value=64,
label="Points per Batch",
)
seg_automask_image_min_area = gr.Number(
value=0,
label="Min Area",
)
seg_automask_image_predict = gr.Button(value="Generator")
with gr.Column():
output_image = gr.Image()
seg_automask_image_predict.click(
fn=automask_image_app,
inputs=[
seg_automask_image_file,
seg_automask_image_model_type,
seg_automask_image_points_per_side,
seg_automask_image_points_per_batch,
seg_automask_image_min_area,
],
outputs=[output_image],
)
def video_app():
with gr.Blocks():
with gr.Row():
with gr.Column():
seg_automask_video_file = gr.Video().style(height=260)
with gr.Row():
with gr.Column():
seg_automask_video_model_type = gr.Dropdown(
choices=[
"vit_h",
"vit_l",
"vit_b",
],
value="vit_l",
label="Model Type",
)
seg_automask_video_points_per_side = gr.Slider(
minimum=0,
maximum=32,
step=2,
value=16,
label="Points per Side",
)
seg_automask_video_points_per_batch = gr.Slider(
minimum=0,
maximum=64,
step=2,
value=64,
label="Points per Batch",
)
with gr.Row():
with gr.Column():
seg_automask_video_min_area = gr.Number(
value=1000,
label="Min Area",
)
seg_automask_video_predict = gr.Button(value="Generator")
with gr.Column():
output_video = gr.Video()
seg_automask_video_predict.click(
fn=automask_video_app,
inputs=[
seg_automask_video_file,
seg_automask_video_model_type,
seg_automask_video_points_per_side,
seg_automask_video_points_per_batch,
seg_automask_video_min_area,
],
outputs=[output_video],
)
def metaseg_app():
app = gr.Blocks()
with app:
gr.Markdown("# **<h2 align='center'>Segment Anything + Video + Package</h2>**")
gr.Markdown(
"""
<h5 style='text-align: center'>
Follow me for more!
<a href='https://twitter.com/kadirnar_ai' target='_blank'>Twitter</a> | <a href='https://github.com/kadirnar' target='_blank'>Github</a> | <a href='https://www.linkedin.com/in/kadir-nar/' target='_blank'>Linkedin</a> |
</h5>
"""
)
with gr.Row():
with gr.Column():
with gr.Tab("Image"):
image_app()
with gr.Tab("Video"):
video_app()
app.queue(concurrency_count=1)
app.launch(debug=True, enable_queue=True)
if __name__ == "__main__":
metaseg_app()
|