Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
61d4939d
P
PaddleGAN
项目概览
PaddlePaddle
/
PaddleGAN
1 年多 前同步成功
通知
97
Star
7254
Fork
1210
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleGAN
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
61d4939d
编写于
5月 18, 2021
作者:
W
wangna11BD
提交者:
GitHub
5月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add EDVR predictor dynamic (#315)
上级
d81d9cc5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
23 deletion
+23
-23
applications/tools/video-enhance.py
applications/tools/video-enhance.py
+0
-2
ppgan/apps/edvr_predictor.py
ppgan/apps/edvr_predictor.py
+23
-21
未找到文件。
applications/tools/video-enhance.py
浏览文件 @
61d4939d
...
...
@@ -119,10 +119,8 @@ if __name__ == "__main__":
weight_path
=
args
.
RealSR_weight
)
frames_path
,
temp_video_path
=
predictor
.
run
(
temp_video_path
)
elif
order
==
'EDVR'
:
paddle
.
enable_static
()
predictor
=
EDVRPredictor
(
args
.
output
,
weight_path
=
args
.
EDVR_weight
)
frames_path
,
temp_video_path
=
predictor
.
run
(
temp_video_path
)
paddle
.
disable_static
()
print
(
'Model {} output frames path:'
.
format
(
order
),
frames_path
)
print
(
'Model {} output video path:'
.
format
(
order
),
temp_video_path
)
...
...
ppgan/apps/edvr_predictor.py
浏览文件 @
61d4939d
...
...
@@ -19,12 +19,15 @@ import glob
import
numpy
as
np
from
tqdm
import
tqdm
import
paddle
from
paddle.io
import
Dataset
,
DataLoader
from
ppgan.utils.download
import
get_path_from_url
from
ppgan.utils.video
import
frames2video
,
video2frames
from
ppgan.models.generators
import
EDVRNet
from
.base_predictor
import
BasePredictor
EDVR_WEIGHT_URL
=
'https://paddlegan.bj.bcebos.com/
applications/edvr_infer_model.tar
'
EDVR_WEIGHT_URL
=
'https://paddlegan.bj.bcebos.com/
models/EDVR_L_w_tsa_SRx4.pdparams
'
def
get_img
(
pred
):
...
...
@@ -110,7 +113,7 @@ def get_test_neighbor_frames(crt_i, N, max_n, padding='new_info'):
return
return_l
class
EDVRDataset
:
class
EDVRDataset
(
Dataset
)
:
def
__init__
(
self
,
frame_paths
):
self
.
frames
=
frame_paths
...
...
@@ -133,16 +136,15 @@ class EDVRDataset:
class
EDVRPredictor
(
BasePredictor
):
def
__init__
(
self
,
output
=
'output'
,
weight_path
=
None
):
def
__init__
(
self
,
output
=
'output'
,
weight_path
=
None
,
bs
=
1
):
self
.
input
=
input
self
.
output
=
os
.
path
.
join
(
output
,
'EDVR'
)
self
.
bs
=
bs
self
.
model
=
EDVRNet
(
nf
=
128
,
back_RBs
=
40
)
if
weight_path
is
None
:
weight_path
=
get_path_from_url
(
EDVR_WEIGHT_URL
)
self
.
weight_path
=
weight_path
self
.
build_inference_model
()
self
.
model
.
set_dict
(
paddle
.
load
(
weight_path
)[
'generator'
])
self
.
model
.
eval
()
def
run
(
self
,
video_path
):
vid
=
video_path
...
...
@@ -163,23 +165,23 @@ class EDVRPredictor(BasePredictor):
frames
=
sorted
(
glob
.
glob
(
os
.
path
.
join
(
out_path
,
'*.png'
)))
dataset
=
EDVRDataset
(
frames
)
test_dataset
=
EDVRDataset
(
frames
)
dataset
=
DataLoader
(
test_dataset
,
batch_size
=
self
.
bs
,
num_workers
=
2
)
periods
=
[]
cur_time
=
time
.
time
()
for
infer_iter
,
data
in
enumerate
(
tqdm
(
dataset
)):
data_feed_in
=
[
data
[
0
]]
outs
=
self
.
base_forward
(
np
.
array
(
data_feed_in
))
infer_result_list
=
[
item
for
item
in
outs
]
data_feed_in
=
paddle
.
to_tensor
(
data
[
0
])
with
paddle
.
no_grad
():
outs
=
self
.
model
(
data_feed_in
).
numpy
()
infer_result_list
=
[
outs
[
i
,
:,
:,
:]
for
i
in
range
(
self
.
bs
)]
frame_path
=
data
[
1
]
img_i
=
get_img
(
infer_result_list
[
0
])
save_img
(
img_i
,
os
.
path
.
join
(
pred_frame_path
,
os
.
path
.
basename
(
frame_path
)))
for
i
in
range
(
self
.
bs
):
img_i
=
get_img
(
infer_result_list
[
i
])
save_img
(
img_i
,
os
.
path
.
join
(
pred_frame_path
,
os
.
path
.
basename
(
frame_path
[
i
])))
prev_time
=
cur_time
cur_time
=
time
.
time
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录