open-mmlab / mmagic

OpenMMLab Multimodal Advanced, Generative, and Intelligent Creation Toolbox. Unlock the magic 🪄: Generative-AI (AIGC), easy-to-use APIs, awsome model zoo, diffusion models, for text-to-image generation, image/video restoration/enhancement, etc.
https://mmagic.readthedocs.io/en/latest/
Apache License 2.0
6.89k stars 1.06k forks source link

[Bug] key error when running restoration_demo.py #1630

Closed z6491679 closed 1 year ago

z6491679 commented 1 year ago

Prerequisite

Task

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

Branch

master branch https://github.com/open-mmlab/mmediting

Environment

/usr/local/lib/python3.6/dist-packages/mmcv/init.py:21: 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. 'On January 1, 2023, MMCV will release v2.0.0, in which it will remove ' fatal: not a git repository (or any of the parent directories): .git sys.platform: linux Python: 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0] CUDA available: True GPU 0,1: Tesla T4 CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 11.2, V11.2.67 GCC: x86_64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 1.8.1+cu111 PyTorch compiling details: PyTorch built with:

TorchVision: 0.9.1+cu111 OpenCV: 4.4.0 MMCV: 1.7.1 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 11.1 MMEditing: 0.16.0+

Reproduces the problem - code sample

Copyright (c) OpenMMLab. All rights reserved.

import argparse import os

import mmcv import torch

from mmedit.apis import init_model, restoration_inference from mmedit.core import tensor2img from mmedit.utils import modify_args

def parse_args(): modify_args() parser = argparse.ArgumentParser(description='Restoration demo') parser.add_argument('--config', default ='', help='test config file path') parser.add_argument('--checkpoint', default ='', help='checkpoint file') parser.add_argument('--img_path', default ='', help='path to input image file') parser.add_argument('--save_path', default ='', help='path to save restoration result') parser.add_argument( '--imshow', action='store_true', help='whether show image with opencv') parser.add_argument('--device', type=int, default=0, help='CUDA device id') parser.add_argument( '--ref-path', default=None, help='path to reference image file') args = parser.parse_args() return args

def main(): args = parse_args() args.config = 'configs/restorers/edvr/edvrl_wotsa_c128b40_8x8_lr2e-4_600k_reds4.py' args.checkpoint = 'models/edvr/edvrl_wotsa_c128b40_8x8_lr2e-4_600k_reds4_20211228-d895a769.pth' args.img_path = 'resize.png' args.save_path = 'res/high-resolution.png'

if not os.path.isfile(args.img_path):
    raise ValueError('It seems that you did not input a valid '
                     '"image_path". Please double check your input, or '
                     'you may want to use "restoration_video_demo.py" '
                     'for video restoration.')
if args.ref_path and not os.path.isfile(args.ref_path):
    raise ValueError('It seems that you did not input a valid '
                     '"ref_path". Please double check your input, or '
                     'you may want to use "ref_path=None" '
                     'for single restoration.')

if args.device < 0 or not torch.cuda.is_available():
    device = torch.device('cpu')
else:
    device = torch.device('cuda', args.device)

model = init_model(args.config, args.checkpoint, device=device)

if args.ref_path:  # Ref-SR
    output = restoration_inference(model, args.img_path, args.ref_path)
else:  # SISR
    output = restoration_inference(model, args.img_path)
output = tensor2img(output)

mmcv.imwrite(output, args.save_path)
if args.imshow:
    mmcv.imshow(output, 'predicted restoration result')

if name == 'main': main()

Reproduces the problem - command or script

python3 restoration_demo.py

Reproduces the problem - error message

root@yhai:/home/mmediting-master# python3 restoration_demo.py /usr/local/lib/python3.6/dist-packages/mmcv/init.py:21: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove compon ents 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-f ull to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details. 'On January 1, 2023, MMCV will release v2.0.0, in which it will remove ' load checkpoint from local path: models/edvr/edvrl_wotsa_c128b40_8x8_lr2e-4_600k_reds4_20211228-d895a769.pth Traceback (most recent call last): File "restoration_demo.py", line 66, in main() File "restoration_demo.py", line 57, in main output = restoration_inference(model, args.img_path) File "/home/mmediting-master/mmedit/apis/restoration_inference.py", line 40, in restoration_inference data = test_pipeline(data) File "/home/mmediting-master/mmedit/datasets/pipelines/compose.py", line 42, in call data = t(data) File "/home/mmediting-master/mmedit/datasets/pipelines/augmentation.py", line 895, in call clip_name, frame_name = results['key'].split(os.sep) KeyError: 'key'

Additional information

No response

Z-Fran commented 1 year ago

Please run:

python mmagic_inference_demo.py \
        --model-name edvr \
        --extra-parameters window_size=5 \
        --video ../resources/input/video_restoration/QUuC4vJs_000084_000094_400x320.mp4 \
        --result-out-dir ../resources/output/video_restoration/demo_video_restoration_edvr_res.mp4
Z-Fran commented 1 year ago

Closing due to inactivity, please reopen if there are any further problems.