Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
1af344a9
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
1 年多 前同步成功
通知
283
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1af344a9
编写于
12月 29, 2022
作者:
jm_12138
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update photo_restoration (#1998)
* update photo_restoration * add clean func
上级
524a7512
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
14 deletion
+73
-14
modules/image/Image_editing/colorization/photo_restoration/README.md
...ge/Image_editing/colorization/photo_restoration/README.md
+5
-1
modules/image/Image_editing/colorization/photo_restoration/README_en.md
...Image_editing/colorization/photo_restoration/README_en.md
+5
-1
modules/image/Image_editing/colorization/photo_restoration/module.py
...ge/Image_editing/colorization/photo_restoration/module.py
+11
-12
modules/image/Image_editing/colorization/photo_restoration/test.py
...mage/Image_editing/colorization/photo_restoration/test.py
+52
-0
未找到文件。
modules/image/Image_editing/colorization/photo_restoration/README.md
浏览文件 @
1af344a9
...
...
@@ -143,6 +143,10 @@
初始发布
*
1.
0.1
*
1.
1.0
适配paddlehub2.0版本
*
```shell
$ hub install photo_restoration==1.1.0
```
modules/image/Image_editing/colorization/photo_restoration/README_en.md
浏览文件 @
1af344a9
...
...
@@ -145,7 +145,11 @@
First release
-
1.
0.1
-
1.
1.0
Adapt to paddlehub2.0
*
```shell
$ hub install photo_restoration==1.1.0
```
modules/image/Image_editing/colorization/photo_restoration/module.py
浏览文件 @
1af344a9
...
...
@@ -18,19 +18,18 @@ import time
import
cv2
import
paddle.nn
as
nn
import
paddlehub
as
hub
from
paddlehub.module.module
import
moduleinfo
,
serving
,
Module
from
paddlehub.module.module
import
moduleinfo
,
serving
import
photo_restoration.
utils
as
U
from
.
import
utils
as
U
@
moduleinfo
(
name
=
"photo_restoration"
,
type
=
"CV/image_editing"
,
author
=
"paddlepaddle"
,
author_email
=
""
,
summary
=
"photo_restoration is a photo restoration model based on deoldify and realsr."
,
version
=
"1.0.0"
)
class
PhotoRestoreModel
(
Module
):
@
moduleinfo
(
name
=
"photo_restoration"
,
type
=
"CV/image_editing"
,
author
=
"paddlepaddle"
,
author_email
=
""
,
summary
=
"photo_restoration is a photo restoration model based on deoldify and realsr."
,
version
=
"1.1.0"
)
class
PhotoRestoreModel
(
nn
.
Layer
):
"""
PhotoRestoreModel
...
...
@@ -39,8 +38,8 @@ class PhotoRestoreModel(Module):
visualization (bool): Whether to save the estimation result. Default is True.
"""
def
_
initialize
(
self
,
visualization
:
bool
=
False
):
#
super(PhotoRestoreModel, self).__init__()
def
_
_init__
(
self
,
visualization
:
bool
=
False
):
super
(
PhotoRestoreModel
,
self
).
__init__
()
self
.
deoldify
=
hub
.
Module
(
name
=
'deoldify'
)
self
.
realsr
=
hub
.
Module
(
name
=
'realsr'
)
self
.
visualization
=
visualization
...
...
modules/image/Image_editing/colorization/photo_restoration/test.py
0 → 100644
浏览文件 @
1af344a9
import
os
import
shutil
import
unittest
import
cv2
import
requests
import
numpy
as
np
import
paddlehub
as
hub
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
'0'
class
TestHubModule
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
)
->
None
:
img_url
=
'https://unsplash.com/photos/1sLIu1XKQrY/download?ixid=MnwxMjA3fDB8MXxhbGx8MTJ8fHx8fHwyfHwxNjYyMzQxNDUx&force=true&w=640'
if
not
os
.
path
.
exists
(
'tests'
):
os
.
makedirs
(
'tests'
)
response
=
requests
.
get
(
img_url
)
assert
response
.
status_code
==
200
,
'Network Error.'
with
open
(
'tests/test.jpg'
,
'wb'
)
as
f
:
f
.
write
(
response
.
content
)
cls
.
module
=
hub
.
Module
(
name
=
"photo_restoration"
)
@
classmethod
def
tearDownClass
(
cls
)
->
None
:
shutil
.
rmtree
(
'tests'
)
shutil
.
rmtree
(
'photo_restoration'
)
def
test_run_image1
(
self
):
results
=
self
.
module
.
run_image
(
input
=
'tests/test.jpg'
)
self
.
assertIsInstance
(
results
,
np
.
ndarray
)
def
test_run_image2
(
self
):
results
=
self
.
module
.
run_image
(
input
=
cv2
.
imread
(
'tests/test.jpg'
)
)
self
.
assertIsInstance
(
results
,
np
.
ndarray
)
def
test_run_image3
(
self
):
self
.
assertRaises
(
FileNotFoundError
,
self
.
module
.
run_image
,
input
=
'no.jpg'
)
if
__name__
==
"__main__"
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录