Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
a123456jy
DeepMosaics
提交
6b747324
DeepMosaics
项目概览
a123456jy
/
DeepMosaics
与 Fork 源项目一致
Fork自
Hypo / DeepMosaics
通知
1
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,发现更多精彩内容 >>
提交
6b747324
编写于
7月 31, 2019
作者:
H
hypox64
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed an BUG that in Windows could not read Chinese path images.
上级
7474e4bd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
16 deletion
+20
-16
README.md
README.md
+4
-4
deepmosaic.py
deepmosaic.py
+5
-5
options.py
options.py
+6
-2
util/image_processing.py
util/image_processing.py
+5
-0
util/util.py
util/util.py
+0
-5
未找到文件。
README.md
浏览文件 @
6b747324
![
image
](
https://github.com/HypoX64/DeepMosaics/blob/master/hand.gif
)
# DeepMosaics
You can use it to automatically remove the mosaics in images and videos, or add mosaics to them.
<br>
This porject based on
semantic segmentation and pix2pix
.
This porject based on
‘semantic segmentation’ and ‘Image-to-Image Translation’
.
<br>
## Notice
...
...
@@ -9,10 +9,10 @@ The code do not include the part of training, I will finish it in my free time.
<br>
## Prerequisites
-
Linux,
(I didn't try this code on Windows or Mac OS)
-
Linux,
Mac OS, Windows
-
Python 3.6+
-
ffmpeg
-
Pytorch 1.0+
[
(Old version codes)
](
https://github.com/HypoX64/DeepMosaics/tree/Pytorch0.4
)
-
[
ffmpeg 3.4
](
http://ffmpeg.org/
)
-
[
Pytorch 1.0+
](
https://pytorch.org/
)
[
(Old version codes)
]
(https://github.com/HypoX64/DeepMosaics/tree/Pytorch0.4)
-
CPU or NVIDIA GPU + CUDA CuDNN
## Getting Started
...
...
deepmosaic.py
浏览文件 @
6b747324
...
...
@@ -21,7 +21,7 @@ if opt.mode == 'add':
path
=
opt
.
media_path
if
util
.
is_img
(
path
):
print
(
'Add Mosaic:'
,
path
)
img
=
cv2
.
imread
(
path
)
img
=
impro
.
imread
(
path
)
img
=
runmodel
.
add_mosaic_to_image
(
img
,
net
,
opt
)
cv2
.
imwrite
(
os
.
path
.
join
(
opt
.
result_dir
,
os
.
path
.
basename
(
path
)),
img
)
elif
util
.
is_video
(
path
):
...
...
@@ -34,7 +34,7 @@ if opt.mode == 'add':
for
imagepath
in
imagepaths
:
imagepath
=
os
.
path
.
join
(
'./tmp/video2image'
,
imagepath
)
print
(
'Add Mosaic:'
,
imagepath
)
img
=
cv2
.
imread
(
imagepath
)
img
=
impro
.
imread
(
imagepath
)
img
=
runmodel
.
add_mosaic_to_image
(
img
,
net
,
opt
)
cv2
.
imwrite
(
os
.
path
.
join
(
'./tmp/addmosaic_image'
,
os
.
path
.
basename
(
imagepath
)),
img
)
...
...
@@ -49,7 +49,7 @@ elif opt.mode == 'clean':
path
=
opt
.
media_path
if
util
.
is_img
(
path
):
print
(
'Clean Mosaic:'
,
path
)
img_origin
=
cv2
.
imread
(
path
)
img_origin
=
impro
.
imread
(
path
)
x
,
y
,
size
=
runmodel
.
get_mosaic_position
(
img_origin
,
net_mosaic_pos
,
opt
)
img_result
=
img_origin
.
copy
()
if
size
!=
0
:
...
...
@@ -68,7 +68,7 @@ elif opt.mode == 'clean':
imagepaths
.
sort
()
for
imagepath
in
imagepaths
:
imagepath
=
os
.
path
.
join
(
'./tmp/video2image'
,
imagepath
)
img_origin
=
cv2
.
imread
(
imagepath
)
img_origin
=
impro
.
imread
(
imagepath
)
x
,
y
,
size
=
runmodel
.
get_mosaic_position
(
img_origin
,
net_mosaic_pos
,
opt
)
positions
.
append
([
x
,
y
,
size
])
print
(
'Find Positions:'
,
imagepath
)
...
...
@@ -79,7 +79,7 @@ elif opt.mode == 'clean':
for
i
,
imagepath
in
enumerate
(
imagepaths
,
0
):
imagepath
=
os
.
path
.
join
(
'./tmp/video2image'
,
imagepath
)
x
,
y
,
size
=
positions
[
i
][
0
],
positions
[
i
][
1
],
positions
[
i
][
2
]
img_origin
=
cv2
.
imread
(
imagepath
)
img_origin
=
impro
.
imread
(
imagepath
)
img_result
=
img_origin
.
copy
()
if
size
!=
0
:
img_mosaic
=
img_origin
[
y
-
size
:
y
+
size
,
x
-
size
:
x
+
size
]
...
...
options.py
浏览文件 @
6b747324
...
...
@@ -25,8 +25,7 @@ class Options():
#AddMosaic
self
.
parser
.
add_argument
(
'--netG'
,
type
=
str
,
default
=
'auto'
,
help
=
'select model to use for netG(clean mosaic) -> auto | unet_128 | resnet_9blocks'
)
self
.
parser
.
add_argument
(
'--mosaic_position_model_path'
,
type
=
str
,
default
=
'./pretrained_models/mosaic_position.pth'
,
help
=
'name of model use to find mosaic position'
)
self
.
parser
.
add_argument
(
'--mosaic_position_model_path'
,
type
=
str
,
default
=
'auto'
,
help
=
'name of model use to find mosaic position'
)
self
.
parser
.
add_argument
(
'--no_feather'
,
action
=
'store_true'
,
help
=
'if true, no edge feather,but run faster'
)
self
.
parser
.
add_argument
(
'--medfilt_num'
,
type
=
int
,
default
=
11
,
help
=
'medfilt window of mosaic movement in the video'
)
self
.
initialized
=
True
...
...
@@ -43,4 +42,9 @@ class Options():
elif
'resnet_9blocks'
in
self
.
opt
.
model_path
:
self
.
opt
.
netG
=
'resnet_9blocks'
if
self
.
opt
.
mosaic_position_model_path
==
'auto'
:
_path
=
os
.
path
.
join
(
os
.
path
.
split
(
self
.
opt
.
model_path
)[
0
],
'mosaic_position.pth'
)
self
.
opt
.
mosaic_position_model_path
=
_path
print
(
self
.
opt
.
mosaic_position_model_path
)
return
self
.
opt
\ No newline at end of file
util/image_processing.py
浏览文件 @
6b747324
...
...
@@ -2,6 +2,11 @@ import cv2
import
numpy
as
np
# imread for chinese path in windows
def
imread
(
file_path
):
cv_img
=
cv2
.
imdecode
(
np
.
fromfile
(
file_path
,
dtype
=
np
.
uint8
),
-
1
)
return
cv_img
def
resize
(
img
,
size
):
h
,
w
=
img
.
shape
[:
2
]
if
np
.
min
((
w
,
h
))
==
size
:
...
...
util/util.py
浏览文件 @
6b747324
...
...
@@ -29,11 +29,6 @@ def writelog(path,log):
f
=
open
(
path
,
'a+'
)
f
.
write
(
log
+
'
\n
'
)
# def del_all(dir_path):
# files = Traversal(dir_path)
# for file in files:
# os.remove(file)
# os.removedirs(dir_path)
def
clean_tempfiles
(
tmp_init
=
True
):
if
os
.
path
.
isdir
(
'./tmp'
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录