LPX55 commited on
Commit
4439436
·
verified ·
1 Parent(s): ca9dc4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -184,18 +184,23 @@ def predict_image(img, confidence_threshold):
184
  "GOAT": label_5
185
  }
186
 
187
- return combined_results
188
 
189
  # Define the Gradio interface
190
- image = gr.Image(label="Image to Analyze", sources=['upload'], type='pil') # Ensure the image type is PIL
191
- confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
192
- label = gr.JSON(label="Model Predictions")
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  # Launch the interface
195
- iface = gr.Interface(
196
- fn=predict_image,
197
- inputs=[image, confidence_slider],
198
- outputs=label,
199
- title="AI Generated Classification"
200
- )
201
- iface.launch()
 
184
  "GOAT": label_5
185
  }
186
 
187
+ return img_pil, combined_results
188
 
189
  # Define the Gradio interface
190
+ with gr.Blocks() as iface:
191
+ gr.Markdown("# AI Generated Image Classification")
192
+
193
+ with gr.Row():
194
+ with gr.Column():
195
+ image_input = gr.Image(label="Upload Image to Analyze", sources=['upload'], type='pil')
196
+ confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
197
+ inputs = [image_input, confidence_slider]
198
+ with gr.Column():
199
+ image_output = gr.Image(label="Processed Image")
200
+ label_output = gr.JSON(label="Model Predictions")
201
+ outputs = [image_output, label_output]
202
+
203
+ gr.Button("Predict").click(fn=predict_image, inputs=inputs, outputs=outputs)
204
 
205
  # Launch the interface
206
+ iface.launch()