KhadijaAsehnoune12
commited on
Commit
•
05936bf
1
Parent(s):
d460ae2
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,32 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
def predict(image):
|
4 |
try:
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
13 |
except Exception as e:
|
14 |
return {"error": str(e)}
|
15 |
|
16 |
interface = gr.Interface(
|
17 |
fn=predict,
|
18 |
-
inputs=gr.Image(type="
|
19 |
outputs=gr.Label(num_top_classes=3),
|
20 |
-
examples=[
|
21 |
title="Orange Disease Detector",
|
22 |
-
description="Detect diseases in orange leaves."
|
23 |
)
|
24 |
|
25 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
|
5 |
def predict(image):
|
6 |
try:
|
7 |
+
# Ensure the input is a PIL Image
|
8 |
+
if isinstance(image, np.ndarray):
|
9 |
+
# Convert numpy array to PIL Image
|
10 |
+
image = Image.fromarray(image)
|
11 |
+
|
12 |
+
if not isinstance(image, Image.Image):
|
13 |
+
return {"error": "Input is not a valid image"}
|
14 |
+
|
15 |
+
# Perform your prediction here
|
16 |
+
# Placeholder for actual prediction logic
|
17 |
+
result = {"Disease": "Predicted Disease", "Confidence": 0.95}
|
18 |
+
return result
|
19 |
+
|
20 |
except Exception as e:
|
21 |
return {"error": str(e)}
|
22 |
|
23 |
interface = gr.Interface(
|
24 |
fn=predict,
|
25 |
+
inputs=gr.Image(type="numpy"), # Use 'numpy' type for better compatibility
|
26 |
outputs=gr.Label(num_top_classes=3),
|
27 |
+
examples=["MoucheB.jpg", "verdissement.jpg"],
|
28 |
title="Orange Disease Detector",
|
29 |
+
description="Detect diseases in orange leaves and fruits."
|
30 |
)
|
31 |
|
32 |
if __name__ == "__main__":
|