Skip to content

Commit

Permalink
mask detection bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavvz committed Mar 22, 2018
1 parent fd4a5c4 commit 490986d
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 16 deletions.
5 changes: 3 additions & 2 deletions object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ def detection(detection_graph, category_index, score, expand):
fps.update()

# End everything
gpu_worker.stop()
cpu_worker.stop()
if split_model:
gpu_worker.stop()
cpu_worker.stop()
fps.stop()
video_stream.stop()
cv2.destroyAllWindows()
Expand Down
Binary file modified object_detection/__init__.pyc
Binary file not shown.
Binary file modified object_detection/core/__init__.pyc
Binary file not shown.
Binary file modified object_detection/core/box_list.pyc
Binary file not shown.
Binary file modified object_detection/core/box_list_ops.pyc
Binary file not shown.
Binary file modified object_detection/core/standard_fields.pyc
Binary file not shown.
Binary file modified object_detection/protos/__init__.pyc
Binary file not shown.
Binary file modified object_detection/protos/string_int_label_map_pb2.pyc
Binary file not shown.
Binary file modified object_detection/utils/__init__.pyc
Binary file not shown.
Binary file modified object_detection/utils/label_map_util.pyc
Binary file not shown.
Binary file modified object_detection/utils/ops.pyc
Binary file not shown.
Binary file modified object_detection/utils/shape_utils.pyc
Binary file not shown.
Binary file modified object_detection/utils/static_shape.pyc
Binary file not shown.
Binary file modified object_detection/utils/visualization_utils.pyc
Binary file not shown.
18 changes: 4 additions & 14 deletions object_detection_mask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
num_classes = cfg['num_classes']
split_model = cfg['split_model']
log_device = cfg['log_device']
convert_rgb = cfg['convert_rgb']
ssd_shape = cfg['ssd_shape']


Expand Down Expand Up @@ -220,21 +219,13 @@ def detection(detection_graph, category_index, score, expand):
cur_frames = 0
while video_stream.isActive():
image = video_stream.read()
fps.update()
# read video frame and expand dimensions
if convert_rgb:
try:
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
cvt = True
except:
print("Error converting BGR2RGB")
cvt = False
image_expanded = np.expand_dims(cv2.cvtColor(image, cv2.COLOR_BGR2RGB),0)
# detection
if split_model:
(score, expand) = sess.run([score_out, expand_out], feed_dict={image_tensor: np.expand_dims(image, 0)})
(score, expand) = sess.run([score_out, expand_out], feed_dict={image_tensor:image_expanded})
output_dict = sess.run(tensor_dict, feed_dict={score_in:score, expand_in: expand})
else:
output_dict = sess.run(tensor_dict, feed_dict={image_tensor: np.expand_dims(image, 0)})
output_dict = sess.run(tensor_dict, feed_dict={image_tensor: image_expanded})
#num = int(output_dict['num_detections'][0])
classes = output_dict['detection_classes'][0].astype(np.uint8)
boxes = output_dict['detection_boxes'][0]
Expand All @@ -243,8 +234,6 @@ def detection(detection_graph, category_index, score, expand):
output_dict['detection_masks'] = output_dict['detection_masks'][0]
# Visualization of the results of a detection.
if visualize:
if convert_rgb and cvt:
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
vis_util.visualize_boxes_and_labels_on_image_array(
image,
boxes,
Expand All @@ -270,6 +259,7 @@ def detection(detection_graph, category_index, score, expand):
print("label: {}\nscore: {}\nbox: {}".format(label, score, box))
if cur_frames >= max_frames:
break
fps.update()
# End everything
fps.stop()
video_stream.stop()
Expand Down
Binary file modified stuff/__init__.pyc
Binary file not shown.
Binary file modified stuff/helper.pyc
Binary file not shown.

0 comments on commit 490986d

Please sign in to comment.