Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -87,26 +87,16 @@ def predict_from_url(url):
|
|
87 |
return json.dumps({"error": f"Error fetching image from URL: {e}"})
|
88 |
|
89 |
|
90 |
-
# Create the Gradio interface
|
91 |
iface = gr.Interface(
|
92 |
fn=predict_from_image,
|
93 |
-
inputs=gr.Image(type="pil", label="Upload an image or provide a local path"),
|
|
|
94 |
outputs=gr.Textbox(label="Prediction Result"),
|
95 |
live=True,
|
96 |
title="Maize Anomaly Detection",
|
97 |
description="Upload an image of maize to detect anomalies like disease or pest infestation. You can provide local paths, URLs, or base64-encoded images."
|
98 |
)
|
99 |
|
100 |
-
# Add another function for URL input
|
101 |
-
url_iface = gr.Interface(
|
102 |
-
fn=predict_from_url,
|
103 |
-
inputs=gr.Textbox(label="Enter image URL"),
|
104 |
-
outputs=gr.Textbox(label="Prediction Result from URL"),
|
105 |
-
live=True,
|
106 |
-
title="Maize Anomaly Detection from URL",
|
107 |
-
description="Provide an image URL to detect anomalies like disease or pest infestation."
|
108 |
-
)
|
109 |
-
|
110 |
# Launch the Gradio interface
|
111 |
iface.launch(share=True, show_error=True)
|
112 |
-
url_iface.launch(share=True, show_error=True)
|
|
|
87 |
return json.dumps({"error": f"Error fetching image from URL: {e}"})
|
88 |
|
89 |
|
90 |
+
# Create the Gradio interface with both local file upload and URL input
|
91 |
iface = gr.Interface(
|
92 |
fn=predict_from_image,
|
93 |
+
inputs=[gr.Image(type="pil", label="Upload an image or provide a local path"),
|
94 |
+
gr.Textbox(label="Or enter image URL (if available)", placeholder="Enter a URL for the image")],
|
95 |
outputs=gr.Textbox(label="Prediction Result"),
|
96 |
live=True,
|
97 |
title="Maize Anomaly Detection",
|
98 |
description="Upload an image of maize to detect anomalies like disease or pest infestation. You can provide local paths, URLs, or base64-encoded images."
|
99 |
)
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
# Launch the Gradio interface
|
102 |
iface.launch(share=True, show_error=True)
|
|