Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,14 +41,20 @@ transform = transforms.Compose([
|
|
41 |
class_names = ['BacterialBlights', 'Healthy', 'Mosaic', 'RedRot', 'Rust', 'Yellow']
|
42 |
|
43 |
#Gemini Response
|
44 |
-
def get_response_llm(predicted_label,knowledge_base):
|
45 |
-
prompt =
|
|
|
|
|
|
|
|
|
|
|
46 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
47 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
48 |
response = model.generate_content([prompt])
|
49 |
return response.text
|
50 |
|
51 |
|
|
|
52 |
# Comprehensive knowledge base for sugarcane diseases and practices
|
53 |
knowledge_base = """
|
54 |
'BacterialBlights': Bacterial blights are caused by *Xanthomonas albilineans*.
|
@@ -164,7 +170,7 @@ def predict_disease(image):
|
|
164 |
Detected Disease: <span style='color: #FF5722;'>{predicted_label}</span>
|
165 |
</div>
|
166 |
<div style='font-size: 16px; color: #757575; line-height: 1.6;'>
|
167 |
-
{detailed_response.replace("
|
168 |
</div>
|
169 |
"""
|
170 |
|
|
|
41 |
class_names = ['BacterialBlights', 'Healthy', 'Mosaic', 'RedRot', 'Rust', 'Yellow']
|
42 |
|
43 |
#Gemini Response
|
44 |
+
def get_response_llm(predicted_label, knowledge_base):
|
45 |
+
prompt = (
|
46 |
+
f"You're a helpful assistant who helps farmers understand sugarcane leaf diseases, "
|
47 |
+
f"providing precautions, advice, and more. The predicted disease label is '{predicted_label}', "
|
48 |
+
f"and additional information is provided from the knowledge base: {knowledge_base}. "
|
49 |
+
f"Please provide a concise and beautiful response, using bold or bullet points where appropriate."
|
50 |
+
)
|
51 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
52 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
53 |
response = model.generate_content([prompt])
|
54 |
return response.text
|
55 |
|
56 |
|
57 |
+
|
58 |
# Comprehensive knowledge base for sugarcane diseases and practices
|
59 |
knowledge_base = """
|
60 |
'BacterialBlights': Bacterial blights are caused by *Xanthomonas albilineans*.
|
|
|
170 |
Detected Disease: <span style='color: #FF5722;'>{predicted_label}</span>
|
171 |
</div>
|
172 |
<div style='font-size: 16px; color: #757575; line-height: 1.6;'>
|
173 |
+
{detailed_response.replace("\n", "<br>").replace("-", "•")}
|
174 |
</div>
|
175 |
"""
|
176 |
|