Enhance Gradio interface with settings accordion and user guidance
Browse files- Move confidence threshold slider into a collapsible settings accordion
- Update project description with a user-friendly hint for interaction
- Fix image resizing for ViT models by using the correct input image
app.py
CHANGED
@@ -90,7 +90,7 @@ def predict_image(img, confidence_threshold):
|
|
90 |
# Resize the image
|
91 |
img_pil = transforms.Resize((256, 256))(img_pil)
|
92 |
# Size 224 for vits models
|
93 |
-
img_pilvits = transforms.Resize((224, 224))(
|
94 |
|
95 |
# Predict using the first model
|
96 |
try:
|
@@ -508,11 +508,12 @@ with gr.Blocks() as iface:
|
|
508 |
with gr.Row():
|
509 |
with gr.Column(scale=1):
|
510 |
image_input = gr.Image(label="Upload Image to Analyze", sources=['upload'], type='pil')
|
511 |
-
|
|
|
512 |
inputs = [image_input, confidence_slider]
|
513 |
with gr.Column(scale=2):
|
514 |
with gr.Accordion("Project OpenSight - Model Evaluations & Playground", open=True):
|
515 |
-
gr.Markdown("## OpenSight is a SOTA gen. image detection model, in pre-release prep.\n\nThis HF Space is a temporary home for us and the public to evaluate the shortcomings of current open source models.")
|
516 |
image_output = gr.Image(label="Processed Image", visible=False)
|
517 |
# Custom HTML component to display results in 5 columns
|
518 |
results_html = gr.HTML(label="Model Predictions")
|
|
|
90 |
# Resize the image
|
91 |
img_pil = transforms.Resize((256, 256))(img_pil)
|
92 |
# Size 224 for vits models
|
93 |
+
img_pilvits = transforms.Resize((224, 224))(img_pil)
|
94 |
|
95 |
# Predict using the first model
|
96 |
try:
|
|
|
508 |
with gr.Row():
|
509 |
with gr.Column(scale=1):
|
510 |
image_input = gr.Image(label="Upload Image to Analyze", sources=['upload'], type='pil')
|
511 |
+
with gr.Accordion("Settings", open=False):
|
512 |
+
confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
|
513 |
inputs = [image_input, confidence_slider]
|
514 |
with gr.Column(scale=2):
|
515 |
with gr.Accordion("Project OpenSight - Model Evaluations & Playground", open=True):
|
516 |
+
gr.Markdown("## OpenSight is a SOTA gen. image detection model, in pre-release prep.\n\nThis HF Space is a temporary home for us and the public to evaluate the shortcomings of current open source models.\n\n<-- Feel free to play around by starting with an image as we prepare our formal announcement.")
|
517 |
image_output = gr.Image(label="Processed Image", visible=False)
|
518 |
# Custom HTML component to display results in 5 columns
|
519 |
results_html = gr.HTML(label="Model Predictions")
|