0-ma commited on
Commit
4addd34
·
verified ·
1 Parent(s): dde0d91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -54,27 +54,19 @@ with gr.Blocks() as demo:
54
  gr.Markdown(f"# {title}")
55
  gr.Markdown(description)
56
 
57
- with gr.Row():
58
- model_dropdown = gr.Dropdown(choices=model_names, label="Select Model", value=model_names[0])
59
- image_input = gr.Image(type="pil")
60
 
61
- # Move the Examples section here, before the output
 
 
62
  gr.Examples(
63
  examples=example_images,
64
  inputs=image_input,
65
  label="Click on an example image to test",
66
  )
67
 
68
- # Output section
69
  output = gr.Label(label="Classification Result")
70
-
71
- # Event handlers
72
- def classify(img, model):
73
- if img is not None:
74
- return predict(img, model)
75
- return None
76
-
77
- image_input.change(fn=classify, inputs=[image_input, model_dropdown], outputs=output)
78
- model_dropdown.change(fn=classify, inputs=[image_input, model_dropdown], outputs=output)
79
 
80
  demo.launch()
 
54
  gr.Markdown(f"# {title}")
55
  gr.Markdown(description)
56
 
 
 
 
57
 
58
+ model_dropdown = gr.Dropdown(choices=model_names, label="Select Model", value=model_names[0])
59
+ image_input = gr.Image(type="pil")
60
+
61
  gr.Examples(
62
  examples=example_images,
63
  inputs=image_input,
64
  label="Click on an example image to test",
65
  )
66
 
 
67
  output = gr.Label(label="Classification Result")
68
+
69
+ image_input.change(fn=predict, inputs=[image_input, model_dropdown], outputs=output)
70
+ model_dropdown.change(fn=predict, inputs=[image_input, model_dropdown], outputs=output)
 
 
 
 
 
 
71
 
72
  demo.launch()