mosidi commited on
Commit
4ffadc5
·
1 Parent(s): 5415aac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -138,19 +138,18 @@ def inference(image_url, image, min_score):
138
  measurements = {}
139
 
140
  for ind,item_mask in enumerate(masks):
141
- # box=bbox[ind]
142
- # Get the true bounding box of the mask (not the same as the bbox prediction)
143
- segmentation = np.where(item_mask == True)
144
- x_min = int(np.min(segmentation[1]))
145
- x_max = int(np.max(segmentation[1]))
146
- y_min = int(np.min(segmentation[0]))
147
- y_max = int(np.max(segmentation[0]))
148
- measurement = int(0.5+len(segmentation[0])/600)
149
- measurements[ind] = {'measurement': measurement, 'x_min': x_min, 'x_max': x_max, 'y_min': y_min, 'y_max': y_max}
150
- # cv2.putText(img=img, text=str(int(0.5+len( segmentation[0])/600)), org=(x_min+20,y_min-10), fontFace=cv2.FONT_HERSHEY_TRIPLEX, fontScale=0.8, color=(0, 255, 0),thickness=2)
151
- # cv2_imshow(img)
152
-
153
-
154
  # Loop over the masks
155
  # return outputs
156
  for ind, item_mask in enumerate(masks):
 
138
  measurements = {}
139
 
140
  for ind,item_mask in enumerate(masks):
141
+ if segmentation[1].any() segmentation[0].any()
142
+ # box=bbox[ind]
143
+ # Get the true bounding box of the mask (not the same as the bbox prediction)
144
+ segmentation = np.where(item_mask == True)
145
+ x_min = int(np.min(segmentation[1]))
146
+ x_max = int(np.max(segmentation[1]))
147
+ y_min = int(np.min(segmentation[0]))
148
+ y_max = int(np.max(segmentation[0]))
149
+ measurement = int(0.5+len(segmentation[0])/600)
150
+ measurements[ind] = {'measurement': measurement, 'x_min': x_min, 'x_max': x_max, 'y_min': y_min, 'y_max': y_max}
151
+ # cv2.putText(img=img, text=str(int(0.5+len( segmentation[0])/600)), org=(x_min+20,y_min-10), fontFace=cv2.FONT_HERSHEY_TRIPLEX, fontScale=0.8, color=(0, 255, 0),thickness=2)
152
+
 
153
  # Loop over the masks
154
  # return outputs
155
  for ind, item_mask in enumerate(masks):