Spaces:
Runtime error
Runtime error
chenjian26
commited on
Commit
·
728800b
1
Parent(s):
2aa9050
add module files
Browse files- app.py +22 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tempfile
|
2 |
+
import os
|
3 |
+
|
4 |
+
from PIL import Image
|
5 |
+
import gradio as gr
|
6 |
+
import paddlehub as hub
|
7 |
+
|
8 |
+
|
9 |
+
module = hub.Module(name="solov2")
|
10 |
+
|
11 |
+
def inference(img, threshold):
|
12 |
+
with tempfile.TemporaryDirectory() as tempdir_name:
|
13 |
+
module.predict(image=img, threshold=threshold, visualization=True, save_dir=tempdir_name)
|
14 |
+
result_names = os.listdir(tempdir_name)
|
15 |
+
output_image = Image.open(os.path.join(tempdir_name, result_names[0]))
|
16 |
+
return [output_image]
|
17 |
+
|
18 |
+
|
19 |
+
title="SOLOv2"
|
20 |
+
description="SOLOv2 is a fast instance segmentation model based on paper \"SOLOv2: Dynamic, Faster and Stronger\". The model improves the detection performance and efficiency of masks compared to SOLOv1, and performs well in instance segmentation tasks."
|
21 |
+
|
22 |
+
gr.Interface(inference,inputs=[gr.inputs.Image(type="filepath"),gr.Slider(0.0, 1.0, value=0.5)],outputs=gr.Gallery(label="Detection Result"),title=title,description=description).launch(enable_queue=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
paddlepaddle == 2.2.0
|
2 |
+
paddlehub
|