isunnyrock commited on
Commit
6bb9cf8
1 Parent(s): 2d0227c

Minor Updates to app file

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -120,7 +120,7 @@ def identify_spots_or_lesions(img):
120
  spot_pixels = sum(cv2.contourArea(cnt) for cnt in filtered_contours)
121
  total_pixels = edges.shape[0] * edges.shape[1]
122
  percentage_spots = (spot_pixels / total_pixels)*100
123
- print(f"Percentage of spots/lesions: {percentage_spots:.2f}%")
124
 
125
  # Draw filtered contours
126
  contoured_image = cv2.drawContours(cv_image.copy(), filtered_contours, -1, (0, 255, 0), 1)
@@ -254,17 +254,17 @@ def classify_image(image):
254
  # --------------------------------
255
 
256
  if top_class_prob[0] < 0.999: # threshold close to 1 to handle floating-point precision issues
257
- print("Second predicted class:", second_class_name)
258
- print(f"Second class confidence: {second_class_prob[0]:.3%}")
259
  else:
260
- print("Second predicted class: None")
261
 
262
  if "healthy" in predicted_class_name:
263
- print(f"{predicted_class_name} is healthy, skipping further analysis.")
264
  return
265
  else:
266
  if "Background_without_leaves" in predicted_class_name:
267
- print(f"{predicted_class_name} is not recognized as a plant image, skipping further analysis.")
268
  return
269
  else:
270
  spots_percentage = identify_spots_or_lesions(image)
@@ -276,7 +276,7 @@ def classify_image(image):
276
 
277
  if predicted_class_name in Details['Plant'].values:
278
  row = Details.loc[Details['Plant'] == predicted_class_name].iloc[0]
279
- st.write("Disease Identification:", row[4])
280
  st.write("----------------------------------")
281
  #st.write("Management:", row[5])
282
  #st.markdown(severity_disease)
@@ -343,8 +343,8 @@ with tab2:
343
 
344
  result = {key: value.numpy() for key, value in result.items()}
345
 
346
- print("Found %d objects." % len(result["detection_scores"]))
347
- print("Inference time: ", end_time - start_time)
348
 
349
  detection_scores = result["detection_scores"]
350
  detection_class_entities = result["detection_class_entities"]
@@ -359,7 +359,7 @@ with tab2:
359
  entity = detection_class_entities[idx].decode('utf-8')
360
  if "Plant" == entity:
361
  plant_score = detection_scores[idx]
362
- print(f"Plant probability score: {plant_score:.2%}")
363
  result1 = classify_image(image)
364
 
365
  if result1 is not None:
 
120
  spot_pixels = sum(cv2.contourArea(cnt) for cnt in filtered_contours)
121
  total_pixels = edges.shape[0] * edges.shape[1]
122
  percentage_spots = (spot_pixels / total_pixels)*100
123
+ st.write(f"Percentage of spots/lesions: {percentage_spots:.2f}%")
124
 
125
  # Draw filtered contours
126
  contoured_image = cv2.drawContours(cv_image.copy(), filtered_contours, -1, (0, 255, 0), 1)
 
254
  # --------------------------------
255
 
256
  if top_class_prob[0] < 0.999: # threshold close to 1 to handle floating-point precision issues
257
+ st.write("Second predicted class:", second_class_name)
258
+ st.write(f"Second class confidence: {second_class_prob[0]:.3%}")
259
  else:
260
+ st.write("Second predicted class: None")
261
 
262
  if "healthy" in predicted_class_name:
263
+ st.write(f"{predicted_class_name} is healthy, skipping further analysis.")
264
  return
265
  else:
266
  if "Background_without_leaves" in predicted_class_name:
267
+ st.write(f"{predicted_class_name} is not recognized as a plant image, skipping further analysis.")
268
  return
269
  else:
270
  spots_percentage = identify_spots_or_lesions(image)
 
276
 
277
  if predicted_class_name in Details['Plant'].values:
278
  row = Details.loc[Details['Plant'] == predicted_class_name].iloc[0]
279
+ #st.write("Disease Identification:", row[4])
280
  st.write("----------------------------------")
281
  #st.write("Management:", row[5])
282
  #st.markdown(severity_disease)
 
343
 
344
  result = {key: value.numpy() for key, value in result.items()}
345
 
346
+ #st.write("Found %d objects." % len(result["detection_scores"]))
347
+ st.write("Inference time: ", end_time - start_time)
348
 
349
  detection_scores = result["detection_scores"]
350
  detection_class_entities = result["detection_class_entities"]
 
359
  entity = detection_class_entities[idx].decode('utf-8')
360
  if "Plant" == entity:
361
  plant_score = detection_scores[idx]
362
+ st.write(f"Plant probability score: {plant_score:.2%}")
363
  result1 = classify_image(image)
364
 
365
  if result1 is not None: