Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,13 +52,33 @@ def predict_disease(image):
|
|
52 |
# Get the predicted label
|
53 |
predicted_label = class_names[predicted_class.item()]
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
# Create Gradio interface
|
58 |
inputs = gr.Image(type="pil")
|
59 |
-
outputs = gr.
|
60 |
|
61 |
-
EXAMPLES = ["img1.jpeg","redrot2.jpg","rust1.jpg","healthy2.jpeg"]
|
62 |
|
63 |
demo_app = gr.Interface(
|
64 |
fn=predict_disease,
|
@@ -70,7 +90,4 @@ demo_app = gr.Interface(
|
|
70 |
theme="huggingface"
|
71 |
)
|
72 |
|
73 |
-
demo_app.launch(debug=True)
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
52 |
# Get the predicted label
|
53 |
predicted_label = class_names[predicted_class.item()]
|
54 |
|
55 |
+
# Create a styled HTML output
|
56 |
+
output_message = f"""
|
57 |
+
<div style='font-size: 18px; color: #4CAF50; font-weight: bold;'>
|
58 |
+
Detected Disease: <span style='color: #FF5722;'>{predicted_label}</span>
|
59 |
+
</div>
|
60 |
+
"""
|
61 |
+
|
62 |
+
if predicted_label != "Healthy":
|
63 |
+
output_message += f"""
|
64 |
+
<p style='font-size: 16px; color: #757575;'>
|
65 |
+
This indicates the presence of <strong>{predicted_label}</strong>. Please take immediate action to prevent further spread.
|
66 |
+
</p>
|
67 |
+
"""
|
68 |
+
else:
|
69 |
+
output_message += f"""
|
70 |
+
<p style='font-size: 16px; color: #757575;'>
|
71 |
+
The sugarcane crop is <strong>healthy</strong>. Keep monitoring for potential risks.
|
72 |
+
</p>
|
73 |
+
"""
|
74 |
+
|
75 |
+
return output_message
|
76 |
|
77 |
# Create Gradio interface
|
78 |
inputs = gr.Image(type="pil")
|
79 |
+
outputs = gr.HTML() # Use HTML output for styled text
|
80 |
|
81 |
+
EXAMPLES = ["img1.jpeg", "redrot2.jpg", "rust1.jpg", "healthy2.jpeg"]
|
82 |
|
83 |
demo_app = gr.Interface(
|
84 |
fn=predict_disease,
|
|
|
90 |
theme="huggingface"
|
91 |
)
|
92 |
|
93 |
+
demo_app.launch(debug=True)
|
|
|
|
|
|