Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
1b96f96a
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看板
提交
1b96f96a
编写于
4年前
作者:
L
LielinJiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some bug
上级
f4a88e2e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
2 deletion
+94
-2
applications/DAIN/predict.py
applications/DAIN/predict.py
+1
-1
applications/EDVR/data.py
applications/EDVR/data.py
+90
-0
applications/tools/main.py
applications/tools/main.py
+3
-1
未找到文件。
applications/DAIN/predict.py
浏览文件 @
1b96f96a
...
...
@@ -252,7 +252,7 @@ class VideoFrameInterp(object):
for
item
,
time_offset
in
zip
(
y_
,
time_offsets
):
out_dir
=
os
.
path
.
join
(
frame_path_interpolated
,
vidname
,
"{:0>
4
d}_{:0>4d}.png"
.
format
(
i
,
count
))
"{:0>
6
d}_{:0>4d}.png"
.
format
(
i
,
count
))
count
=
count
+
1
imsave
(
out_dir
,
np
.
round
(
item
).
astype
(
np
.
uint8
))
...
...
This diff is collapsed.
Click to expand it.
applications/EDVR/data.py
0 → 100644
浏览文件 @
1b96f96a
import
cv2
import
numpy
as
np
def
read_img
(
path
,
size
=
None
,
is_gt
=
False
):
"""read image by cv2
return: Numpy float32, HWC, BGR, [0,1]"""
# print('debug:', path)
img
=
cv2
.
imread
(
path
,
cv2
.
IMREAD_UNCHANGED
)
img
=
img
.
astype
(
np
.
float32
)
/
255.
if
img
.
ndim
==
2
:
img
=
np
.
expand_dims
(
img
,
axis
=
2
)
if
img
.
shape
[
2
]
>
3
:
img
=
img
[:,
:,
:
3
]
return
img
def
get_test_neighbor_frames
(
crt_i
,
N
,
max_n
,
padding
=
'new_info'
):
"""Generate an index list for reading N frames from a sequence of images
Args:
crt_i (int): current center index
max_n (int): max number of the sequence of images (calculated from 1)
N (int): reading N frames
padding (str): padding mode, one of replicate | reflection | new_info | circle
Example: crt_i = 0, N = 5
replicate: [0, 0, 0, 1, 2]
reflection: [2, 1, 0, 1, 2]
new_info: [4, 3, 0, 1, 2]
circle: [3, 4, 0, 1, 2]
Returns:
return_l (list [int]): a list of indexes
"""
max_n
=
max_n
-
1
n_pad
=
N
//
2
return_l
=
[]
for
i
in
range
(
crt_i
-
n_pad
,
crt_i
+
n_pad
+
1
):
if
i
<
0
:
if
padding
==
'replicate'
:
add_idx
=
0
elif
padding
==
'reflection'
:
add_idx
=
-
i
elif
padding
==
'new_info'
:
add_idx
=
(
crt_i
+
n_pad
)
+
(
-
i
)
elif
padding
==
'circle'
:
add_idx
=
N
+
i
else
:
raise
ValueError
(
'Wrong padding mode'
)
elif
i
>
max_n
:
if
padding
==
'replicate'
:
add_idx
=
max_n
elif
padding
==
'reflection'
:
add_idx
=
max_n
*
2
-
i
elif
padding
==
'new_info'
:
add_idx
=
(
crt_i
-
n_pad
)
-
(
i
-
max_n
)
elif
padding
==
'circle'
:
add_idx
=
i
-
N
else
:
raise
ValueError
(
'Wrong padding mode'
)
else
:
add_idx
=
i
return_l
.
append
(
add_idx
)
# name_b = '{:08d}'.format(crt_i)
return
return_l
class
EDVRDataset
:
def
__init__
(
self
,
frame_paths
):
self
.
frames
=
frame_paths
def
__getitem__
(
self
,
index
):
indexs
=
get_test_neighbor_frames
(
index
,
5
,
len
(
self
.
frames
))
frame_list
=
[]
for
i
in
indexs
:
img
=
read_img
(
self
.
frames
[
i
])
frame_list
.
append
(
img
)
img_LQs
=
np
.
stack
(
frame_list
,
axis
=
0
)
print
(
'img:'
,
img_LQs
.
shape
)
# BGR to RGB, HWC to CHW, numpy to tensor
img_LQs
=
img_LQs
[:,
:,
:,
[
2
,
1
,
0
]]
img_LQs
=
np
.
transpose
(
img_LQs
,
(
0
,
3
,
1
,
2
)).
astype
(
'float32'
)
return
img_LQs
,
self
.
frames
[
index
]
def
__len__
(
self
):
return
len
(
self
.
frames
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
applications/tools/main.py
浏览文件 @
1b96f96a
...
...
@@ -26,9 +26,11 @@ if __name__ == "__main__":
temp_video_path
=
None
for
order
in
orders
:
if
temp_video_path
is
None
:
temp_video_path
=
args
.
input
if
order
==
'DAIN'
:
predictor
=
VideoFrameInterp
(
args
.
time_step
,
args
.
DAIN_weight
,
args
.
input
,
output_path
=
args
.
output
)
temp_video_path
,
output_path
=
args
.
output
)
frames_path
,
temp_video_path
=
predictor
.
run
()
elif
order
==
'DeOldify'
:
print
(
'frames:'
,
frames_path
)
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
新手
引导
客服
返回
顶部