Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
Real-ESRGAN_pytorch
Commits
b0878a53
Commit
b0878a53
authored
Mar 06, 2024
by
Rayyyyy
Browse files
add ada20k process
parent
3799d625
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
86 additions
and
29 deletions
+86
-29
README.md
README.md
+27
-25
docker/Dockerfile
docker/Dockerfile
+0
-2
evalution.py
evalution.py
+23
-0
gen_ada20k_val.py
gen_ada20k_val.py
+33
-0
model.properties
model.properties
+2
-2
tiny_datasets/ADE20K_val/ADE_val_00000001.jpg
tiny_datasets/ADE20K_val/ADE_val_00000001.jpg
+0
-0
tiny_datasets/ADE20K_val/ADE_val_00000002.jpg
tiny_datasets/ADE20K_val/ADE_val_00000002.jpg
+0
-0
tiny_datasets/ADE20K_val/ADE_val_00000003.jpg
tiny_datasets/ADE20K_val/ADE_val_00000003.jpg
+0
-0
tiny_datasets/ADE20K_val/ADE_val_00000004.jpg
tiny_datasets/ADE20K_val/ADE_val_00000004.jpg
+0
-0
tiny_datasets/ADE20K_val/ADE_val_00000005.jpg
tiny_datasets/ADE20K_val/ADE_val_00000005.jpg
+0
-0
tiny_datasets/ADE20K_val/ADE_val_00000006.jpg
tiny_datasets/ADE20K_val/ADE_val_00000006.jpg
+0
-0
tiny_datasets/ADE20K_val/ADE_val_00000007.jpg
tiny_datasets/ADE20K_val/ADE_val_00000007.jpg
+0
-0
val.sh
val.sh
+1
-0
No files found.
README.md
View file @
b0878a53
...
...
@@ -28,14 +28,9 @@
```
bash
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py38-latest
docker run
-it
-v
/path/your_code_data/:/path/
your_code_data/
--shm-size
=
32G
--privileged
=
true
--device
=
/dev/kfd
--device
=
/dev/dri/
--group-add
video
--name
docker_name imageID bash
docker run
-it
-v
/path/your_code_data/:/path/your_code_data/
--shm-size
=
32G
--privileged
=
true
--device
=
/dev/kfd
--device
=
/dev/dri/
--group-add
video
--name
docker_name imageID bash
cd
/your_code_path/real-esrgan_pytorch
# 推理和训练都用到了basicsr库
pip
install
basicsr
# facexlib 和 gfpgan 用于面部增强
pip
install
facexlib
pip
install
gfpgan
pip
install
-r
requirements.txt
python setup.py develop
```
...
...
@@ -44,17 +39,11 @@ python setup.py develop
```
bash
cd
./docker
cp
../requirements.txt requirements.txt
docker build
--no-cache
-t
real_esrgan:latest
.
docker run
-it
-v
/path/your_code_data/:/path/your_code_data/
--shm-size
=
32G
--privileged
=
true
--device
=
/dev/kfd
--device
=
/dev/dri/
--group-add
video
--name
docker_name imageID bash
cd
/your_code_path/real-esrgan_pytorch
# 推理和训练都用到了basicsr库
pip
install
basicsr
# facexlib 和 gfpgan 用于面部增强
pip
install
facexlib
pip
install
gfpgan
pip
install
-r
requirements.txt
python setup.py develop
```
...
...
@@ -75,11 +64,6 @@ Tips:以上dtk软件栈、python、torch等DCU相关工具版本需要严格
2、其他非特殊库直接按照下面步骤进行安装
```
bash
# 推理和训练都用到了basicsr库
pip
install
basicsr
# facexlib 和 gfpgan 用于面部增强
pip
install
facexlib
pip
install
gfpgan
pip
install
-r
requirements.txt
python setup.py develop
```
...
...
@@ -95,8 +79,15 @@ python setup.py develop
[
OST
](
https://openmmlab.oss-cn-hangzhou.aliyuncs.com/datasets/OST_dataset.zip
)
[
ADE20K
](
https://groups.csail.mit.edu/vision/datasets/ADE20K/
)
ADE20K数据需要预处理:
```
bash
python gen_20k_val.py
--root_path
/path/of/ADE20K_2021_17_01
--save_path
datasets/ADE20K_val
```
数
据集的目录结构如下:
据集的目录结构如下:
```
bash
├── datasets
...
...
@@ -108,7 +99,11 @@ python setup.py develop
│ └── meta_info
# 生成的
│ ├── OST
│ ├── train_HR
# 将OST的HR图像放于这里
│ ├── train_HR_sub
# 生成的
│ ├── train_HR_sub
│ ├── ADE20K_2021_17_01
│ ├── images
│ ├── objects.txt
│ ├── ADE20K_val
# 生成的
```
Tips: 项目提供了tiny_datasets进行快速上手测试, 如需使用tiny_datasets, 下面的数据路径需进行对应修改。
...
...
@@ -314,25 +309,32 @@ python inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhance
```
## result
Model: RealESRGAN_x4plus
<div
align=
center
>
<img
src=
"./doc/00017_gray.jpg"
/>
<img
src=
"./doc/00017_gray_out.jpg"
/>
</div>
### 精度
本项目基于ADE20K公开数据集的val数据进行定性效果验证,首先需要对ADE20K val数据进行处理,得到处理后的结果图像(默认在results下).
```
bash
# 执行推理
python inference_realesrgan.py
--model_path
weights/RealESRGAN_x4plus.pth
-n
RealESRGAN_x4plus
-i
dataset/ADE20K_val
--face_enhance
python evalution.py
--root_path
results
```
| NIQE | ADE20K val |
OST300 |
| :------: | :------: |
:------: |
|
our | xxx | xxx
|
|
paper
| 3.7886 |
2.8659 |
| NIQE | ADE20K val |
| :------: | :------: |
|
V100S |
|
|
Z100L
| 3.7886 |
## 应用场景
### 算法类别
图像超分
### 热点应用行业
交通,政府,
工业
交通,政府,
制造
## 源码仓库及问题反馈
https://developer.hpccube.com/codes/modelzoo/real-esrgan_pytorch
...
...
docker/Dockerfile
View file @
b0878a53
FROM
image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py38-latest
RUN
source
/opt/dtk/env.sh
COPY
requirements.txt requirements.txt
RUN
pip3
install
-r
requirements.txt
evalution.py
0 → 100644
View file @
b0878a53
import
os
import
cv2
import
warnings
import
argparse
from
basicsr.metrics
import
calculate_niqe
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--root_path'
,
type
=
str
,
default
=
'results'
)
args
=
parser
.
parse_args
()
def
main
():
for
imgname
in
os
.
listdir
(
args
.
root_path
):
img_path
=
os
.
path
.
join
(
args
.
root_path
,
imgname
)
# img_path = 'tests/data/baboon.png'
img
=
cv2
.
imread
(
img_path
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
category
=
RuntimeWarning
)
niqe_result
=
calculate_niqe
(
img
,
0
,
input_order
=
'HWC'
,
convert_to
=
'y'
)
print
(
niqe_result
)
if
__name__
==
'__main__'
:
main
()
gen_ada20k_val.py
0 → 100644
View file @
b0878a53
import
os
import
shutil
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--root_path'
,
type
=
str
,
default
=
'datasets/ADE20K_2021_17_01'
)
parser
.
add_argument
(
'--save_path'
,
type
=
str
,
default
=
'datasets/ADE20K_val'
)
args
=
parser
.
parse_args
()
if
__name__
==
"__main__"
:
val_img_path
=
os
.
path
.
join
(
args
.
root_path
,
'images/ADE/validation'
)
filenames
=
os
.
listdir
(
val_img_path
)
os
.
makedirs
(
args
.
save_path
,
exist_ok
=
True
)
for
filename
in
filenames
:
file_path
=
os
.
path
.
join
(
val_img_path
,
filename
)
if
not
os
.
path
.
isdir
(
file_path
):
continue
child_files
=
os
.
listdir
(
file_path
)
for
cfile
in
child_files
:
cfile_path
=
os
.
path
.
join
(
file_path
,
cfile
)
if
not
os
.
path
.
isdir
(
cfile_path
):
continue
imgnames
=
os
.
listdir
(
cfile_path
)
for
img_name
in
imgnames
:
if
not
img_name
.
endswith
(
'.jpg'
):
continue
source_path
=
os
.
path
.
join
(
cfile_path
,
img_name
)
target_path
=
os
.
path
.
join
(
args
.
save_path
,
img_name
)
print
(
"move {} to {}"
.
format
(
source_path
,
target_path
))
shutil
.
move
(
source_path
,
target_path
)
print
(
'### process end'
)
model.properties
View file @
b0878a53
...
...
@@ -3,8 +3,8 @@ modelCode=530
# 模型名称
modelName
=
real-esrgan_pytorch
# 模型描述
modelDescription
=
通过使用更实用的退化过程合成训练对, 扩展强大的ESRGAN以恢复一般的真实世界LR图像。
modelDescription
=
通过使用更实用的退化过程合成训练
图像
对, 扩展强大的ESRGAN以恢复一般的真实世界LR图像。
# 应用场景
appScenario
=
推理,训练,图像超分,交通,政府,
工业
appScenario
=
推理,训练,图像超分,交通,政府,
制造
# 框架类型
frameType
=
PyTorch
tiny_datasets/ADE20K_val/ADE_val_00000001.jpg
0 → 100644
View file @
b0878a53
201 KB
tiny_datasets/ADE20K_val/ADE_val_00000002.jpg
0 → 100644
View file @
b0878a53
33.2 KB
tiny_datasets/ADE20K_val/ADE_val_00000003.jpg
0 → 100644
View file @
b0878a53
18.3 KB
tiny_datasets/ADE20K_val/ADE_val_00000004.jpg
0 → 100644
View file @
b0878a53
99.3 KB
tiny_datasets/ADE20K_val/ADE_val_00000005.jpg
0 → 100644
View file @
b0878a53
20.5 KB
tiny_datasets/ADE20K_val/ADE_val_00000006.jpg
0 → 100644
View file @
b0878a53
139 KB
tiny_datasets/ADE20K_val/ADE_val_00000007.jpg
0 → 100644
View file @
b0878a53
33.7 KB
val.sh
View file @
b0878a53
#!/bin/bash
export
HIP_VISIBLE_DEVICES
=
0
python inference_realesrgan.py
-n
RealESRGAN_x4plus
-i
inputs
--face_enhance
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment