Closed BananaTonic closed 2 years ago
As the documentation (https://detectron2.readthedocs.io/en/latest/tutorials/datasets.html#metadata-for-datasets) and the error says, it is expecting metadata "stuff_classes", not "stuff_names".
I'm trying to train model on the CityScapes by using sample, but when I run this code it gives me an error.
This link points to detectron2 v0.2, which is more than 2 years old. Please don't refer to it.
Instructions To Reproduce the Issue:
I'm trying to train model on the CityScapes by using sample, but when I run this code it gives me an error.
from detectron2.structures import BoxMode from detectron2.utils.comm import get_world_size from detectron2.utils.logger import setup_logger
try: import cv2 # noqa except ImportError:
OpenCV is an optional dependency at the moment
logger = logging.getLogger(name)
def get_cityscapes_files(image_dir, gt_dir): files = []
scan through the directory
[docs]def load_cityscapes_instances(image_dir, gt_dir, from_json=True, to_polygons=True): """ Args: image_dir (str): path to the raw dataset. e.g., "~/cityscapes/leftImg8bit/train". gt_dir (str): path to the raw annotations. e.g., "~/cityscapes/gtFine/train". from_json (bool): whether to read annotations from the raw json file or the png files. to_polygons (bool): whether to represent the segmentation as polygons (COCO's format) instead of masks (cityscapes's format).
def load_cityscapes_semantic(image_dir, gt_dir): """ Args: image_dir (str): path to the raw dataset. e.g., "~/cityscapes/leftImg8bit/train". gt_dir (str): path to the raw annotations. e.g., "~/cityscapes/gtFine/train".
def cityscapes_files_to_dict(files, from_json, to_polygons): """ Parse cityscapes annotation files to a instance segmentation dataset dict.
if name == "main": """ Test the cityscapes dataset loader.
Generating labelTrainIds.png with cityscapesscripts/preparation/createTrainIdLabelImgs.py
CITYSCAPES_DATASET=/path/to/cityscapes python cityscapesscripts/preparation/createPanopticImgs.py
Execute sample code
python /path/to/script/cityscapes_sample.py --type semantic /path/to/cityscapes/leftImg8bit/train /path/to/cityscapes/gtFine/train
[11/22 12:20:21 main]: 18 cities found in '/path/to/cityscapes/leftImg8bit/train'. [11/22 12:20:31 main]: Done loading 2975 samples. Traceback (most recent call last): File "/path/to/script/cityscapes_sample.py", line 326, in
vis = visualizer.draw_dataset_dict(d)
File "/usr/local/lib/python3.6/dist-packages/detectron2/utils/visualizer.py", line 579, in draw_dataset_dict
self.draw_sem_seg(sem_seg, area_threshold=0, alpha=0.5)
File "/usr/local/lib/python3.6/dist-packages/detectron2/utils/visualizer.py", line 442, in draw_sem_seg
for label in filter(lambda l: l < len(self.metadata.stuff_classes), labels):
File "/usr/local/lib/python3.6/dist-packages/detectron2/utils/visualizer.py", line 442, in
for label in filter(lambda l: l < len(self.metadata.stuff_classes), labels):
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/catalog.py", line 128, in getattr
"keys are {}.".format(key, self.name, str(self.dict.keys()))
AttributeError: Attribute 'stuff_classes' does not exist in the metadata of dataset 'N/A'. Available keys are dict_keys(['stuff_names', 'stuff_colors']).
Process finished with exit code 1
sys.platform linux Python 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0] numpy 1.19.5 detectron2 0.5 @/usr/local/lib/python3.6/dist-packages/detectron2 Compiler GCC 7.3 CUDA compiler CUDA 10.2 detectron2 arch flags 3.7, 5.0, 5.2, 6.0, 6.1, 7.0, 7.5 DETECTRON2_ENV_MODULE
PyTorch 1.9.0+cu102 @/usr/local/lib/python3.6/dist-packages/torch
PyTorch debug build False
GPU available Yes
GPU 0,1,2,3 Tesla V100-DGXS-32GB (arch=7.0)
CUDA_HOME /usr/local/cuda
Pillow 8.1.0
torchvision 0.10.0+cu102 @/usr/local/lib/python3.6/dist-packages/torchvision
torchvision arch flags 3.5, 5.0, 6.0, 7.0, 7.5
fvcore 0.1.5.post20210924
iopath 0.1.8
cv2 4.5.3
PyTorch built with: