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
pix2pixHD_pytorch
Commits
811e7409
Commit
811e7409
authored
Nov 17, 2023
by
yongshk
Browse files
Initial commit
parent
5aec721a
Pipeline
#632
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
92 deletions
+52
-92
README.md
README.md
+52
-92
No files found.
README.md
View file @
811e7409
# PIX2PIXHD
# UNET
## 论文
`U-Net: Convolutional Networks for Biomedical Image Segmentation`
` High-Resolution Image Synthesis and Semantic `
-
https://arxiv.org/pdf/1711.11585.pdf
-
https://arxiv.org/abs/1505.04597
## 模型结构
模型整体的结构是conditional GAN。 模型与Pix2pix相比更换了coarse-to-fine的生成器、multi-scale的判别器。

UNet(全名 U-Net)是一种用于图像分割的卷积神经网络(CNN)架构,UNet 的结构具有 U 形状,因此得名。

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

1.
**编码器(Cont
ra
c
ti
ng Path)**
:U-Net 的编码器由卷积层和池化层组成,用于捕捉图像的特征信息并逐渐减小分辨率。这一部分的任务是将输入图像缩小到一个低分辨率的特征图,同时保留有关图像内容的关键特征。
2.
**中间层(Bottleneck)**
:在编码器和解码器之间,U-Net 包括一个中间层,通常由卷积层组成,用于进一步提取特征信息。
3.
**解码器(Expansive Path)**
:U-Net 的解码器包括上采样层和卷积层,用于将特征图恢复到原始输入图像的分辨率。解码器的任务是将高级特征与低级特征相结合,以便生成分割结果。这一部分的结构与编码器相对称。

## 环境配置
### 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
此处提供
[
光源
](
https://www.sourcefind.cn/#/service-details
)
拉取docker镜像的地址与使用步骤
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.10.0-centos7.6-dtk-23.04-py37-latest
docker run -it --network=host --name=unet --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-23.04-py37-latest
```
### Dockerfile(方法二)
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
docker build --no-cache -t
unet
:latest .
docker run -dit --network=host --name=
unet
--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
unet
:latest
docker exec -it
unet
/bin/bash
pip install -r requirements.txt
```
### Anaconda(方法三)
关于本项目DCU显卡所需的特殊深度学习库可从
[
光合
](
https://developer.hpccube.com/tool/
)
开发者社区下载安装。
此处提供本地配置、编译的详细步骤,例如:
关于本项目DCU显卡所需的特殊深度学习库可从
[
光合
](
https://developer.hpccube.com/tool/
)
开发者社区下载安装。
```
DTK驱动:dtk2
2.10
DTK驱动:dtk2
3.04
python:python3.7
apex==0.1+gitdb7007a.dtk2210
torch==1.10.0a0+git2040069.dtk2210
apex==0.1+f49ddd4.abi0.dtk2304.torch1.13
torch==1.13.1+git55d300e.abi0.dtk2304
torchvision==0.14.1+git9134838.abi0.dtk2304.torch1.13
```
`Tips:以上dtk驱动、python等DCU相关工具版本需要严格一一对应`
其它非深度学习库参照requirements.txt安装:
```
pip install -r requirements.txt
```
## 数据集
`Carvana`
`模型使用数据为cityscapes`
-
<https://www.cityscapes-dataset.com/>
-
https://www.kaggle.com/c/carvana-image-masking-challenge/data
此处提供数据预处理脚本的使用方法
```
bash scripts/download_data.sh
```
项目中已提供用于试验训练的迷你数据集,训练数据目录结构如下,用于正常训练的完整数据集请按此目录结构进行制备:
```
── 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
│ └── ...
── data
│ ├── imgs
│ ├──────fff9b3a5373f_15.jpg
│ ├──────fff9b3a5373f_16.jpg
│ └── masks
│ ├────── fff9b3a5373f_15.gif
│ ├────── fff9b3a5373f_16.gif
```
## 训练
### 单机单卡
以 1024 x 512 分辨率训练模型
```
#!./scripts/train_512p.sh
python train.py
--name
label2city_512p
python train.py
```
### 单机多卡
```
#!./scripts/train_512p.sh
python train.py
--name
label2city_512p
--batchSize
4
--gpu_ids
0,1,2,3
python -m torch.distributed.launch --nproc_per_node 4 train_ddp.py
```
## 推理
python test.py --name label2city_512p \
--netG local \
--ngf 32 \
--resize_or_crop none \
[
模型下载路径
](
https://github.com/milesial/Pytorch-UNet/releases/tag/v3.0
)
```
python predict.py -m model_path -i image.jpg -o output.jpg
```
## result
测试图


### 精度
测试数据:
<https://www.cityscapes-dataset.com/>
,使用的加速卡:Z100L。
测试数据:
[
test data
](
https://www.kaggle.com/c/carvana-image-masking-challenge/data
)
,使用的加速卡:Z100L。(采用iou系数)
根据测试结果情况填写表格:
| pix2pixHD | G_GAN | G_GAN_Feat | G_VGG | D_fake | D_real |
| :--------: | :---: | ---------- | ----- | ------ | :----: |
| cityscapes | 0.540 | 6.153 | 3.087 | 0.534 | 0.424 |
| Unet | 精度 | 速度 |
| :------: | :------: | :------: |
| Carvana | 0.976 | 25.96 |
## 应用场景
### 算法类别
`图像
超
分`
`图像分
割
`
### 热点应用行业
`设计`
`医疗`
## 源码仓库及问题反馈
*
[
https://github.com/NVIDIA/pix2pixHD
](
https://github.com/NVIDIA/pix2pixHD
)
-
https://developer.hpccube.com/codes/modelzoo/unet-pytorch
## 参考资料
*
[
https://github.com/NVIDIA/pix2pixHD
](
https://github.com/NVIDIA/pix2pixHD
)
-
https://github.com/milesial/Pytorch-Unet
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