Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMYOLO for yolov5 instance segmentation on balloon dataset getting this error "ValueError: Key img_path is not in available keys." #1018

Open
3 tasks done
Chanchalsrm opened this issue Jun 21, 2024 · 2 comments

Comments

@Chanchalsrm
Copy link

Prerequisite

🐞 Describe the bug

I am trying the replicate mmyolo instance segmentation using balloon data set as per the document (https://mmyolo.readthedocs.io/en/latest/get_started/15_minutes_instance_segmentation.html#)
I have followed all the instruction as per the document. After execution
"import os

os.system('python tools/train.py configs/yolov5/ins_seg/yolov5_ins_s-v61_syncbn_fast_8xb16-300e_balloon_instance.py')"

I am getting this error "ValueError: Key img_path is not in available keys."

The error in details:

06/20 02:47:12 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io
06/20 02:47:12 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future.
06/20 02:47:12 - mmengine - INFO - Checkpoints will be saved to /raid/home/dgxuser3/ChanchalBiswas/mmyolo/work_dirs/yolov5_ins_s-v61_syncbn_fast_8xb16-300e_balloon_instance.
/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/albumentations/core/composition.py:144: UserWarning: Got processor for bboxes, but no transform to process it.
self._set_keys()
Traceback (most recent call last):
File "tools/train.py", line 123, in
main()
File "tools/train.py", line 119, in main
runner.train()
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmengine/runner/runner.py", line 1777, in train
model = self.train_loop.run() # type: ignore
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmengine/runner/loops.py", line 96, in run
self.run_epoch()
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmengine/runner/loops.py", line 112, in run_epoch
for idx, data_batch in enumerate(self.dataloader):
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/torch/_utils.py", line 434, in reraise
raise exception
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 410, in getitem
data = self.prepare_data(idx)
File "/raid/home/dgxuser3/ChanchalBiswas/mmyolo/mmyolo/datasets/yolov5_coco.py", line 53, in prepare_data
return self.pipeline(data_info)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 60, in call
data = t(data)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmcv/transforms/base.py", line 12, in call
return self.transform(results)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmdet/structures/bbox/box_type.py", line 267, in wrapper
return func(self, results)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/mmdet/datasets/transforms/transforms.py", line 1699, in transform
results = self.aug(**results)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/albumentations/core/composition.py", line 255, in call
self._check_args(**data)
File "/home/dgxuser3/anaconda3/envs/mmyolo2/lib/python3.8/site-packages/albumentations/core/composition.py", line 324, in _check_args
raise ValueError(msg)
ValueError: Key img_path is not in available keys.

Could you please provide me a solution

Thank you!

Environment

import os
os.system('python mmyolo/utils/collect_env.py')

Result
sys.platform: linux
Python: 3.8.19 (default, Mar 20 2024, 19:58:24) [GCC 11.2.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0,1,2,3,4,5,6,7: Tesla V100-SXM2-32GB
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.4, V12.4.131
GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
PyTorch: 1.10.1
PyTorch compiling details: PyTorch built with:

  • GCC 7.3
  • C++ Version: 201402
  • Intel(R) oneAPI Math Kernel Library Version 2023.1-Product Build 20230303 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_61,code=sm_61;-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;-gencode;arch=compute_37,code=compute_37
  • 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.1, 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,

TorchVision: 0.11.2
OpenCV: 4.10.0
MMEngine: 0.10.4
MMCV: 2.0.1
MMDetection: 3.3.0
MMYOLO: 0.6.0+8c4d9dc

Additional information

Step 1
conda create -n mmyolo2 python=3.8 -y
conda activate mmyolo2

If you have GPU

conda install pytorch torchvision -c pytorch

Step 2
Installed jupyter notebook
conda jupyterlab

Step 3
Open jupyter notebook

Step 4
Clone mmyolo

!git clone https://github.com/open-mmlab/mmyolo.git
!cd mmyolo
pip install -r requirements/albu.txt
!mim install -v -e .

Step 5
Downloaded the data

import os
os.system('python tools/misc/download_dataset.py --dataset-name balloon --save-dir data/balloon --unzip --delete')

Step 6
Converted to coco

import os
os.system('python ./tools/dataset_converters/balloon2coco.py')

Step 7
train yolov5

import os
os.system('python tools/train.py configs/yolov5/ins_seg/yolov5_ins_s-v61_syncbn_fast_8xb16-300e_balloon_instance.py')

Step 8

Change in ins_seg/yolov5_ins_s-v61_syncbn_fast_8xb16-300e_balloon_instance.py

base = './yolov5_ins_s-v61_syncbn_fast_8xb16-300e_coco_instance.py' # noqa

data_root = 'data/balloon/balloon/'

Path of train annotation file

train_ann_file = 'train.json'
train_data_prefix = 'train/' # Prefix of train image path

Path of val annotation file

val_ann_file = 'val.json'
val_data_prefix = 'val/' # Prefix of val image path
metainfo = {
'classes': ('balloon', ),
'palette': [
(220, 20, 60),
]
}
num_classes = 1

train_batch_size_per_gpu = 4
train_num_workers = 2
log_interval = 1
#####################
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
data_root=data_root,
metainfo=metainfo,
data_prefix=dict(img=train_data_prefix),
ann_file=train_ann_file))
val_dataloader = dict(
dataset=dict(
data_root=data_root,
metainfo=metainfo,
data_prefix=dict(img=val_data_prefix),
ann_file=val_ann_file))
test_dataloader = val_dataloader
val_evaluator = dict(ann_file=data_root + val_ann_file)
test_evaluator = val_evaluator
default_hooks = dict(logger=dict(interval=log_interval))
#####################

model = dict(bbox_head=dict(head_module=dict(num_classes=num_classes)))

@Lazy-coder-9527
Copy link

pip install albumentations==1.3.1
this maybe work for your problem.

@upupupfei
Copy link

pip install albumentations==1.3.1

it works,thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants