Skip to content

Commit

Permalink
replace '.jpg' instead of 'jpg' to guarantee replacing file ending (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Fehler committed Jan 4, 2024
1 parent aeb4647 commit 10ae0b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mmdet/datasets/api_wrappers/coco_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def createIndex(self) -> None:
if 'images' in self.dataset:
for img_info in self.dataset['images']:
img_info['segm_file'] = img_info['file_name'].replace(
'jpg', 'png')
'.jpg', '.png')
imgs[img_info['id']] = img_info

if 'categories' in self.dataset:
Expand Down
2 changes: 1 addition & 1 deletion mmdet/datasets/coco_panoptic.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def parse_data_info(self, raw_data_info: dict) -> dict:
if self.data_prefix.get('seg', None):
seg_map_path = osp.join(
self.data_prefix['seg'],
img_info['file_name'].replace('jpg', 'png'))
img_info['file_name'].replace('.jpg', '.png'))
else:
seg_map_path = None
data_info['img_path'] = img_path
Expand Down
6 changes: 3 additions & 3 deletions mmdet/evaluation/metrics/coco_panoptic_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def gt_to_coco_json(self, gt_dicts: Sequence[dict],
}
segments_info.append(new_segment_info)

segm_file = image_info['file_name'].replace('jpg', 'png')
segm_file = image_info['file_name'].replace('.jpg', '.png')
annotation = dict(
image_id=img_id,
segments_info=segments_info,
Expand Down Expand Up @@ -330,7 +330,7 @@ def _compute_batch_pq_stats(self, data_samples: Sequence[dict]):
# parse pred
img_id = data_sample['img_id']
segm_file = osp.basename(data_sample['img_path']).replace(
'jpg', 'png')
'.jpg', '.png')
result = self._parse_predictions(
pred=data_sample,
img_id=img_id,
Expand Down Expand Up @@ -397,7 +397,7 @@ def _process_gt_and_predictions(self, data_samples: Sequence[dict]):
# parse pred
img_id = data_sample['img_id']
segm_file = osp.basename(data_sample['img_path']).replace(
'jpg', 'png')
'.jpg', '.png')
result = self._parse_predictions(
pred=data_sample, img_id=img_id, segm_file=segm_file)

Expand Down

0 comments on commit 10ae0b3

Please sign in to comment.