Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8da696b

Browse files
committed
Add support to single channel images in visualization tool.
PiperOrigin-RevId: 190996725
1 parent 642e100 commit 8da696b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

research/object_detection/eval_util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def visualize_detection_results(result_dict,
7979
data corresponding to each image being evaluated. The following keys
8080
are required:
8181
'original_image': a numpy array representing the image with shape
82-
[1, height, width, 3]
82+
[1, height, width, 3] or [1, height, width, 1]
8383
'detection_boxes': a numpy array of shape [N, 4]
8484
'detection_scores': a numpy array of shape [N]
8585
'detection_classes': a numpy array of shape [N]
@@ -133,6 +133,8 @@ def visualize_detection_results(result_dict,
133133
category_index = label_map_util.create_category_index(categories)
134134

135135
image = np.squeeze(result_dict[input_fields.original_image], axis=0)
136+
if image.shape[2] == 1: # If one channel image, repeat in RGB.
137+
image = np.tile(image, [1, 1, 3])
136138
detection_boxes = result_dict[detection_fields.detection_boxes]
137139
detection_scores = result_dict[detection_fields.detection_scores]
138140
detection_classes = np.int32((result_dict[

0 commit comments

Comments
 (0)