未验证 提交 be30224c 编写于 作者: Q qingqing01 提交者: GitHub

Refine some docs (#65)

* Refine some docs
* Update docs/en_US/data_prepare.md
上级 ac4b41ea
...@@ -34,24 +34,49 @@ PaddleGAN 是一个基于飞桨的生成对抗网络开发工具包. ...@@ -34,24 +34,49 @@ PaddleGAN 是一个基于飞桨的生成对抗网络开发工具包.
请参考[安装文档](./docs/zh_CN/install.md)来进行PaddlePaddle和ppgan的安装 请参考[安装文档](./docs/zh_CN/install.md)来进行PaddlePaddle和ppgan的安装
## 数据准备 ## 快速开始
请参考[数据准备](./docs/zh_CN/data_prepare.md) 来准备对应的数据.
通过ppgan.app接口使用预训练模型:
## 快速开始 ```python
训练,预测,推理等请参考 [快速开始](./docs/zh_CN/get_started.md). from ppgan.apps import RealSRPredictor
sr = RealSRPredictor()
sr.run("docs/imgs/monarch.png")
```
更多训练、评估教程参考:
- [数据准备](./docs/zh_CN/data_prepare.md)
- [训练/评估/推理教程](./docs/zh_CN/get_started.md)
## 模型教程 ## 模型教程
* [Pixel2Pixel](./docs/zh_CN/tutorials/pix2pix_cyclegan.md) * [Pixel2Pixel](./docs/zh_CN/tutorials/pix2pix_cyclegan.md)
* [CycleGAN](./docs/zh_CN/tutorials/pix2pix_cyclegan.md) * [CycleGAN](./docs/zh_CN/tutorials/pix2pix_cyclegan.md)
* [PSGAN](./docs/zh_CN/tutorials/psgan.md) * [PSGAN](./docs/zh_CN/tutorials/psgan.md)
* [First Order Motion Model](./docs/zh_CN/tutorials/motion_driving.md) * [First Order Motion Model](./docs/zh_CN/tutorials/motion_driving.md)
* [视频修复](./docs/zh_CN/tutorials/video_restore.md) * [视频修复](./docs/zh_CN/tutorials/video_restore.md)
## 许可证书 ## 在线体验
本项目的发布受[Apache 2.0 license](LICENSE)许可认证。
通过[AI Studio实训平台](https://aistudio.baidu.com/aistudio/index)在线体验:
|在线教程 | 链接 |
|--------------|-----------|
|老北京视频修复|[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/1161285)|
|表情动作迁移-当苏大强唱起unravel |[点击体验](https://aistudio.baidu.com/aistudio/projectdetail/1048840)|
## 版本更新
- v0.1.0 (2020.11.02)
- 初版发布,支持Pixel2Pixel、CycleGAN、PSGAN模型,支持视频插针、超分、老照片/视频上色、视频动作生成等应用。
- 模块化设计,接口简单易用。
## 贡献代码 ## 贡献代码
我们非常欢迎您可以为PaddleGAN提供任何贡献和建议。大多数贡献都需要同意参与者许可协议(CLA)。当提交拉取请求时,CLA机器人会自动检查您是否需要提供CLA。 只需要按照机器人提供的说明进行操作即可。CLA只需要同意一次,就能应用到所有的代码仓库上。关于更多的流程请参考[贡献指南](docs/zh_CN/contribute.md) 我们非常欢迎您可以为PaddleGAN提供任何贡献和建议。大多数贡献都需要同意参与者许可协议(CLA)。当提交拉取请求时,CLA机器人会自动检查您是否需要提供CLA。 只需要按照机器人提供的说明进行操作即可。CLA只需要同意一次,就能应用到所有的代码仓库上。关于更多的流程请参考[贡献指南](docs/zh_CN/contribute.md)
## 许可证书
本项目的发布受[Apache 2.0 license](LICENSE)许可认证。
...@@ -37,24 +37,41 @@ changes. ...@@ -37,24 +37,41 @@ changes.
Please refer to [install](./docs/en_US/install.md). Please refer to [install](./docs/en_US/install.md).
## Data Prepare ## Quick Start
Please refer to [data prepare](./docs/en_US/data_prepare.md) for dataset preparation.
## Get Start Get started through ppgan.app interface:
Please refer [get started](./docs/en_US/get_started.md) for the basic usage of PaddleGAN.
```python
from ppgan.apps import RealSRPredictor
sr = RealSRPredictor()
sr.run("docs/imgs/monarch.png")
```
More tutorials:
- [Data preparation](./docs/en_US/data_prepare.md)
- [Traning/Evaluating/Testing basic usage](./docs/zh_CN/get_started.md)
## Model Tutorial
## Model tutorial
* [Pixel2Pixel](./docs/en_US/tutorials/pix2pix_cyclegan.md) * [Pixel2Pixel](./docs/en_US/tutorials/pix2pix_cyclegan.md)
* [CycleGAN](./docs/en_US/tutorials/pix2pix_cyclegan.md) * [CycleGAN](./docs/en_US/tutorials/pix2pix_cyclegan.md)
* [PSGAN](./docs/en_US/tutorials/psgan.md) * [PSGAN](./docs/en_US/tutorials/psgan.md)
* [First Order Motion Model](./docs/en_US/tutorials/motion_driving.md) * [First Order Motion Model](./docs/en_US/tutorials/motion_driving.md)
* [Video restore](./docs/zh_CN/tutorials/video_restore.md) * [Video restore](./docs/zh_CN/tutorials/video_restore.md)
## License
PaddleGAN is released under the [Apache 2.0 license](LICENSE). ## Changelog
- v0.1.0 (2020.11.02)
- Realse first version, supported models include Pixel2Pixel, CycleGAN, PSGAN. Supported applications include video frame interpolation, super resolution, colorize images and videos, image animation.
- Modular design and friendly interface.
## Contributing ## Contributing
Contributions and suggestions are highly welcomed. Most contributions require you to agree to a [Contributor License Agreement (CLA)](https://cla-assistant.io/PaddlePaddle/PaddleGAN) declaring. Contributions and suggestions are highly welcomed. Most contributions require you to agree to a [Contributor License Agreement (CLA)](https://cla-assistant.io/PaddlePaddle/PaddleGAN) declaring.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA. Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA. Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
For more, please reference [contribution guidelines](docs/en_US/contribute.md). For more, please reference [contribution guidelines](docs/en_US/contribute.md).
## License
PaddleGAN is released under the [Apache 2.0 license](LICENSE).
## data prepare ## Data prepare
The config will suppose your data put in `$PaddleGAN/data`. You can symlink your datasets to `$PaddleGAN/data`. The config will suppose your data put in `$PaddleGAN/data`. You can symlink your datasets to `$PaddleGAN/data`.
...@@ -28,8 +28,7 @@ PaddleGAN ...@@ -28,8 +28,7 @@ PaddleGAN
``` ```
if you put your datasets on other place,for example ```your/data/path```, If you put your datasets on other place,for example ```your/data/path```, you can also change ```dataroot``` in config file:
you can also change ```dataroot``` in config file:
``` ```
dataset: dataset:
...@@ -41,12 +40,12 @@ dataset: ...@@ -41,12 +40,12 @@ dataset:
### Datasets of CycleGAN ### Datasets of CycleGAN
#### download existed datasets #### download form website
##### download form website Datasets for CycleGAN can be downloaded from [here](https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/)
datasets for CycleGAN you can download from [here](https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/)
#### download by script
##### download by script
You can use ```download_cyclegan_data.py``` in ```PaddleGAN/data``` to download datasets you wanted. Supported datasets are: apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes。 You can use ```download_cyclegan_data.py``` in ```PaddleGAN/data``` to download datasets you wanted. Supported datasets are: apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes。
run following command. Dataset will be downloaded to ```~/.cache/ppgan``` and symlink to ```PaddleGAN/data/``` . run following command. Dataset will be downloaded to ```~/.cache/ppgan``` and symlink to ```PaddleGAN/data/``` .
...@@ -55,7 +54,9 @@ python data/download_cyclegan_data.py --name horse2zebra ...@@ -55,7 +54,9 @@ python data/download_cyclegan_data.py --name horse2zebra
``` ```
#### custom dataset #### custom dataset
Data should be arranged in following way if you use custom dataset. Data should be arranged in following way if you use custom dataset.
``` ```
custom_datasets custom_datasets
├── testA ├── testA
...@@ -66,20 +67,21 @@ custom_datasets ...@@ -66,20 +67,21 @@ custom_datasets
### Datasets of Pix2Pix ### Datasets of Pix2Pix
#### download existed datasets #### Download from website
##### download from website Dataset for pix2pix can be downloaded from [here](https://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/)
dataset for pix2pix you can download from [here](hhttps://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/)
#### Download by script
##### download by script
You can use ```download_pix2pix_data.py``` in ```PaddleGAN/data``` to download datasets you wanted. Supported datasets are: apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes. You can use ```download_pix2pix_data.py``` in ```PaddleGAN/data``` to download datasets you wanted. Supported datasets are: apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes.
run following command. Dataset will be downloaded to ```~/.cache/ppgan``` and symlink to ```PaddleGAN/data/``` . Dataset will be downloaded to ```~/.cache/ppgan``` and symlink to ```PaddleGAN/data/``` .
``` ```
python data/download_pix2pix_data.py --name cityscapes python data/download_pix2pix_data.py --name cityscapes
``` ```
#### custom datasets #### Custom datasets
Data should be arranged in following way if you use custom dataset. And image content shoubld be same with example image. Data should be arranged in following way if you use custom dataset. And image content shoubld be same with example image.
``` ```
......
...@@ -25,11 +25,24 @@ Note: command above will install paddle with cuda10.2,if your installed cuda i ...@@ -25,11 +25,24 @@ Note: command above will install paddle with cuda10.2,if your installed cuda i
</code></pre> </details> </td> </tr></tbody></table> </code></pre> </details> </td> </tr></tbody></table>
### 2. Install ppgan ### 2. Install through pip
```
# only support Python3
python3 -m pip install --upgrade ppgan
```
Download the examples and configuration files via cloning the source code:
``` ```
git clone https://github.com/PaddlePaddle/PaddleGAN git clone https://github.com/PaddlePaddle/PaddleGAN
cd PaddleGAN cd PaddleGAN
```
### 3. Install through source code
```
git clone https://github.com/PaddlePaddle/PaddleGAN
cd PaddleGAN
pip install -v -e . # or "python setup.py develop" pip install -v -e . # or "python setup.py develop"
``` ```
...@@ -13,7 +13,10 @@ ...@@ -13,7 +13,10 @@
Users can upload the prepared source image and driving video, then substitute the path of source image and driving video for the `source_image` and `driving_video` parameter in the following running command. It will geneate a video file named `result.mp4` in the `output` folder, which is the animated video file. Users can upload the prepared source image and driving video, then substitute the path of source image and driving video for the `source_image` and `driving_video` parameter in the following running command. It will geneate a video file named `result.mp4` in the `output` folder, which is the animated video file.
``` ```
python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_image ./sudaqiang.png --relative --adapt_scale python -u tools/first-order-demo.py \
--driving_video ./ravel_10.mp4 \
--source_image ./sudaqiang.png \
--relative --adapt_scale
``` ```
**params:** **params:**
...@@ -29,6 +32,7 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im ...@@ -29,6 +32,7 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im
## Reference ## Reference
```
@InProceedings{Siarohin_2019_NeurIPS, @InProceedings{Siarohin_2019_NeurIPS,
author={Siarohin, Aliaksandr and Lathuilière, Stéphane and Tulyakov, Sergey and Ricci, Elisa and Sebe, Nicu}, author={Siarohin, Aliaksandr and Lathuilière, Stéphane and Tulyakov, Sergey and Ricci, Elisa and Sebe, Nicu},
title={First Order Motion Model for Image Animation}, title={First Order Motion Model for Image Animation},
...@@ -36,3 +40,4 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im ...@@ -36,3 +40,4 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im
month = {December}, month = {December},
year = {2019} year = {2019}
} }
```
...@@ -41,19 +41,21 @@ dataset: ...@@ -41,19 +41,21 @@ dataset:
### CycleGAN模型相关的数据集下载 ### CycleGAN模型相关的数据集下载
#### 已有的数据集下载 #### 从网页下载
##### 从网页下载
cyclgan模型相关的数据集可以在[这里](https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/)下载 cyclgan模型相关的数据集可以在[这里](https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/)下载
##### 使用脚本下载 #### 使用脚本下载
我们在 ```PaddleGAN/data``` 文件夹下提供了一个脚本 ```download_cyclegan_data.py``` 方便下载CycleGAN相关的 我们在 ```PaddleGAN/data``` 文件夹下提供了一个脚本 ```download_cyclegan_data.py``` 方便下载CycleGAN相关的
数据集。执行如下命令可以下载相关的数据集,目前支持的数据集名称有:apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes。 数据集。执行如下命令可以下载相关的数据集,目前支持的数据集名称有:apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes。
执行如下命令,可以下载对应的数据集到 ```~/.cache/ppgan``` 并软连接到 ```PaddleGAN/data/``` 下。 执行如下命令,可以下载对应的数据集到 ```~/.cache/ppgan``` 并软连接到 ```PaddleGAN/data/``` 下。
``` ```
python data/download_cyclegan_data.py --name horse2zebra python data/download_cyclegan_data.py --name horse2zebra
``` ```
#### 使用自己的数据集 #### 使用自己的数据集
如果你使用自己的数据集,需要构造成如下目录的格式。注意 ```xxxA``````xxxB```文件数量,文件内容无需一一对应。 如果你使用自己的数据集,需要构造成如下目录的格式。注意 ```xxxA``````xxxB```文件数量,文件内容无需一一对应。
``` ```
...@@ -66,20 +68,22 @@ custom_datasets ...@@ -66,20 +68,22 @@ custom_datasets
### Pix2Pix相关的数据集下载 ### Pix2Pix相关的数据集下载
#### 已有的数据集下载 #### 从网页下载
##### 从网页下载
pixel2pixel模型相关的数据集可以在[这里](hhttps://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/)下载 pixel2pixel模型相关的数据集可以在[这里](hhttps://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/)下载
##### 使用脚本下载 #### 使用脚本下载
我们在 ```PaddleGAN/data``` 文件夹下提供了一个脚本 ```download_pix2pix_data.py``` 方便下载pix2pix模型相关的数据集。执行如下命令可以下载相关的数据集,目前支持的数据集名称有:apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes。 我们在 ```PaddleGAN/data``` 文件夹下提供了一个脚本 ```download_pix2pix_data.py``` 方便下载pix2pix模型相关的数据集。执行如下命令可以下载相关的数据集,目前支持的数据集名称有:apple2orange, summer2winter_yosemite,horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photos, cityscapes。
执行如下命令,可以下载对应的数据集到 ```~/.cache/ppgan``` 并软连接到 ```PaddleGAN/data/``` 下。 执行如下命令,可以下载对应的数据集到 ```~/.cache/ppgan``` 并软连接到 ```PaddleGAN/data/``` 下。
``` ```
python data/download_pix2pix_data.py --name cityscapes python data/download_pix2pix_data.py --name cityscapes
``` ```
#### 使用自己的数据集 #### 使用自己的数据集
如果你使用自己的数据集,需要构造成如下目录的格式。同时图片应该制作成下图的样式,即左边为一种风格,另一边为相应转换的风格。 如果你使用自己的数据集,需要构造成如下目录的格式。同时图片应该制作成下图的样式,即左边为一种风格,另一边为相应转换的风格。
``` ```
......
...@@ -23,8 +23,21 @@ pip install -U paddlepaddle-gpu==2.0.0rc0 ...@@ -23,8 +23,21 @@ pip install -U paddlepaddle-gpu==2.0.0rc0
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install https://paddle-wheel.bj.bcebos.com/2.0.0-rc0-gpu-cuda9-cudnn7-mkl%2Fpaddlepaddle_gpu-2.0.0rc0.post90-cp36-cp36m-linux_x86_64.whl </code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install https://paddle-wheel.bj.bcebos.com/2.0.0-rc0-gpu-cuda9-cudnn7-mkl%2Fpaddlepaddle_gpu-2.0.0rc0.post90-cp36-cp36m-linux_x86_64.whl
</code></pre> </details> </td> </tr></tbody></table> </code></pre> </details> </td> </tr></tbody></table>
### 2. 通过Pip安装
### 2. 安装ppgan ```
# only support Python3
python3 -m pip install --upgrade ppgan
```
下载示例和配置文件:
```
git clone https://github.com/PaddlePaddle/PaddleGAN
cd PaddleGAN
```
### 3. 通过源码安装PaddleGAN
``` ```
git clone https://github.com/PaddlePaddle/PaddleGAN git clone https://github.com/PaddlePaddle/PaddleGAN
......
...@@ -17,7 +17,10 @@ First order motion model的任务是image animation,给定一张源图片, ...@@ -17,7 +17,10 @@ First order motion model的任务是image animation,给定一张源图片,
用户可以上传自己准备的视频和图片,并在如下命令中的source_image参数和driving_video参数分别换成自己的图片和视频路径,然后运行如下命令,就可以完成动作表情迁移,程序运行成功后,会在ouput文件夹生成名为result.mp4的视频文件,该文件即为动作迁移后的视频。本项目中提供了原始图片和驱动视频供展示使用。运行的命令如下所示: 用户可以上传自己准备的视频和图片,并在如下命令中的source_image参数和driving_video参数分别换成自己的图片和视频路径,然后运行如下命令,就可以完成动作表情迁移,程序运行成功后,会在ouput文件夹生成名为result.mp4的视频文件,该文件即为动作迁移后的视频。本项目中提供了原始图片和驱动视频供展示使用。运行的命令如下所示:
``` ```
python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_image ./sudaqiang.png --relative --adapt_scale python -u tools/first-order-demo.py \
--driving_video ./ravel_10.mp4 \
--source_image ./sudaqiang.png \
--relative --adapt_scale
``` ```
**参数说明:** **参数说明:**
...@@ -34,6 +37,7 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im ...@@ -34,6 +37,7 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im
## 参考文献 ## 参考文献
```
@InProceedings{Siarohin_2019_NeurIPS, @InProceedings{Siarohin_2019_NeurIPS,
author={Siarohin, Aliaksandr and Lathuilière, Stéphane and Tulyakov, Sergey and Ricci, Elisa and Sebe, Nicu}, author={Siarohin, Aliaksandr and Lathuilière, Stéphane and Tulyakov, Sergey and Ricci, Elisa and Sebe, Nicu},
title={First Order Motion Model for Image Animation}, title={First Order Motion Model for Image Animation},
...@@ -41,3 +45,5 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im ...@@ -41,3 +45,5 @@ python -u tools/first-order-demo.py --driving_video ./ravel_10.mp4 --source_im
month = {December}, month = {December},
year = {2019} year = {2019}
} }
```
...@@ -17,6 +17,10 @@ import numpy as np ...@@ -17,6 +17,10 @@ import numpy as np
import paddle import paddle
from ..utils.logger import get_logger
logger = get_logger('init')
def _calculate_fan_in_and_fan_out(tensor): def _calculate_fan_in_and_fan_out(tensor):
dimensions = len(tensor.shape) dimensions = len(tensor.shape)
...@@ -65,7 +69,6 @@ def calculate_gain(nonlinearity, param=None): ...@@ -65,7 +69,6 @@ def calculate_gain(nonlinearity, param=None):
Args: Args:
nonlinearity: the non-linear function (`nn.functional` name) nonlinearity: the non-linear function (`nn.functional` name)
param: optional parameter for the non-linear function param: optional parameter for the non-linear function
""" """
linear_fns = [ linear_fns = [
'linear', 'conv1d', 'conv2d', 'conv3d', 'conv_transpose1d', 'linear', 'conv1d', 'conv2d', 'conv3d', 'conv_transpose1d',
...@@ -310,5 +313,5 @@ def init_weights(net, init_type='normal', init_gain=0.02): ...@@ -310,5 +313,5 @@ def init_weights(net, init_type='normal', init_gain=0.02):
normal_(m.weight, 1.0, init_gain) normal_(m.weight, 1.0, init_gain)
constant_(m.bias, 0.0) constant_(m.bias, 0.0)
print('initialize network with %s' % init_type) logger.debug('initialize network with %s' % init_type)
net.apply(init_func) # apply the initialization function <init_func> net.apply(init_func) # apply the initialization function <init_func>
...@@ -35,7 +35,7 @@ def setup_logger(output=None, name="ppgan"): ...@@ -35,7 +35,7 @@ def setup_logger(output=None, name="ppgan"):
logging.Logger: a logger logging.Logger: a logger
""" """
logger = logging.getLogger(name) logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG) logger.setLevel(logging.INFO)
logger.propagate = False logger.propagate = False
plain_formatter = logging.Formatter( plain_formatter = logging.Formatter(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册