yifehuang97 commited on
Commit
a77ab47
·
1 Parent(s): f028c47

(feat) update neg process

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -167,20 +167,20 @@ def count_objects(image, pos_caption, neg_caption, box_threshold, point_radius,
167
  neg_boxes = [box.tolist() for box in neg_boxes]
168
  neg_points = [[box[0], box[1]] for box in neg_boxes]
169
 
170
- # img_size = image.size
171
- # filtered_points, kept_indices = filter_points_by_negative(
172
- # points,
173
- # neg_points,
174
- # image_size=img_size,
175
- # pixel_threshold=5
176
- # )
177
 
178
- # filtered_boxes = [boxes[i] for i in kept_indices]
179
- # if "scores" in results:
180
- # filtered_scores = [results["scores"][i].item() for i in kept_indices]
181
 
182
- # points = filtered_points
183
- # boxes = filtered_boxes
184
 
185
  # Visualize results
186
  img_w, img_h = image.size
 
167
  neg_boxes = [box.tolist() for box in neg_boxes]
168
  neg_points = [[box[0], box[1]] for box in neg_boxes]
169
 
170
+ img_size = image.size
171
+ filtered_points, kept_indices = filter_points_by_negative(
172
+ points,
173
+ neg_points,
174
+ image_size=img_size,
175
+ pixel_threshold=5
176
+ )
177
 
178
+ filtered_boxes = [boxes[i] for i in kept_indices]
179
+ if "scores" in results:
180
+ filtered_scores = [results["scores"][i].item() for i in kept_indices]
181
 
182
+ points = filtered_points
183
+ boxes = filtered_boxes
184
 
185
  # Visualize results
186
  img_w, img_h = image.size