Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,8 @@ def infer(image, candidate_labels):
|
|
17 |
clip_out = clip_detector(image, candidate_labels=candidate_labels)
|
18 |
return postprocess(clip_out)
|
19 |
|
|
|
|
|
20 |
|
21 |
with gr.Blocks() as demo:
|
22 |
gr.Markdown("# Compare CLIP and SigLIP")
|
@@ -25,6 +27,7 @@ with gr.Blocks() as demo:
|
|
25 |
with gr.Column():
|
26 |
image_input = gr.Image(type="pil")
|
27 |
text_input = gr.Textbox(label="Input a list of labels")
|
|
|
28 |
run_button = gr.Button("Run", visible=True)
|
29 |
|
30 |
with gr.Column():
|
@@ -39,6 +42,12 @@ with gr.Blocks() as demo:
|
|
39 |
fn=infer,
|
40 |
cache_examples=True
|
41 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
run_button.click(fn=infer,
|
43 |
inputs=[image_input, text_input],
|
44 |
outputs=[clip_output,
|
|
|
17 |
clip_out = clip_detector(image, candidate_labels=candidate_labels)
|
18 |
return postprocess(clip_out)
|
19 |
|
20 |
+
def update_top_classes(num_classes):
|
21 |
+
return
|
22 |
|
23 |
with gr.Blocks() as demo:
|
24 |
gr.Markdown("# Compare CLIP and SigLIP")
|
|
|
27 |
with gr.Column():
|
28 |
image_input = gr.Image(type="pil")
|
29 |
text_input = gr.Textbox(label="Input a list of labels")
|
30 |
+
slider = gr.Slider(minimum=3, maximum=20, step=1, value=3, label="Number of Top Classes")
|
31 |
run_button = gr.Button("Run", visible=True)
|
32 |
|
33 |
with gr.Column():
|
|
|
42 |
fn=infer,
|
43 |
cache_examples=True
|
44 |
)
|
45 |
+
slider.change(
|
46 |
+
fn=update_top_classes,
|
47 |
+
inputs=slider,
|
48 |
+
outputs=clip_output,
|
49 |
+
_js="(i) => ({ 'num_top_classes': i })"
|
50 |
+
)
|
51 |
run_button.click(fn=infer,
|
52 |
inputs=[image_input, text_input],
|
53 |
outputs=[clip_output,
|