Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -56,9 +56,13 @@ def predict_disease(image):
|
|
56 |
predicted_label = class_names[predicted_class.item()]
|
57 |
|
58 |
# Generate AI response based on the detected disease
|
59 |
-
prompt = f"
|
60 |
ai_response = ai_pipeline(prompt, max_length=50, num_return_sequences=1)[0]['generated_text']
|
61 |
-
|
|
|
|
|
|
|
|
|
62 |
# Create a styled HTML output
|
63 |
output_message = f"""
|
64 |
<div style='font-size: 18px; color: #4CAF50; font-weight: bold;'>
|
|
|
56 |
predicted_label = class_names[predicted_class.item()]
|
57 |
|
58 |
# Generate AI response based on the detected disease
|
59 |
+
prompt = f"The detected sugarcane disease is '{predicted_label}'. Provide detailed advice for managing this condition."
|
60 |
ai_response = ai_pipeline(prompt, max_length=50, num_return_sequences=1)[0]['generated_text']
|
61 |
+
|
62 |
+
# Remove the prompt text if it appears in the AI response
|
63 |
+
if ai_response.startswith(prompt):
|
64 |
+
ai_response = ai_response[len(prompt):].strip()
|
65 |
+
|
66 |
# Create a styled HTML output
|
67 |
output_message = f"""
|
68 |
<div style='font-size: 18px; color: #4CAF50; font-weight: bold;'>
|