README.md 4.1 KB
Newer Older
yongshk's avatar
更新  
yongshk committed
1
# FLAVR
yongshk's avatar
yongshk committed
2
3
4
5
6
7
8

## 论文

` FLAVR: Flow-Agnostic Video Representations for Fast Frame Interpolation `

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

yongshk's avatar
更新  
yongshk committed
9
## 模型结构
yongshk's avatar
yongshk committed
10
11
 FLAVR模型是一个3D U-Net模型,通过拓展2D U-Net,将2D卷积替换为3D卷积而得到的。该模型能够更准确地对输入帧之间的时间动态进行建模,从而获得更好的插值质量。 

yongshk's avatar
yongshk committed
12
![](https://developer.hpccube.com/codes/modelzoo/flavr_pytorch/-/raw/master/doc/arch_dia.png)
yongshk's avatar
yongshk committed
13
14
15

## 算法原理

yongshk's avatar
yongshk committed
16
  3D U-Net结构、encoder部分采用ResNet-3D,decoder部分采用3D TransConv,以及Spatio-Temporal Feature Gating ![](https://developer.hpccube.com/codes/modelzoo/flavr_pytorch/-/raw/master/doc/%E5%8E%9F%E7%90%86.png)
yongshk's avatar
yongshk committed
17
18
19
20
21

## 环境配置

### Docker(方法一)

dcuai's avatar
dcuai committed
22
此处提供[光源](https://sourcefind.cn/#/main-page)拉取docker镜像
yongshk's avatar
yongshk committed
23
24

```
shantf's avatar
shantf committed
25
26
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10 
docker run -it --network=host --name=flavr --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 -v /opt/hyhal:/opt/hyhal:ro --ulimit memlock=-1:-1 image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10
dcuai's avatar
dcuai committed
27
pip install -r requirements.txt
yongshk's avatar
yongshk committed
28
29
30
31
32
33
34
35
```

### Dockerfile(方法二)

dockerfile使用方法

```
docker build --no-cache -t flavr:latest .
shantf's avatar
shantf committed
36
docker run -dit --network=host --name=flavr --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 -v /opt/hyhal:/opt/hyhal:ro --ulimit stack=-1:-1 --ulimit memlock=-1:-1 flavr:latest
yongshk's avatar
yongshk committed
37
38
39
40
41
42
43
44
docker exec -it flavr /bin/bash
```

### Anaconda(方法三)

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

```
shantf's avatar
shantf committed
45
46
47
48
DTK驱动:dtk24.04.1
python:python3.10
torch==2.1.0+das1.1.git3ac1bdd.abi1.dtk2404
torchvision==0.16.0+das1.1.git7d45932.abi1.dtk2404.torch2.1
yongshk's avatar
yongshk committed
49
50
51
52
53
54
55
```

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

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

```
dcuai's avatar
dcuai committed
56
57
pip install -r requirements.txt
pip install tensorboard setuptools==57.5.0 six
yongshk's avatar
yongshk committed
58
```
yongshk's avatar
yongshk committed
59

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

yongshk's avatar
yongshk committed
62
63
64
`模型使用数据为 Vimeo-90K `

-  http://toflow.csail.mit.edu/
bailuo's avatar
bailuo committed
65
- 或者从`SCNet`下载[Vimeo-90K](http://113.200.138.88:18080/aidatasets/project-dependency/vimeo-90k.git)
yongshk's avatar
yongshk committed
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

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

```
 ── datasets
   │   ├── readme.txt
   │   ├── sep_testlist.txt 
   │   ├── sep_trainlist.txt 
   │   ├── sequences
          │    ├── xx/xx/xxx.png
          │    ├── xx/xx/xxx.png
```




## 训练
### 单机单卡

```
shantf's avatar
shantf committed
86
注意:在k100_AI上运行需要在命令行前设置HIP_VISIBLE_DEVICES=xx,指定一下使用显卡
yongshk's avatar
yongshk committed
87
88
89
90
python main.py --batch_size 32 --test_batch_size 32 --dataset vimeo90K_septuplet --loss 1*L1 --max_epoch 200 --lr 0.0002 --data_root datasets --n_outputs 1 --num_gpu 1
```

### 单机多卡
yongshk's avatar
yongshk committed
91

yongshk's avatar
yongshk committed
92
93
94
```
python main.py --batch_size 32 --test_batch_size 32 --dataset vimeo90K_septuplet --loss 1*L1 --max_epoch 200 --lr 0.0002 --data_root datasets --n_outputs 1 --num_gpu 4
```
yongshk's avatar
yongshk committed
95

yongshk's avatar
yongshk committed
96
## 推理
yongshk's avatar
yongshk committed
97

yongshk's avatar
yongshk committed
98
    python test.py --dataset vimeo90K_septuplet --data_root <data_path> --load_from <saved_model> --n_outputs 1
yongshk's avatar
yongshk committed
99

yongshk's avatar
yongshk committed
100
## result
yongshk's avatar
yongshk committed
101

yongshk's avatar
yongshk committed
102
测试图
yongshk's avatar
yongshk committed
103

yongshk's avatar
yongshk committed
104
![](https://developer.hpccube.com/codes/modelzoo/flavr_pytorch/-/raw/master/doc/sprite.gif)
yongshk's avatar
yongshk committed
105

yongshk's avatar
yongshk committed
106
### 精度
yongshk's avatar
yongshk committed
107

bailuo's avatar
bailuo committed
108
测试数据:[vimeo-90](http://113.200.138.88:18080/aidatasets/project-dependency/vimeo-90k.git),使用的加速卡:Z100L。
yongshk's avatar
yongshk committed
109
110
111

根据测试结果情况填写表格:

yongshk's avatar
yongshk committed
112
113
114
|  FLAVR   |   PSNR    | SSIM     |
| :------: | :-------: | -------- |
| vimeo-90 | 18.511020 | 0.702564 |
yongshk's avatar
yongshk committed
115
116
117
118
119
120
121
122
123

## 应用场景

### 算法类别

`图像超分`

### 热点应用行业

dcuai's avatar
dcuai committed
124
`设计`,`制造`,`科研`
yongshk's avatar
yongshk committed
125

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

dcuai's avatar
dcuai committed
128
*   https://developer.hpccube.com/codes/modelzoo/flavr_pytorch 
yongshk's avatar
yongshk committed
129
130
131
## 参考资料
*  https://github.com/tarun005/FLAVR