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

[Enhance] support image restoration inferencer #1873

Merged
merged 6 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Table of contents:

      [2.2.9. Text-to-Image example](#229-text-to-image)

      [2.2.10. 3D-aware Generation example](#2210-3d-aware-generation)

      [2.2.11. Image Restoration example](#2211-image-restoration)

[3. Other demos](#3-other-demos)

## 1. Download sample images or videos
Expand Down Expand Up @@ -214,10 +218,19 @@ python mmagic_inference_demo.py \
--result-out-dir ../resources/output/text2image/demo_text2image_stable_diffusion_res.png
```

#### 2.2.9 3D-aware Generation (EG3D)
#### 2.2.10 3D-aware Generation

```shell
python demo/mmagic_inference_demo.py \
--model-name eg3d \
--result-out-dir ../resources/output/eg3d-output
```

#### 2.2.11 Image Restoration

```shell
python mmagic_inference_demo.py \
--model-name nafnet \
--img ../resources/input/restoration/0901x2.png \
--result-out-dir ../resources/output/restoration/demo_restoration_nafnet_res.png
```
7 changes: 7 additions & 0 deletions mmagic/apis/inferencers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def __init__(self,
config, ckpt, device, extra_parameters, seed=seed)
elif self.task in ['controlnet_animation']:
self.inferencer = ControlnetAnimationInferencer(config)
elif self.task in [
'Image Restoration', 'Denoising, Deblurring, Deraining',
'Image Super-Resolution, Image denoising, JPEG compression '
'artifact reduction'
]:
self.inferencer = ImageSuperResolutionInferencer(
config, ckpt, device, extra_parameters, seed=seed)
else:
raise ValueError(f'Unknown inferencer task: {self.task}')

Expand Down
5 changes: 5 additions & 0 deletions mmagic/apis/mmagic_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ class MMagicInferencer:
'basicvsr_pp',
'real_basicvsr',

# image_restoration models
'nafnet',
'swinir',
'restormer',

# text2image models
'disco_diffusion',
'stable_diffusion',
Expand Down
1 change: 1 addition & 0 deletions requirements/runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ face-alignment
facexlib
lmdb
lpips
mediapipe
mmcv>=2.0.0rc1
mmengine
numpy
Expand Down