Skip to content

Commit

Permalink
[Fix] Fix module PascalContextDataset (#3235)
Browse files Browse the repository at this point in the history
## Motivation

- 'PascalContextDataset' object has no attribute 'file_client', it will
cause an error.
- The attribute ‘ann_file’ is not allowed to be empty, otherwise, an
error will be reported.

## Modification
- Replace file_client with fileio
  • Loading branch information
angiecao authored Aug 9, 2023
1 parent 1235217 commit 4927b0e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions mmseg/datasets/pascal_context.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmengine.fileio as fileio

from mmseg.registry import DATASETS
from .basesegdataset import BaseSegDataset
Expand Down Expand Up @@ -46,18 +46,18 @@ class PascalContextDataset(BaseSegDataset):
[255, 71, 0], [0, 235, 255], [0, 173, 255], [31, 0, 255]])

def __init__(self,
ann_file: str,
ann_file='',
img_suffix='.jpg',
seg_map_suffix='.png',
reduce_zero_label=False,
**kwargs) -> None:
super().__init__(
img_suffix=img_suffix,
seg_map_suffix=seg_map_suffix,
ann_file=ann_file,
reduce_zero_label=False,
reduce_zero_label=reduce_zero_label,
**kwargs)
assert self.file_client.exists(
self.data_prefix['img_path']) and osp.isfile(self.ann_file)
assert fileio.exists(self.data_prefix['img_path'], self.backend_args)


@DATASETS.register_module()
Expand All @@ -66,8 +66,10 @@ class PascalContextDataset59(BaseSegDataset):
In segmentation map annotation for PascalContext, 0 stands for background,
which is included in 60 categories. ``reduce_zero_label`` is fixed to
False. The ``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is
True. The ``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is
fixed to '.png'.
Noted: If the background is 255 and the ids of categories are from 0 to 58,
``reduce_zero_label`` needs to be set to False.
Args:
ann_file (str): Annotation file path.
Expand Down Expand Up @@ -100,7 +102,7 @@ class PascalContextDataset59(BaseSegDataset):
[255, 71, 0], [0, 235, 255], [0, 173, 255], [31, 0, 255]])

def __init__(self,
ann_file: str,
ann_file='',
img_suffix='.jpg',
seg_map_suffix='.png',
reduce_zero_label=True,
Expand All @@ -111,5 +113,4 @@ def __init__(self,
ann_file=ann_file,
reduce_zero_label=reduce_zero_label,
**kwargs)
assert self.file_client.exists(
self.data_prefix['img_path']) and osp.isfile(self.ann_file)
assert fileio.exists(self.data_prefix['img_path'], self.backend_args)

0 comments on commit 4927b0e

Please sign in to comment.