vishwak1 commited on
Commit
d16269d
·
verified ·
1 Parent(s): acbfe74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -9,9 +9,8 @@ from google import genai
9
  model = load_model("model.h5")
10
 
11
  # Configure Gemini
12
- genai.configure(api_key=" AIzaSyAL_Q5yEJXnVDA8EOxNCi6WdG5VtZSzMHg")
13
- client = genai.GenerativeModel("gemini-2.0-flash")
14
 
 
15
  # Class index to label map
16
  label_map = {
17
  0: "Healthy",
@@ -31,8 +30,11 @@ def predict_and_explain(image):
31
  predicted_label = label_map.get(predicted_index, "Unknown")
32
 
33
  # Generate explanation using Gemini
34
- prompt = f"Explain about the plant disease '{predicted_label}' and how to treat it in one paragraph."
35
- response = client.generate_content(prompt)
 
 
 
36
 
37
  return predicted_label, response.text
38
  except Exception as e:
 
9
  model = load_model("model.h5")
10
 
11
  # Configure Gemini
 
 
12
 
13
+ client = genai.Client(api_key="AIzaSyCzWEZR6C6k13PSGHheeBXPAy0h0koxFCM")
14
  # Class index to label map
15
  label_map = {
16
  0: "Healthy",
 
30
  predicted_label = label_map.get(predicted_index, "Unknown")
31
 
32
  # Generate explanation using Gemini
33
+ prompt = f"Explain about the plant disease '{predicted_label}' explain in two main headings 1. describe symptoms with minimal points,2. suggest treatment with minimal points."
34
+ response = client.models.generate_content(
35
+ model="gemini-2.0-flash", # Adjust model name if necessary
36
+ contents=prompt
37
+ )
38
 
39
  return predicted_label, response.text
40
  except Exception as e: