Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import paddlehub as hub
|
3 |
+
import cv2
|
4 |
+
|
5 |
+
model = hub.Module(name="U2Net_Portrait")
|
6 |
+
|
7 |
+
|
8 |
+
def inference(img):
|
9 |
+
result = model.Portrait_GEN(images=[cv2.imread(img)])
|
10 |
+
print(result)
|
11 |
+
return result[0][:,:,::-1]
|
12 |
+
|
13 |
+
|
14 |
+
title="U2Net_Portrait"
|
15 |
+
description="U2Net_Portrait can be used to extract face sketch results."
|
16 |
+
|
17 |
+
examples=[['groot.png']]
|
18 |
+
gr.Interface(inference,gr.inputs.Image(type="filepath"),gr.outputs.Image(type="numpy"),title=title,description=description,examples=examples).launch(enable_queue=True,cache_examples=True)
|