fahrnphi commited on
Commit
b272b12
·
verified ·
1 Parent(s): 06d6310

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -19,11 +19,11 @@ def predict_labels_and_probabilities(image_path):
19
  img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
20
 
21
  # Scan the image in a grid-like fashion
22
- step_size = 100 # Step size for the grid
23
  predictions = []
24
 
25
- for y in range(0, img_rgb.shape[0] - img_height, step_size):
26
- for x in range(0, img_rgb.shape[1] - img_width, step_size):
27
  patch = img_rgb[y:y+img_height, x:x+img_width]
28
  patch_resized = cv2.resize(patch, (img_height, img_width))
29
  patch_array = image.img_to_array(patch_resized)
@@ -68,4 +68,10 @@ if uploaded_file is not None:
68
  st.write(f"Location: ({x1}, {y1}) to ({x2}, {y2})")
69
 
70
  # Display the image with rectangles
71
- st.image(img_with_boxes, caption='Detected Ingredients', use_column_width=True)
 
 
 
 
 
 
 
19
  img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
20
 
21
  # Scan the image in a grid-like fashion
22
+ step_size = 50 # Step size for the grid
23
  predictions = []
24
 
25
+ for y in range(0, img_rgb.shape[0] - img_height + 1, step_size):
26
+ for x in range(0, img_rgb.shape[1] - img_width + 1, step_size):
27
  patch = img_rgb[y:y+img_height, x:x+img_width]
28
  patch_resized = cv2.resize(patch, (img_height, img_width))
29
  patch_array = image.img_to_array(patch_resized)
 
68
  st.write(f"Location: ({x1}, {y1}) to ({x2}, {y2})")
69
 
70
  # Display the image with rectangles
71
+ st.image(img_with_boxes, caption='Detected Ingredients', use_column_width=True)
72
+
73
+ # Debugging information
74
+ if not predictions:
75
+ st.write("No ingredients detected with probability above the threshold.")
76
+ else:
77
+ st.write(f"Total detected patches: {len(predictions)}")