Skip to content

Commit 569a3f0

Browse files
authored
Merge pull request #89 from palacima/patch-1
Update tf_iou.py
2 parents fde7b6c + ff28780 commit 569a3f0

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

examples/utils/tf_iou.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,28 @@ def pred_bbox():
6666
detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')
6767
detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')
6868
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
69-
for image_path in test_imgs:
70-
image = Image.open(image_path)
71-
image_np = load_image_into_numpy_array(image)
72-
# the array based representation of the image will be used later in order to prepare the
73-
# result image with boxes and labels on it.
74-
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
75-
image_np_expanded = np.expand_dims(image_np, axis=0)
76-
# Actual detection.
77-
(boxes, scores, classes, num) = sess.run(
78-
[detection_boxes, detection_scores, detection_classes, num_detections],
79-
feed_dict={image_tensor: image_np_expanded})
80-
### 256 here is the image size from Label Maker, adjust it according to your input image size.
81-
bboxe = (boxes*256).astype(np.int)
82-
bboxe = np.squeeze(bboxe)
83-
score = np.squeeze(((scores*100).transpose()).astype(np.int))
84-
### only keep the bbox that prediction score is higher than 50.
85-
bboxes = bboxe[score > 50]
86-
if bboxes.any():
87-
bboxes_ls = bboxes.tolist()
88-
for bbox in bboxes_ls:
89-
# pred_bboxes.append([image_path[-18:],bbox])
90-
pred_bboxes.append(bbox)
69+
for image_path in test_imgs:
70+
image = Image.open(image_path)
71+
image_np = load_image_into_numpy_array(image)
72+
# the array based representation of the image will be used later in order to prepare the
73+
# result image with boxes and labels on it.
74+
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
75+
image_np_expanded = np.expand_dims(image_np, axis=0)
76+
# Actual detection.
77+
(boxes, scores, classes, num) = sess.run(
78+
[detection_boxes, detection_scores, detection_classes, num_detections],
79+
feed_dict={image_tensor: image_np_expanded})
80+
### 256 here is the image size from Label Maker, adjust it according to your input image size.
81+
bboxe = (boxes*256).astype(np.int)
82+
bboxe = np.squeeze(bboxe)
83+
score = np.squeeze(((scores*100).transpose()).astype(np.int))
84+
### only keep the bbox that prediction score is higher than 50.
85+
bboxes = bboxe[score > 50]
86+
if bboxes.any():
87+
bboxes_ls = bboxes.tolist()
88+
for bbox in bboxes_ls:
89+
# pred_bboxes.append([image_path[-18:],bbox])
90+
pred_bboxes.append(bbox)
9191
return pred_bboxes
9292

9393
def gr_bbox():

0 commit comments

Comments
 (0)