未验证 提交 32dbb01a 编写于 作者: jm_12138's avatar jm_12138 提交者: GitHub

add deoldify gradio app (#2158)

上级 01740e0e
...@@ -162,6 +162,8 @@ ...@@ -162,6 +162,8 @@
cv2.imwrite('/PATH/TO/SAVE/IMAGE', img) cv2.imwrite('/PATH/TO/SAVE/IMAGE', img)
``` ```
- ### Gradio APP 支持
从 PaddleHub 2.3.1 开始支持使用链接 http://127.0.0.1:8866/gradio/deoldify 在浏览器中访问 deoldify 的 Gradio APP。
## 五、更新历史 ## 五、更新历史
...@@ -177,6 +179,10 @@ ...@@ -177,6 +179,10 @@
移除 Fluid API 移除 Fluid API
* 1.2.0
添加 Gradio APP 支持
```shell ```shell
$ hub install deoldify == 1.1.0 $ hub install deoldify == 1.2.0
``` ```
...@@ -161,6 +161,8 @@ ...@@ -161,6 +161,8 @@
cv2.imwrite('/PATH/TO/SAVE/IMAGE', img) cv2.imwrite('/PATH/TO/SAVE/IMAGE', img)
``` ```
- ### Gradio APP support
Starting with PaddleHub 2.3.1, the Gradio APP for deoldify is supported to be accessed in the browser using the link http://127.0.0.1:8866/gradio/deoldify.
## V. Release Note ## V. Release Note
...@@ -176,6 +178,10 @@ ...@@ -176,6 +178,10 @@
Remove Fluid API Remove Fluid API
* 1.2.0
Add Gradio APP support
```shell ```shell
$ hub install deoldify == 1.1.0 $ hub install deoldify == 1.2.0
``` ```
...@@ -33,7 +33,7 @@ from paddlehub.module.module import serving ...@@ -33,7 +33,7 @@ from paddlehub.module.module import serving
author="paddlepaddle", author="paddlepaddle",
author_email="", author_email="",
summary="Deoldify is a colorizaton model", summary="Deoldify is a colorizaton model",
version="1.1.0") version="1.2.0")
class DeOldifyPredictor(nn.Layer): class DeOldifyPredictor(nn.Layer):
def __init__(self, render_factor: int = 32, output_path: int = 'output', load_checkpoint: str = None): def __init__(self, render_factor: int = 32, output_path: int = 'output', load_checkpoint: str = None):
...@@ -163,3 +163,18 @@ class DeOldifyPredictor(nn.Layer): ...@@ -163,3 +163,18 @@ class DeOldifyPredictor(nn.Layer):
results = self.run_image(img=images_decode) results = self.run_image(img=images_decode)
results = U.cv2_to_base64(results) results = U.cv2_to_base64(results)
return results return results
def create_gradio_app(self):
import gradio as gr
def inference(image):
img, _ = self.predict(image.name)
return img
title = "DeOldify"
interface = gr.Interface(inference,
inputs=gr.inputs.Image(type="file"),
outputs=gr.outputs.Image(type="numpy"),
title=title,
allow_flagging='never')
return interface
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册