mmagic icon indicating copy to clipboard operation
mmagic copied to clipboard

[Bug] Pypi Library broken: FileNotFoundError

Open nicolaus-huang opened this issue 1 year ago • 4 comments

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

main branch https://github.com/open-mmlab/mmagic

Environment

sys.platform: linux
Python: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
CUDA available: True
numpy_random_seed: 2147483648
GPU 0: NVIDIA GeForce RTX 3060
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 11.6, V11.6.124
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
PyTorch: 1.13.1+cu116
PyTorch compiling details: PyTorch built with:
  - GCC 9.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.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - 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.6
  - 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.3.2  (built against CUDA 11.5)
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.6, CUDNN_VERSION=8.3.2, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -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 -Werror=non-virtual-dtor -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_VERSION=1.13.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, USE_ROCM=OFF, 

TorchVision: 0.14.1+cu116
OpenCV: 4.7.0
MMEngine: 0.7.2
MMCV: 2.0.0
MMCV Compiler: GCC 9.3
MMCV CUDA Compiler: 11.6
MMagic: 1.0.0+

Reproduces the problem - code sample

from mmagic.apis import MMagicInferencer

# Create a MMagicInferencer instance and infer
result_out_dir = './result.jpg'
editor = MMagicInferencer('biggan', model_setting=4)
results = editor.infer(label=1, result_out_dir='./biggan_res.jpg')

Reproduces the problem - command or script

python3 script.py

Reproduces the problem - error message

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/humor/SDU_graduate/Validation/test.py:5 in <module>                                        │
│                                                                                                  │
│   2                                                                                              │
│   3 # Create a MMagicInferencer instance and infer                                               │
│   4 result_out_dir = './result.jpg'                                                              │
│ ❱ 5 editor = MMagicInferencer('biggan', model_setting=4)                                         │
│   6 results = editor.infer(label=1, result_out_dir='./biggan_res.jpg')                           │
│   7                                                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/mmagic/apis/mmagic_inferencer.py:123 in __init__         │
│                                                                                                  │
│   120 │   │   │   │    seed: int = 2022,                                                         │
│   121 │   │   │   │    **kwargs) -> None:                                                        │
│   122 │   │   init_default_scope('mmagic')                                                       │
│ ❱ 123 │   │   MMagicInferencer.init_inference_supported_models_cfg()                             │
│   124 │   │   inferencer_kwargs = {}                                                             │
│   125 │   │   inferencer_kwargs.update(                                                          │
│   126 │   │   │   self._get_inferencer_kwargs(model_name, model_setting,                         │
│                                                                                                  │
│ /usr/local/lib/python3.10/dist-packages/mmagic/apis/mmagic_inferencer.py:232 in                  │
│ init_inference_supported_models_cfg                                                              │
│                                                                                                  │
│   229 │   │   │   for model_name in MMagicInferencer.inference_supported_models:                 │
│   230 │   │   │   │   meta_file_dir = osp.join(all_cfgs_dir, model_name,                         │
│   231 │   │   │   │   │   │   │   │   │   │    'metafile.yml')                                   │
│ ❱ 232 │   │   │   │   with open(meta_file_dir, 'r') as stream:                                   │
│   233 │   │   │   │   │   parsed_yaml = yaml.safe_load(stream)                                   │
│   234 │   │   │   │   task = parsed_yaml['Models'][0]['Results'][0]['Task']                      │
│   235 │   │   │   │   MMagicInferencer.inference_supported_models_cfg[                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.10/dist-packages/mmagic/apis/../../configs/inst_colorization/metafile.yml'

Additional information

It's too hard to use

nicolaus-huang avatar Apr 25 '23 13:04 nicolaus-huang

I run your codes, and get the same results like this https://github.com/open-mmlab/mmagic/issues/1814 . Can you reproduce this error 'FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.10/dist-packages/mmagic/apis/../../configs/inst_colorization/metafile.yml''?

Z-Fran avatar Apr 26 '23 03:04 Z-Fran

I run your codes, and get the same results like this #1814 . Can you reproduce this error 'FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.10/dist-packages/mmagic/apis/../../configs/inst_colorization/metafile.yml''?

Sure, just install mmagic using pip install git+https://github.com/open-mmlab/mmagic.git -v

and rerun my code.

from mmagic.apis import MMagicInferencer

result_out_dir = './result.jpg'
editor = MMagicInferencer('biggan', model_setting=4)
results = editor.infer(label=1, result_out_dir='./biggan_res.jpg')

nicolaus-huang avatar Apr 26 '23 03:04 nicolaus-huang

This is caused by https://github.com/open-mmlab/mmagic/blob/05aac573bf302129d378725a3d9226027b8c3a87/mmagic/apis/mmagic_inferencer.py#L227

and

https://github.com/open-mmlab/mmagic/blob/05aac573bf302129d378725a3d9226027b8c3a87/mmagic/apis/mmagic_inferencer.py#L149

which indicates that the config files should be in the ../../configs directory where it's not.

nicolaus-huang avatar Apr 26 '23 03:04 nicolaus-huang

But this is not the case, I fixed that and it gave me another warning code causing bad results

Rerun my code

from mmagic.apis import MMagicInferencer

result_out_dir = './result.jpg'
editor = MMagicInferencer('biggan', model_setting=4)
results = editor.infer(label=1, result_out_dir='./biggan_res.jpg')

the output should be like:

/usr/local/lib/python3.10/dist-packages/mmcv/cnn/bricks/conv_module.py:153: UserWarning: Unnecessary conv bias before batch/instance norm
  warnings.warn(
Loads checkpoint by http backend from path: https://download.openmmlab.com/mmediting/biggan/biggan-deep_imagenet1k_256x256_cvt_hugging-face_rgb_20210728_111735-28651569.pth
04/26 11:49:55 - mmengine - WARNING - Failed to search registry with scope "mmagic" in the "function" registry tree. As a workaround, the current "function" registry in "mmengine" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmagic" is a correct scope, or whether the registry is initialized.
04/26 11:49:55 - mmengine - WARNING - `Visualizer` backend is not initialized because save_dir is None.

and the image it generated is terrible result

nicolaus-huang avatar Apr 26 '23 03:04 nicolaus-huang

Since the error complains missing config files, I just do !git clone https://github.com/open-mmlab/mmagic.git and !cp -r /content/mmagic/configs /usr/local/lib/python3.10/dist-packages/, and it seems to work fine. I use Colab. Good luck.

yiboji avatar Apr 28 '23 04:04 yiboji

Something is wrong in installation script IMO.

yiboji avatar Apr 28 '23 04:04 yiboji

Hi, we fix the bug there https://github.com/open-mmlab/mmagic/pull/1829 @Jay-Humor

Z-Fran avatar Apr 28 '23 06:04 Z-Fran

Closing this issue since the bug has been fixed in a merged pull request. Please feel free to reopen it if it has not been fixed.

Z-Fran avatar Apr 28 '23 07:04 Z-Fran

Thanks!

nicolaus-huang avatar Apr 28 '23 14:04 nicolaus-huang

Hi, we fix the bug there #1829 @Jay-Humor

hi, firstly thanks for this powerful framework.

My question is that the FileNotFoundError is still there, right? not be fixed in latest release version(1.0.0) Because I have faced the same problem.

I can fix this manually by copying the "config" folder to the side-package folder, but this is not an elegant solution.

haobo724 avatar May 07 '23 22:05 haobo724

Fix it later.

Z-Fran avatar May 26 '23 05:05 Z-Fran