Commit
·
0e894d5
1
Parent(s):
7487aec
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
|
|
@@ -14,9 +15,9 @@ inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
|
| 14 |
|
| 15 |
# Perform image segmentation for multy class output
|
| 16 |
def query(inputs):
|
| 17 |
-
with open(inputs, "rb") as f:
|
| 18 |
-
|
| 19 |
-
response = requests.post(API_URL, headers=headers, data=
|
| 20 |
return response.json()
|
| 21 |
|
| 22 |
|
|
@@ -29,7 +30,7 @@ description = "Upload an image and get the segmentation result."
|
|
| 29 |
|
| 30 |
gr.Interface(fn=query,
|
| 31 |
inputs=inputs,
|
| 32 |
-
outputs=query(inputs
|
| 33 |
title=title,
|
| 34 |
examples=[["00_plane.jpg"], ["01_car.jpg"], ["02_bird.jpg"], ["03_cat.jpg"], ["04_deer.jpg"]],
|
| 35 |
description=description,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
+
import base64
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
|
|
|
|
| 15 |
|
| 16 |
# Perform image segmentation for multy class output
|
| 17 |
def query(inputs):
|
| 18 |
+
# with open(inputs, "rb") as f:
|
| 19 |
+
# data = f.read()
|
| 20 |
+
response = requests.post(API_URL, headers=headers, data=inputs.encode())
|
| 21 |
return response.json()
|
| 22 |
|
| 23 |
|
|
|
|
| 30 |
|
| 31 |
gr.Interface(fn=query,
|
| 32 |
inputs=inputs,
|
| 33 |
+
outputs=query(inputs),
|
| 34 |
title=title,
|
| 35 |
examples=[["00_plane.jpg"], ["01_car.jpg"], ["02_bird.jpg"], ["03_cat.jpg"], ["04_deer.jpg"]],
|
| 36 |
description=description,
|