README.md 4.33 KB
Newer Older
yongshk's avatar
yongshk committed
1
2
3
4
5
6
7
8
# PIX2PIXHD

## 论文

` High-Resolution Image Synthesis and Semantic `

- https://arxiv.org/pdf/1711.11585.pdf

yongshk's avatar
更新  
yongshk committed
9
10
## 模型结构
模型整体的结构是conditional GAN。 模型与Pix2pix相比更换了coarse-to-fine的生成器、multi-scale的判别器。
yongshk's avatar
yongshk committed
11

yongshk's avatar
yongshk committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
![](D:\git上传前\pix2pixhd_pytorch\doc\Pix2PixHD-GAN-model-for-paired-image-to-image-translation.png)

## 算法原理

 pix2pixHD的算法原理是基于条件生成对抗网络(Conditional Generative Adversarial Nets)。它是一个由两个部分组成的网络:生成器和判别器。生成器用于从训练数据中合成图像,而判别器则负责判断生成的图像是否真实。 

![](D:\git上传前\pix2pixhd_pytorch\doc\pix2pixHD原理.png)

## 环境配置

### Docker(方法一)

此处提供[光源](https://www.sourcefind.cn/#/service-details)拉取docker镜像

```
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.10.0-centos7.6-dtk-22.10-py37-latest
docker run -it --network=host --name=bert_prof --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=32G  --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.10.0-centos7.6-dtk-22.10-py37-latest
```

### Dockerfile(方法二)

dockerfile使用方法

```
docker build --no-cache -t pix2pixhd:latest .
docker run -dit --network=host --name=pix2pixhd --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G  --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 pix2pixhd:latest
docker exec -it pix2pixhd /bin/bash
pip install -r requirements.txt
```

### Anaconda(方法三)

关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.hpccube.com/tool/)开发者社区下载安装。

```
DTK驱动:dtk22.10
python:python3.7
apex==0.1+gitdb7007a.dtk2210
torch==1.10.0a0+git2040069.dtk2210
```

`Tips:以上dtk驱动、python等DCU相关工具版本需要严格一一对应`

其它非深度学习库参照requirements.txt安装:

```
pip install -r requirements.txt
```

yongshk's avatar
更新  
yongshk committed
61
## 数据集
yongshk's avatar
yongshk committed
62

yongshk's avatar
yongshk committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
`模型使用数据为cityscapes`

- <https://www.cityscapes-dataset.com/>

项目中已提供用于试验训练的迷你数据集,训练数据目录结构如下,用于正常训练的完整数据集请按此目录结构进行制备:

```
 ── dataset
 ────── cityscapes
       │   ├── train_label
       │             ├── xxx.png
       │             ├── xxx.png
       │             └── ...
       │   └── train_inst
       │             ├── xxx.png
       │             ├── xxx.png
       │             └── ...
       │   └── train_img
       │             ├── xxx.png
       │             ├── xxx.png
       │             └── ...
       │   └── test_label
       │             ├── xxx.png
       │             ├── xxx.png
       │             └── ...
       │   └── test_inst
       │             ├── xxx.png
       │             ├── xxx.png
       │             └── ...
```
yongshk's avatar
yongshk committed
93
94
95
96




yongshk's avatar
yongshk committed
97
98
99
100
## 训练
### 单机单卡

以 1024 x 512 分辨率训练模型
yongshk's avatar
yongshk committed
101
102
103
104
105
106

```
#!./scripts/train_512p.sh
python train.py --name label2city_512p
```

yongshk's avatar
yongshk committed
107
### 单机多卡
yongshk's avatar
yongshk committed
108

yongshk's avatar
yongshk committed
109
110
111
112
```
#!./scripts/train_512p.sh
python train.py --name label2city_512p --batchSize 4 --gpu_ids 0,1,2,3
```
yongshk's avatar
更新  
yongshk committed
113

yongshk's avatar
yongshk committed
114
## 推理
yongshk's avatar
更新  
yongshk committed
115

yongshk's avatar
yongshk committed
116
    python test.py --name label2city_512p \
yongshk's avatar
更新  
yongshk committed
117
118
119
                   --netG local \
                   --ngf 32 \
                   --resize_or_crop none \
yongshk's avatar
yongshk committed
120

yongshk's avatar
yongshk committed
121
122
123
124
125
126
127
128
129
130
131
## result

测试图

![](D:\git上传前\pix2pixhd_pytorch\doc\face1_1.jpg)

### 精度

测试数据:<https://www.cityscapes-dataset.com/>,使用的加速卡:Z100L。

根据测试结果情况填写表格:
yongshk's avatar
yongshk committed
132

yongshk's avatar
yongshk committed
133
134
135
136
137
138
139
140
141
142
143
144
145
| pix2pixHD  | G_GAN | G_GAN_Feat | G_VGG | D_fake | D_real |
| :--------: | :---: | ---------- | ----- | ------ | :----: |
| cityscapes | 0.540 | 6.153      | 3.087 | 0.534  | 0.424  |

## 应用场景

### 算法类别

`图像超分`

### 热点应用行业

`设计`
yongshk's avatar
yongshk committed
146

yongshk's avatar
更新  
yongshk committed
147
## 源码仓库及问题反馈
yongshk's avatar
yongshk committed
148

yongshk's avatar
更新  
yongshk committed
149
* [https://github.com/NVIDIA/pix2pixHD](https://github.com/NVIDIA/pix2pixHD)
yongshk's avatar
yongshk committed
150
## 参考资料
yongshk's avatar
更新  
yongshk committed
151
* [https://github.com/NVIDIA/pix2pixHD](https://github.com/NVIDIA/pix2pixHD)
yongshk's avatar
yongshk committed
152