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

Albumentations error #11925

Open
pedrozamboni opened this issue Aug 28, 2024 · 0 comments
Open

Albumentations error #11925

pedrozamboni opened this issue Aug 28, 2024 · 0 comments
Assignees

Comments

@pedrozamboni
Copy link

Hey, Im having some issues while trying to use Albumentations direct on my config file. I always get this error:

File "tools/train.py", line 247, in
main()
File "tools/train.py", line 236, in main
train_detector(
File "/home/pedro/Documents/Documents/mmdetection-2.28.2/mmdet/apis/train.py", line 246, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 136, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 49, in train
for i, data_batch in enumerate(self.data_loader):
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 634, in next
data = self._next_data()
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1346, in _next_data
return self._process_data(data)
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1372, in _process_data
data.reraise()
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/_utils.py", line 644, in reraise
raise exception
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
data = fetcher.fetch(index)
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 51, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/pedro/Documents/Documents/mmdetection-2.28.2/mmdet/datasets/custom.py", line 220, in getitem
data = self.prepare_train_img(idx)
File "/home/pedro/Documents/Documents/mmdetection-2.28.2/mmdet/datasets/custom.py", line 243, in prepare_train_img
return self.pipeline(results)
File "/home/pedro/Documents/Documents/mmdetection-2.28.2/mmdet/datasets/pipelines/compose.py", line 41, in call
data = t(data)
File "/home/pedro/Documents/Documents/mmdetection-2.28.2/mmdet/datasets/pipelines/transforms.py", line 1487, in call
results = self.aug(**results)
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/albumentations/core/composition.py", line 304, in call
self.preprocess(data)
File "/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/albumentations/core/composition.py", line 331, in preprocess
raise ValueError(msg)
ValueError: Key img_info is not in available keys.

I`m using a custom dataset and a custom loading functions to open npy files with 5 bands.

This is my loading func:

class LoadImageFromNumpy(object):
"""Load an image from file.

Required keys are "img_prefix" and "img_info" (a dict that must contain the
key "filename"). Added or updated keys are "filename", "img", "img_shape",
"ori_shape" (same as `img_shape`), "pad_shape" (same as `img_shape`),
"scale_factor" (1.0) and "img_norm_cfg" (means=0 and stds=1).

Args:
    to_float32 (bool): Whether to convert the loaded image to a float32
        numpy array. If set to False, the loaded image is an uint8 array.
        Defaults to False.
    color_type (str): The flag argument for :func:`mmcv.imfrombytes`.
        Defaults to 'color'.
    file_client_args (dict): Arguments to instantiate a FileClient.
        See :class:`mmcv.fileio.FileClient` for details.
        Defaults to ``dict(backend='disk')``.
    imdecode_backend (str): Backend for :func:`mmcv.imdecode`. Default:
        'cv2'
"""

def __init__(self,
             to_float32=False,
             color_type='color',
             file_client_args=dict(backend='disk'),
             imdecode_backend='numpy',
             bands=[0,1,2],
             ):
    self.to_float32 = to_float32
    self.color_type = color_type
    self.file_client_args = file_client_args.copy()
    self.file_client = None
    self.imdecode_backend = imdecode_backend
    self.bands = bands

def __call__(self, results):
    """Call functions to load image and get image meta information.

    Args:
        results (dict): Result dict from :obj:`mmseg.CustomDataset`.

    Returns:
        dict: The dict contains loaded image and meta information.
    """

    if self.file_client is None:
        self.file_client = mmcv.FileClient(**self.file_client_args)

    if results.get('img_prefix') is not None:
        filename = osp.join(results['img_prefix'],
                            results['img_info']['filename'])
    else:
        filename = results['img_info']['filename']

    #img_bytes = np.load(filename.replace('.png','.npy'))
    #print(filename.replace('.png','.npy'))
    img_bytes = np.load(filename)
    img = img_bytes[:,:,self.bands]
    if self.to_float32:
        img = img.astype(np.float32)

    results['filename'] = filename
    results['ori_filename'] = results['img_info']['filename']
    results['img'] = img
    results['img_shape'] = img.shape
    results['ori_shape'] = img.shape
    # Set initial values for default meta_keys
    results['pad_shape'] = img.shape
    #results['scale_factor'] = 1.0
    num_channels = 1 if len(img.shape) < 3 else img.shape[2]

    return results

Environment
/home/pedro/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/init.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
warnings.warn(
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
sys.platform: linux
Python: 3.8.19 | packaged by conda-forge | (default, Mar 20 2024, 12:47:35) [GCC 12.3.0]
CUDA available: True
GPU 0: NVIDIA GeForce RTX 3090 Ti
CUDA_HOME: /usr
NVCC: Cuda compilation tools, release 11.5, V11.5.119
GCC: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 2.0.0+cu118
PyTorch compiling details: PyTorch built with:

  • GCC 9.3
  • C++ Version: 201703
  • Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.7.3 (Git Hash 6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)
  • 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.8
  • 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;-gencode;arch=compute_90,code=sm_90
  • CuDNN 8.7
  • Magma 2.6.1
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -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 -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=2.0.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=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.15.1+cu118
OpenCV: 4.10.0
MMCV: 1.7.2
MMCV Compiler: GCC 9.3
MMCV CUDA Compiler: 11.8
MMDetection: 2.28.2+

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

2 participants