Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
linkedin_61247605
DeepMosaics
提交
e31088f5
DeepMosaics
项目概览
linkedin_61247605
/
DeepMosaics
与 Fork 源项目一致
Fork自
Hypo / DeepMosaics
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DeepMosaics
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e31088f5
编写于
12月 19, 2020
作者:
H
hypox64
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean cache during processing
上级
cab98f71
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
20 addition
and
14 deletion
+20
-14
cores/core.py
cores/core.py
+17
-14
util/util.py
util/util.py
+3
-0
未找到文件。
cores/core.py
浏览文件 @
e31088f5
...
...
@@ -16,21 +16,20 @@ def video_init(opt,path):
fps
=
opt
.
fps
continue_flag
=
False
imagepaths
=
[]
if
os
.
path
.
isdir
(
opt
.
temp_dir
):
if
(
opt
.
last_time
!=
'00:00:00'
and
len
(
os
.
listdir
(
os
.
path
.
join
(
opt
.
temp_dir
,
'video2image'
)))
>
fps
*
(
util
.
stamp2second
(
opt
.
last_time
)
-
1
))
\
or
(
opt
.
last_time
==
'00:00:00'
and
len
(
os
.
listdir
(
os
.
path
.
join
(
opt
.
temp_dir
,
'video2image'
)))
>
fps
*
(
endtime
-
1
)):
imagepaths
=
os
.
listdir
(
opt
.
temp_dir
+
'/video2image'
)
if
imagepaths
!=
[]:
imagepaths
.
sort
()
last_frame
=
int
(
imagepaths
[
-
1
][
7
:
13
])
if
(
opt
.
last_time
!=
'00:00:00'
and
last_frame
>
fps
*
(
util
.
stamp2second
(
opt
.
last_time
)
-
1
))
\
or
(
opt
.
last_time
==
'00:00:00'
and
last_frame
>
fps
*
(
endtime
-
1
)):
choose
=
input
(
'There is an unfinished video. Continue it? [y/n] '
)
if
choose
.
lower
()
==
'yes'
or
choose
.
lower
()
==
'y'
:
continue_flag
=
True
if
continue_flag
:
processed_num
=
max
(
len
(
os
.
listdir
(
os
.
path
.
join
(
opt
.
temp_dir
,
'addmosaic_image'
))),
len
(
os
.
listdir
(
os
.
path
.
join
(
opt
.
temp_dir
,
'replace_mosaic'
))),
len
(
os
.
listdir
(
os
.
path
.
join
(
opt
.
temp_dir
,
'style_transfer'
))))
imagepaths
=
os
.
listdir
(
opt
.
temp_dir
+
'/video2image'
)
imagepaths
.
sort
()
imagepaths
=
imagepaths
[
processed_num
:]
else
:
if
not
continue_flag
:
util
.
file_init
(
opt
)
ffmpeg
.
video2voice
(
path
,
opt
.
temp_dir
+
'/voice_tmp.mp3'
,
opt
.
start_time
,
opt
.
last_time
)
ffmpeg
.
video2image
(
path
,
opt
.
temp_dir
+
'/video2image/output_%06d.'
+
opt
.
tempimage_type
,
fps
,
opt
.
start_time
,
opt
.
last_time
)
...
...
@@ -89,6 +88,7 @@ def addmosaic_video(opt,netS):
except
Exception
as
e
:
print
(
'Warning:'
,
e
)
cv2
.
imwrite
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/addmosaic_image'
,
imagepath
),
img
)
os
.
remove
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/video2image'
,
imagepath
))
#preview result and print
if
not
opt
.
no_preview
:
...
...
@@ -129,6 +129,7 @@ def styletransfer_video(opt,netG):
img
=
impro
.
imread
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/video2image'
,
imagepath
))
img
=
runmodel
.
run_styletransfer
(
opt
,
netG
,
img
)
cv2
.
imwrite
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/style_transfer'
,
imagepath
),
img
)
os
.
remove
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/video2image'
,
imagepath
))
#preview result and print
if
not
opt
.
no_preview
:
...
...
@@ -225,6 +226,7 @@ def cleanmosaic_video_byframe(opt,netG,netM):
except
Exception
as
e
:
print
(
'Warning:'
,
e
)
cv2
.
imwrite
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/replace_mosaic'
,
imagepath
),
img_result
)
os
.
remove
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/video2image'
,
imagepath
))
#preview result and print
if
not
opt
.
no_preview
:
...
...
@@ -288,6 +290,7 @@ def cleanmosaic_video_fusion(opt,netG,netM):
except
Exception
as
e
:
print
(
'Warning:'
,
e
)
cv2
.
imwrite
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/replace_mosaic'
,
imagepath
),
img_result
)
os
.
remove
(
os
.
path
.
join
(
opt
.
temp_dir
+
'/video2image'
,
imagepath
))
#preview result and print
if
not
opt
.
no_preview
:
...
...
util/util.py
浏览文件 @
e31088f5
...
...
@@ -74,6 +74,9 @@ def clean_tempfiles(opt,tmp_init=True):
os
.
makedirs
(
os
.
path
.
join
(
tmpdir
,
'mosaic_mask'
))
os
.
makedirs
(
os
.
path
.
join
(
tmpdir
,
'ROI_mask'
))
os
.
makedirs
(
os
.
path
.
join
(
tmpdir
,
'style_transfer'
))
# make dataset
os
.
makedirs
(
os
.
path
.
join
(
tmpdir
,
'mosaic_crop'
))
os
.
makedirs
(
os
.
path
.
join
(
tmpdir
,
'ROI_mask_check'
))
def
file_init
(
opt
):
if
not
os
.
path
.
isdir
(
opt
.
result_dir
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录