saritha commited on
Commit
b8c2514
·
verified ·
1 Parent(s): 7794a17

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
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"You are an expert in sugarcane farming. The detected disease is '{predicted_label}'. Provide advice for the farmer."
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;'>