Skip to content

Please read & provide the following #4761

@anirbankonar123

Description

@anirbankonar123

If you do not know the root cause of the problem, please post according to this template:

Instructions To Reproduce the Issue:

Creating dict from COCO JSON here:

def get_corrosion_dicts(img_dir,json_file):
dataset_dicts = []
f = open(json_file)
data = json.load(f)
ctr=0
for i in range(len(data['images'])):
record = {}
annotations=[]
filename = os.path.join(img_dir+data['images'][i]["file_name"])
record["file_name"] = filename
record["sem_seg_file_name"] = filename
record["sem_seg"] = "True"
record["image_id"] = data['images'][i]["id"]
record["height"] = data['images'][i]["height"]
record["width"] = data['images'][i]["width"]

    for j in range(len(data["annotations"])):
        if (data['annotations'][j]['image_id'] == record["image_id"]):
              anno = data['annotations'][j]
              anno["bbox_mode"]= BoxMode.XYXY_ABS
              annotations.append(anno)
    record["annotations"]=annotations
    dataset_dicts.append(record)
  
return dataset_dicts

dataset_dicts = get_corrosion_dicts(,)

DatasetCatalog.register("coco_train", lambda d=d: get_corrosion_dicts("/content/Blisters/","/content/Train_Coco.json"))
MetadataCatalog.get("coco_train").set(thing_classes=["Blisters"])
MetadataCatalog.get("coco_train").set(stuff_classes=["Blisters"])

dataset_dicts = get_corrosion_dicts(,)
for d in random.sample(dataset_dicts, 3):
img = cv2.imread(d["file_name"])
visualizer = Visualizer(img[:, :, ::-1], metadata=coco_metadata, scale=0.5)
out = visualizer.draw_dataset_dict(d)
cv2_imshow(out.get_image()[:, :, ::-1])

  1. Full runnable code or full changes you made:

https://colab.research.google.com/drive/1gbSuwvct8gyBNVMBebgSsEeYRT20Qe7Q?usp=sharing

  1. What exact command you run:
    out = visualizer.draw_dataset_dict(d)
  2. Full logs or other relevant observations:
    ERROR :
    /usr/local/lib/python3.8/dist-packages/detectron2/utils/visualizer.py in (.0)
    242 if classes is not None:
    243 if class_names is not None and len(class_names) > 0:
    --> 244 labels = [class_names[i] for i in classes]
    245 else:
    246 labels = [str(i) for i in classes]

IndexError: list index out of range


## Expected behavior:
Trying to use SemSegEvaluator to get MeanIoU score
If there are no obvious crash in "full logs" provided above,
please tell us the expected behavior.

SemSegEvaluator should work and give the MeanIoU score , from COCO Json as input, and transformed as dict (as shown above)

If you expect a model to converge / work better, we do not help with such issues, unless
a model fails to reproduce the results in detectron2 model zoo, or proves existence of bugs.

## Environment:

Paste the output of the following command:

wget -nc -nv https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py

2023-01-31 05:10:27 URL:https://raw.githubusercontent.com/facebookresearch/detectron2/main/detectron2/utils/collect_env.py [8391/8391] -> "collect_env.py" [1]
----------------------  ----------------------------------------------------------------
sys.platform            linux
Python                  3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
numpy                   1.21.6
detectron2              0.6 @/usr/local/lib/python3.8/dist-packages/detectron2
Compiler                GCC 7.3
CUDA compiler           CUDA 11.3
detectron2 arch flags   3.7, 5.0, 5.2, 6.0, 6.1, 7.0, 7.5, 8.0, 8.6
DETECTRON2_ENV_MODULE   <not set>
PyTorch                 1.10.0+cu113 @/usr/local/lib/python3.8/dist-packages/torch
PyTorch debug build     False
GPU available           Yes
GPU 0                   Tesla T4 (arch=7.5)
Driver version          510.47.03
CUDA_HOME               /usr/local/cuda
Pillow                  7.1.2
torchvision             0.11.0+cu113 @/usr/local/lib/python3.8/dist-packages/torchvision
torchvision arch flags  3.5, 5.0, 6.0, 7.0, 7.5, 8.0, 8.6
fvcore                  0.1.5.post20221221
iopath                  0.1.9
cv2                     4.6.0
----------------------  ----------------------------------------------------------------
PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.3
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
  - CuDNN 8.2
  - Magma 2.5.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, 

If your issue looks like an installation issue / environment issue,
please first check common issues in https://detectron2.readthedocs.io/tutorials/install.html#common-installation-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions