File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ def remove_useless_info(coco):
19
19
"""
20
20
if isinstance (coco , COCO ):
21
21
dataset = coco .dataset
22
- dataset .pop ("info" , None )
23
22
dataset .pop ("licenses" , None )
24
23
for img in dataset ["images" ]:
25
24
img .pop ("license" , None )
@@ -147,7 +146,7 @@ def load_image(self, index):
147
146
148
147
img_file = os .path .join (self .data_dir , self .name , file_name )
149
148
150
- img = cv2 .imread (img_file , cv2 .IMREAD_COLOR_BGR if self .num_channels == 3 else cv2 .IMREAD_GRAYSCALE )
149
+ img = cv2 .imread (img_file , cv2 .IMREAD_COLOR if self .num_channels == 3 else cv2 .IMREAD_GRAYSCALE )
151
150
assert img is not None , f"file named { img_file } not found"
152
151
153
152
return img
Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ def __init__(
108
108
dataset_name = "VOC0712" ,
109
109
cache = False ,
110
110
cache_type = "ram" ,
111
+ num_channels = 3
111
112
):
112
113
self .root = data_dir
113
114
self .image_set = image_sets
@@ -131,6 +132,7 @@ def __init__(
131
132
):
132
133
self .ids .append ((rootpath , line .strip ()))
133
134
self .num_imgs = len (self .ids )
135
+ self .num_channels = num_channels
134
136
135
137
self .annotations = self ._load_coco_annotations ()
136
138
@@ -184,7 +186,7 @@ def load_resized_img(self, index):
184
186
185
187
def load_image (self , index ):
186
188
img_id = self .ids [index ]
187
- img = cv2 .imread (self ._imgpath % img_id , cv2 .IMREAD_COLOR )
189
+ img = cv2 .imread (self ._imgpath % img_id , cv2 .IMREAD_COLOR if self . num_channels == 3 else cv2 . IMREAD_GRAYSCALE )
188
190
assert img is not None , f"file named { self ._imgpath % img_id } not found"
189
191
190
192
return img
You can’t perform that action at this time.
0 commit comments