未验证 提交 5827d7df 编写于 作者: Y YixinKristy 提交者: GitHub

Replace gif and photos in README & Revise the docs of video restore (#322)

* revise video restore docs

* delete photos

* Update README.md

* Update install.md

* update readme

* Update README.md
上级 d84bfbbf
......@@ -71,62 +71,71 @@ You can run those projects in the [AI Studio](https://aistudio.baidu.com/aistudi
### Image Translation
<div align='center'>
<img src='./docs/imgs/horse2zebra.gif'width='700' height='200'/>
<img src='https://user-images.githubusercontent.com/48054808/119464966-d5c1c000-bd75-11eb-9696-9bb75357229f.gif'width='700' height='200'/>
</div>
### Old video restore
<div align='center'>
<img src='./docs/imgs/color_sr_peking.gif' width='700'/>
<img src='https://user-images.githubusercontent.com/48054808/119469496-fc81f580-bd79-11eb-865a-5e38482b1ae8.gif' width='700'/>
</div>
### Motion driving
<div align='center'>
<img src='./docs/imgs/first_order.gif' width='700'>
<img src='https://user-images.githubusercontent.com/48054808/119469551-0a377b00-bd7a-11eb-9117-e4871c8fb9c0.gif' width='700'>
</div>
### Super resolution
<div align='center'>
<img src='./docs/imgs/sr_demo.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119469753-3e12a080-bd7a-11eb-9cde-4fa01b3201ab.png'width='700' height='250'/>
</div>
### Makeup shifter
<div align='center'>
<img src='./docs/imgs/makeup_shifter.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119469834-4ff44380-bd7a-11eb-93b6-05b705dcfbf2.png'width='700' height='250'/>
</div>
### Face cartoonization
<div align='center'>
<img src='./docs/imgs/ugatit.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119469952-6bf7e500-bd7a-11eb-89ad-9a78b10bd4ab.png'width='700' height='250'/>
</div>
### Realistic face cartoonization
<div align='center'>
<img src='./docs/imgs/photo2cartoon.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119470028-7f0ab500-bd7a-11eb-88e9-78a6b9e2e319.png'width='700' height='250'/>
</div>
### Photo animation
<div align='center'>
<img src='./docs/imgs/animeganv2.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119470099-9184ee80-bd7a-11eb-8b12-c9400fe01266.png'width='700' height='250'/>
</div>
### Lip-syncing
<div align='center'>
<img src='./docs/imgs/mona.gif'width='700'>
<img src='https://user-images.githubusercontent.com/48054808/119470166-a6618200-bd7a-11eb-9f98-58052ce21b14.gif'width='700'>
</div>
## Changelog
- v0.1.0 (2020.11.02)
......
......@@ -86,7 +86,7 @@ GAN--生成对抗网络,被“卷积网络之父”**Yann LeCun(杨立昆)
## 复合应用
* [视频修复](./docs/zh_CN/tutorials/video_restore.md)
* [智能影像修复](./docs/zh_CN/industrial_solution/video_restore_cn.md)
## 在线教程
......@@ -105,64 +105,73 @@ GAN--生成对抗网络,被“卷积网络之父”**Yann LeCun(杨立昆)
### 图片变换
<div align='center'>
<img src='./docs/imgs/horse2zebra.gif'width='700' height='200'/>
<img src='https://user-images.githubusercontent.com/48054808/119464966-d5c1c000-bd75-11eb-9696-9bb75357229f.gif'width='700' height='200'/>
</div>
### 老视频修复
<div align='center'>
<img src='./docs/imgs/color_sr_peking.gif' width='700'/>
<img src='https://user-images.githubusercontent.com/48054808/119469496-fc81f580-bd79-11eb-865a-5e38482b1ae8.gif' width='700'/>
</div>
### 动作迁移
<div align='center'>
<img src='./docs/imgs/first_order.gif' width='700'/>
<img src='https://user-images.githubusercontent.com/48054808/119469551-0a377b00-bd7a-11eb-9117-e4871c8fb9c0.gif' width='700'/>
</div>
### 超分辨率
<div align='center'>
<img src='./docs/imgs/sr_demo.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119469753-3e12a080-bd7a-11eb-9cde-4fa01b3201ab.png'width='700' height='250'/>
</div>
### 妆容迁移
<div align='center'>
<img src='./docs/imgs/makeup_shifter.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119469834-4ff44380-bd7a-11eb-93b6-05b705dcfbf2.png'width='700' height='250'/>
</div>
### 人脸动漫化
<div align='center'>
<img src='./docs/imgs/ugatit.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119469952-6bf7e500-bd7a-11eb-89ad-9a78b10bd4ab.png'width='700' height='250'/>
</div>
### 写实人像卡通化
<div align='center'>
<img src='./docs/imgs/photo2cartoon.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119470028-7f0ab500-bd7a-11eb-88e9-78a6b9e2e319.png'width='700' height='250'/>
</div>
### 照片动漫化
<div align='center'>
<img src='./docs/imgs/animeganv2.png'width='700' height='250'/>
<img src='https://user-images.githubusercontent.com/48054808/119470099-9184ee80-bd7a-11eb-8b12-c9400fe01266.png'width='700' height='250'/>
</div>
### 唇形同步
<div align='center'>
<img src='./docs/imgs/mona.gif'width='700'>
<img src='https://user-images.githubusercontent.com/48054808/119470166-a6618200-bd7a-11eb-9f98-58052ce21b14.gif'width='700'>
</div>
## 版本更新
- v0.1.0 (2020.11.02)
......
因为 它太大了无法显示 image diff 。你可以改为 查看blob
因为 它太大了无法显示 image diff 。你可以改为 查看blob
# 图片上色
针对图片的上色,PaddleGAN提供了[DeOldify](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdeoldifypredictor)模型。
## DeOldifyPredictor
[DeOldify](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdeoldifypredictor)采用自注意力机制的生成对抗网络,生成器是一个U-NET结构的网络。在图像/视频的上色方面有着较好的效果。
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925538-fd526a80-b329-11eb-8924-8f2614fcd9e6.png'>
</div>
### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
- `artistic (bool)`: 是否使用偏"艺术性"的模型。"艺术性"的模型有可能产生一些有趣的颜色,但是毛刺比较多。
- `render_factor (int)`: 会将该参数乘以16后作为输入帧的resize的值,如果该值设置为32,
则输入帧会resize到(32 * 16, 32 * 16)的尺寸再输入到网络中。
### 使用方式
**1. API预测**
```
from ppgan.apps import DeOldifyPredictor
deoldify = DeOldifyPredictor()
deoldify.run("/home/aistudio/先烈.jpg") #原图片所在路径
```
*`run`接口为图片/视频通用接口,由于这里对象是图片,可以使用`run_image`的接口
[完整API接口使用说明]()
**2. 命令行预测**
```
!python applications/tools/video-enhance.py --input /home/aistudio/先烈.jpg \ #原图片路径
--process_order DeOldify \ #对原图片处理的顺序
--output output_dir #成品图片所在的路径
```
### 在线项目体验
**1. [老北京城影像修复](https://aistudio.baidu.com/aistudio/projectdetail/1161285)**
**2. [PaddleGAN ❤️ 520特辑](https://aistudio.baidu.com/aistudio/projectdetail/1956943?channelType=0&channel=0)**
# 图片超分
针对图片分辨率提升,PaddleGAN提供了[RealSR](#RealSR)[ESRGAN](#ESRGAN)[LESRCNN](#LESRCNN)三种模型。接下来将介绍模型预测方式。
## RealSR
[完整模型教程](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/tutorials/single_image_super_resolution.md)
[RealSR](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsrealsrpredictor)模型通过估计各种模糊内核以及实际噪声分布,为现实世界的图像设计一种新颖的真实图片降采样框架。基于该降采样框架,可以获取与真实世界图像共享同一域的低分辨率图像。并且提出了一个旨在提高感知度的真实世界超分辨率模型。对合成噪声数据和真实世界图像进行的大量实验表明,该模型能够有效降低了噪声并提高了视觉质量。
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925551-02afb500-b32a-11eb-9a11-14e484daa953.png'>
</div>
```
ppgan.apps.RealSRPredictor(output='output', weight_path=None)
```
### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
### 使用方式
**1. API预测**
```
from ppgan.apps import DeepRemasterPredictor
deep_remaster = DeepRemasterPredictor()
deep_remaster.run("docs/imgs/先烈.jpg") #原图片所在路径
```
**2. 命令行预测**
```
!python applications/tools/video-enhance.py --input /home/aistudio/Peking_input360p_clip6_5s.mp4 \ #原视频路径
--process_order DeepRemaster \ #对原视频处理的顺序
--output output_dir #成品视频所在的路径
```
## ESRGAN
[完整模型教程](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/tutorials/single_image_super_resolution.md)
目前ESRGAN还未封装为API供开发者们使用,因此如需使用模型,可下载使用:
| 模型 | 数据集 | 下载地址 |
|---|---|---|
| esrgan_psnr_x4 | DIV2K | [esrgan_psnr_x4](https://paddlegan.bj.bcebos.com/models/esrgan_psnr_x4.pdparams)
| esrgan_x4 | DIV2K | [esrgan_x4](https://paddlegan.bj.bcebos.com/models/esrgan_x4.pdparams)
## LESRCNN
[完整模型教程](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/tutorials/single_image_super_resolution.md)
目前LESRCNN还未封装为API供开发者们使用,因此如需使用模型,可下载使用:
| 模型 | 数据集 | 下载地址 |
|---|---|---|
| lesrcnn_x4 | DIV2K | [lesrcnn_x4](https://paddlegan.bj.bcebos.com/models/lesrcnn_x4.pdparams)
### 在线项目体验
**1. [老北京城影像修复](https://aistudio.baidu.com/aistudio/projectdetail/1161285)**
**2. [PaddleGAN ❤️ 520特辑](https://aistudio.baidu.com/aistudio/projectdetail/1956943?channelType=0&channel=0)**
# 视频上色
针对视频上色,PaddleGAN提供两种上色模型:[DeOldify](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdeoldifypredictor)[DeepRemaster](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdeepremasterpredictor)
## DeOldifyPredictor
[DeOldify](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdeoldifypredictor)采用自注意力机制的生成对抗网络,生成器是一个U-NET结构的网络。在图像/视频的上色方面有着较好的效果。
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925538-fd526a80-b329-11eb-8924-8f2614fcd9e6.png'>
</div>
### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
- `artistic (bool)`: 是否使用偏"艺术性"的模型。"艺术性"的模型有可能产生一些有趣的颜色,但是毛刺比较多。
- `render_factor (int)`: 会将该参数乘以16后作为输入帧的resize的值,如果该值设置为32,
则输入帧会resize到(32 * 16, 32 * 16)的尺寸再输入到网络中。
### 使用方式
**1. API预测**
```
from ppgan.apps import DeOldifyPredictor
deoldify = DeOldifyPredictor()
deoldify.run("/home/aistudio/Peking_input360p_clip6_5s.mp4") #原视频所在路径
```
*`run`接口为图片/视频通用接口,由于这里对象是视频,可以使用`run_video`的接口
**2. 命令行预测**
```
!python applications/tools/video-enhance.py --input /home/aistudio/Peking_input360p_clip6_5s.mp4 \ #原视频路径
--process_order DeOldify \ #对原视频处理的顺序
--output output_dir #成品视频所在的路径
```
## DeepRemasterPredictor
[DeepRemaster](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdeepremasterpredictor) 模型目前只能用于对视频上色,基于时空卷积神经网络和自注意力机制。并且能够根据输入的任意数量的参考帧对视频中的每一帧图片进行上色。
![](../../imgs/remaster_network.png)
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925558-05120f00-b32a-11eb-9727-d1c0d5814dc5.png'>
</div>
```
ppgan.apps.DeepRemasterPredictor(
output='output',
weight_path=None,
colorization=False,
reference_dir=None,
mindim=360):
```
### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
- `colorization (bool)`: 是否对输入视频上色,如果选项设置为 `True` ,则参考帧的文件夹路径也必须要设置。默认值:`False`
- `reference_dir (bool)`: 参考帧的文件夹路径。默认值:`None`
- `mindim (bool)`: 输入帧重新resize后的短边的大小。默认值:360。
### 使用方式
**1. API预测**
```
from ppgan.apps import DeepRemasterPredictor
deep_remaster = DeepRemasterPredictor()
deep_remaster.run("docs/imgs/test_old.jpeg") #原视频所在路径
```
**2. 命令行预测**
```
!python applications/tools/video-enhance.py --input /home/aistudio/Peking_input360p_clip6_5s.mp4 \ #原视频路径
--process_order DeepRemaster \ #对原视频处理的顺序
--output output_dir #成品视频所在的路径
```
### 在线项目体验
**1. [老北京城影像修复](https://aistudio.baidu.com/aistudio/projectdetail/1161285)**
**2. [PaddleGAN ❤️ 520特辑](https://aistudio.baidu.com/aistudio/projectdetail/1956943?channelType=0&channel=0)**
# 视频补帧
针对老视频的流畅度提升,PaddleGAN提供了[DAIN](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdainpredictor)模型接口。
## DAIN
[DAIN](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsdainpredictor)模型通过探索深度的信息来显式检测遮挡。并且开发了一个深度感知的流投影层来合成中间流。在视频补帧方面有较好的效果。
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925889-76ea5880-b32a-11eb-9917-17cea27b64d0.png'>
</div>
```
ppgan.apps.DAINPredictor(
output='output',
weight_path=None,
time_step=None,
use_gpu=True,
remove_duplicates=False)
```
### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
- `time_step (int)`: 补帧的时间系数,如果设置为0.5,则原先为每秒30帧的视频,补帧后变为每秒60帧。
- `remove_duplicates (bool,可选的)`: 是否删除重复帧,默认值:`False`.
### 使用方式
**1. API预测**
除了定义输入视频路径外,此接口还需定义time_step,同时,目前API预测方式只支持在静态图下运行,需加上启动静态图命令,后续会支持动态图,敬请期待~
```
paddle.enable_static()
from ppgan.apps import DAINPredictor
dain = DAINPredictor(output='output', time_step=0.5)
# 测试一个视频文件
dain.run("/home/aistudio/Peking_input360p_clip6_5s.mp4",)
paddle.disable_static()
paddle.disable_static()
```
**2. 命令行预测**
```
!python applications/tools/video-enhance.py --input /home/aistudio/Peking_input360p_clip6_5s.mp4 \ #原视频路径
--process_order DAIN \
--output output_dir #成品视频所在的路径
```
### 在线项目体验
**1. [老北京城影像修复](https://aistudio.baidu.com/aistudio/projectdetail/1161285)**
# 智能影像修复
PaddleGAN提供一系列影像修复能力,包括 **[图片上色](./photo_color_cn.md)、[视频上色](./video_color_cn.md)、[图片分辨率提升](./photo_sr_cn.md)、[视频分辨率提升](./video_sr_cn.md)**,以及 **[视频流畅度提升](./video_frame_cn.md)**(提高视频播放流畅度)三大功能,使得历史影像恢复往日鲜活的色彩,清晰流畅的呈现于我们眼前。
在未来,PaddleGAN也将不断补充与优化影像修复的能力,比如增加去噪、图像修复等功能,还请大家敬请期待!
## **一行代码快速进行影像修复**
```
cd applications
python tools/video-enhance.py --input you_video_path.mp4 --process_order DAIN DeOldify EDVR --output output_dir
```
### **参数**
- `--input (str)`: 输入的视频路径。
- `--output (str)`: 输出的视频路径。
- `--process_order`: 调用的模型名字和顺序,比如输入为 `DAIN DeOldify EDVR`,则会顺序调用 `DAINPredictor` `DeOldifyPredictor` `EDVRPredictor`
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925494-e9a70400-b329-11eb-9f38-a48ef946a3a4.gif' width='600'>
</div>
## 详细教程
* 视频修复
* [视频上色](./video_color_cn.md)
* [视频分辨率提升](./video_sr_cn.md)
* [视频流畅度提升](./video_frame_cn.md)
* 照片修复
* [图片上色](./photo_color_cn.md)
* [图片分辨率提升](./photo_sr_cn.md)
## 在线体验
为了让大家快速体验影像修复的能力,PaddleGAN在飞桨人工智能学习与实训平台AI Studio准备了完整的实现步骤及详细代码,同时,AI Studio还为大家准备了免费的GPU算力,大家登录即可亲自实践 **[老北京城影像修复](https://aistudio.baidu.com/aistudio/projectdetail/1161285)** 的项目,快上手体验吧!
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117924001-a0ee4b80-b327-11eb-8ab8-189f4afb8c23.png'>
</div>
# 视频分辨率提升
针对视频超分,PaddleGAN提供了两种模型,[RealSR](#RealSR)[EDVR](#EDVR)
## RealSR
[完整模型教程](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/tutorials/single_image_super_resolution.md)
[RealSR](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsrealsrpredictor)模型通过估计各种模糊内核以及实际噪声分布,为现实世界的图像设计一种新颖的真实图片降采样框架。基于该降采样框架,可以获取与真实世界图像共享同一域的低分辨率图像。并且提出了一个旨在提高感知度的真实世界超分辨率模型。对合成噪声数据和真实世界图像进行的大量实验表明,该模型能够有效降低了噪声并提高了视觉质量。
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925551-02afb500-b32a-11eb-9a11-14e484daa953.png'>
</div>
```
ppgan.apps.RealSRPredictor(output='output', weight_path=None)
```
### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
### 使用方式
**1. API预测**
```
from ppgan.apps import DeepRemasterPredictor
deep_remaster = DeepRemasterPredictor()
deep_remaster.run("/home/aistudio/Peking_input360p_clip6_5s.mp4") #原视频所在路径
```
**2. 命令行预测**
```
!python applications/tools/video-enhance.py --input /home/aistudio/Peking_input360p_clip6_5s.mp4 \ #原视频路径
--process_order DeepRemaster \ #对原视频处理的顺序
--output output_dir #成品视频所在的路径
```
## EDVR
[完整模型教程](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/tutorials/video_super_resolution.md)
[EDVR](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsedvrpredictor)模型提出了一个新颖的视频具有增强可变形卷积的还原框架:第一,为了处理大动作而设计的一个金字塔,级联和可变形(PCD)对齐模块,使用可变形卷积以从粗到精的方式在特征级别完成对齐;第二,提出时空注意力机制(TSA)融合模块,在时间和空间上都融合了注意机制,用以增强复原的功能。
[EDVR](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsedvrpredictor)模型是一个基于连续帧的超分模型,能够有效利用帧间的信息,速度比[RealSR](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/docs/zh_CN/apis/apps.md#ppganappsrealsrpredictor)模型快。
<div align='center'>
<img src='https://user-images.githubusercontent.com/48054808/117925546-004d5b00-b32a-11eb-9af9-3b19d666de01.png'>
</div>
```
ppgan.apps.EDVRPredictor(output='output', weight_path=None)
```
### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
### 使用方式
**1. API预测**
目前API预测方式只支持在静态图下运行,需加上启动静态图命令,后续会支持动态图,敬请期待~
```
paddle.enable_static()
from ppgan.apps import EDVRPredictor
sr = EDVRPredictor()
# 测试一个视频文件
sr.run("/home/aistudio/Peking_input360p_clip6_5s.mp4") #原视频所在路径
paddle.disable_static()
```
**2. 命令行预测**
```
!python applications/tools/video-enhance.py --input /home/aistudio/Peking_input360p_clip6_5s.mp4 \ #原视频路径
--process_order EDVR \ #对原视频处理的顺序,此处注意“EDVR”四个字母都需大写
--output output_dir #成品视频所在的路径
```
### 在线项目体验
**1. [老北京城影像修复](https://aistudio.baidu.com/aistudio/projectdetail/1161285)**
**2. [PaddleGAN ❤️ 520特辑](https://aistudio.baidu.com/aistudio/projectdetail/1956943?channelType=0&channel=0)**
## 安装PaddleGAN
# 安装文档
本文档包含了如何安装PaddleGAN以及相关依赖,更多产品简介请参考[README](https://github.com/PaddlePaddle/PaddleGAN/blob/develop/README_cn.md)
### 要求
## 环境依赖
- PaddlePaddle >= 2.0.0
- Python >= 3.6
- CUDA >= 9.0
* PaddlePaddle >= 2.0.0
* Python >= 3.6
* CUDA >= 9.0
## 安装PaddlePaddle
### 1. 安装PaddlePaddle
```
pip install -U paddlepaddle-gpu==2.0.0
# CUDA9.0
python -m pip install paddlepaddle-gpu==2.0.1.post90 -i https://mirror.baidu.com/pypi/simple
# CUDA10.1
python -m pip install paddlepaddle-gpu==2.0.1.post101 -f https://mirror.baidu.com/pypi/simple
# CPU
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
```
上面命令会默认安装cuda10.2的包,如果想安装其他cuda版本的包或者其他的系统,请参考[paddlepaddle官网安装教程](https://www.paddlepaddle.org.cn/install/quick)
更多安装方式例如conda或源码编译安装方法,请参考[PaddlePaddle安装文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/index_cn.html)
### 2. 安装PaddleGAN
请确保您的PaddlePaddle安装成功并且版本不低于需求版本。使用以下命令进行验证。
##### 2.1 通过Pip安裝
```
# only support Python3
python3 -m pip install --upgrade ppgan
# 在您的Python解释器中确认PaddlePaddle安装成功
>>> import paddle
>>> paddle.utils.run_check()
# 确认PaddlePaddle版本
python -c "import paddle; print(paddle.__version__)"
```
下载示例和配置文件:
## 安装PaddleGAN
### 通过PIP安裝(只支持Python3)
* 安装:
```
python3 -m pip install --upgrade ppgan
```
* 下载示例和配置文件:
```
git clone https://github.com/PaddlePaddle/PaddleGAN
cd PaddleGAN
```
##### 2.2通过源码安装
### 通过源码安装
```
git clone https://github.com/PaddlePaddle/PaddleGAN
cd PaddleGAN
pip install -v -e . # or "python setup.py develop"
```
按照上述方法安装成功后,本地的修改也会自动同步到ppgan中
# 安装其他依赖
pip install -r requirements.txt
```
## 其他第三方工具安装
### 4. 其他可能用到的工具安装
#### 4.1 ffmpeg
如果需要使用ppgan处理视频相关的任务,则需要安装ffmpeg。这里推荐您使用[conda](https://docs.conda.io/en/latest/miniconda.html)安装:
* 涉及视频的任务都需安装**ffmpeg**,这里推荐使用[conda](https://docs.conda.io/en/latest/miniconda.html)安装:
```
conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge
```
#### 4.2 Visual DL
如果需要使用[飞桨VisualDL](https://github.com/PaddlePaddle/VisualDL)对训练过程进行可视化监控,请安装`VisualDL`(使用方法请参考[这里](./get_started.md)):
* 如需使用可视化工具监控训练过程,请安装[飞桨VisualDL](https://github.com/PaddlePaddle/VisualDL)
```
python -m pip install visualdl -i https://mirror.baidu.com/pypi/simple
```
*注意:VisualDL目前只维护Python3以上的安装版本
## 老视频修复
老视频往往具有帧数少,无色彩,分辨率低等特点。于是针对这些特点,我们使用补帧,上色,超分等模型对视频进行修复。
### 使用applications中的video-enhance.py工具进行快速开始视频修复
```
cd applications
python tools/video-enhance.py --input you_video_path.mp4 --process_order DAIN DeOldify EDVR --output output_dir
```
#### 参数
- `--input (str)`: 输入的视频路径。
- `--output (str)`: 输出的视频路径。
- `--process_order`: 调用的模型名字和顺序,比如输入为 `DAIN DeOldify EDVR`,则会顺序调用 `DAINPredictor` `DeOldifyPredictor` `EDVRPredictor`
#### 效果展示
![](../../imgs/color_sr_peking.gif)
### 快速体验
我们在ai studio制作了一个[ai studio 老北京视频修复教程](https://aistudio.baidu.com/aistudio/projectdetail/1161285)
### 注意事项
* 在使用本教程前,请确保您已经[安装完paddle和ppgan](../install.md)
* 本教程的所有命令都基于PaddleGAN/applications主目录进行执行。
* 各个模型耗时较长,尤其使超分辨率模型,建议输入的视频分辨率低一些,时长短一些。
* 需要运行在gpu环境上
### ppgan提供的可用于视频修复的预测api简介
可以根据要修复的视频的特点,使用不同的模型与参数
### 补帧模型DAIN
DAIN 模型通过探索深度的信息来显式检测遮挡。并且开发了一个深度感知的流投影层来合成中间流。在视频补帧方面有较好的效果。
![](../../imgs/dain_network.png)
```
ppgan.apps.DAINPredictor(
output='output',
weight_path=None,
time_step=None,
use_gpu=True,
remove_duplicates=False)
```
#### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
- `time_step (int)`: 补帧的时间系数,如果设置为0.5,则原先为每秒30帧的视频,补帧后变为每秒60帧。
- `remove_duplicates (bool,可选的)`: 是否删除重复帧,默认值:`False`.
### 上色模型DeOldifyPredictor
DeOldify 采用自注意力机制的生成对抗网络,生成器是一个U-NET结构的网络。在图像的上色方面有着较好的效果。
![](../../imgs/deoldify_network.png)
```
ppgan.apps.DeOldifyPredictor(output='output', weight_path=None, render_factor=32)
```
#### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
- `artistic (bool)`: 是否使用偏"艺术性"的模型。"艺术性"的模型有可能产生一些有趣的颜色,但是毛刺比较多。
- `render_factor (int)`: 会将该参数乘以16后作为输入帧的resize的值,如果该值设置为32,
则输入帧会resize到(32 * 16, 32 * 16)的尺寸再输入到网络中。
### 上色模型DeepRemasterPredictor
DeepRemaster 模型基于时空卷积神经网络和自注意力机制。并且能够根据输入的任意数量的参考帧对图片进行上色。
![](../../imgs/remaster_network.png)
```
ppgan.apps.DeepRemasterPredictor(
output='output',
weight_path=None,
colorization=False,
reference_dir=None,
mindim=360):
```
#### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
- `colorization (bool)`: 是否对输入视频上色,如果选项设置为 `True` ,则参考帧的文件夹路径也必须要设置。默认值:`False`
- `reference_dir (bool)`: 参考帧的文件夹路径。默认值:`None`
- `mindim (bool)`: 输入帧重新resize后的短边的大小。默认值:360。
### 超分辨率模型RealSRPredictor
RealSR模型通过估计各种模糊内核以及实际噪声分布,为现实世界的图像设计一种新颖的真实图片降采样框架。基于该降采样框架,可以获取与真实世界图像共享同一域的低分辨率图像。并且提出了一个旨在提高感知度的真实世界超分辨率模型。对合成噪声数据和真实世界图像进行的大量实验表明,该模型能够有效降低了噪声并提高了视觉质量。
![](../../imgs/realsr_network.png)
```
ppgan.apps.RealSRPredictor(output='output', weight_path=None)
```
#### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
-
### 超分辨率模型EDVRPredictor
EDVR模型提出了一个新颖的视频具有增强可变形卷积的还原框架:第一,为了处理大动作而设计的一个金字塔,级联和可变形(PCD)对齐模块,使用可变形卷积以从粗到精的方式在特征级别完成对齐;第二,提出时空注意力机制(TSA)融合模块,在时间和空间上都融合了注意机制,用以增强复原的功能。
EDVR模型是一个基于连续帧的超分模型,能够有效利用帧间的信息,速度比RealSR模型快。
![](../../imgs/edvr_network.png)
```
ppgan.apps.EDVRPredictor(output='output', weight_path=None)
```
#### 参数
- `output (str,可选的)`: 输出的文件夹路径,默认值:`output`.
- `weight_path (None,可选的)`: 载入的权重路径,如果没有设置,则从云端下载默认的权重到本地。默认值:`None`
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册