Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,28 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
def classify_image(filepath):
|
8 |
+
"""
|
9 |
+
Function to send image to the FastAPI server for classification
|
10 |
+
and then return the results.
|
11 |
+
"""
|
12 |
+
print("============")
|
13 |
+
url = "http://18.191.206.114/predict"
|
14 |
+
with open(filepath, "rb") as f:
|
15 |
+
response = requests.post(url, files={"file": f})
|
16 |
+
print('ζε')
|
17 |
+
return response.json()['predictions']
|
18 |
+
|
19 |
+
|
20 |
+
oi = gr.Interface(
|
21 |
+
fn=classify_image,
|
22 |
+
inputs=gr.Image(
|
23 |
+
shape=(224, 224), source='upload',label="Upload Image or Capture from Webcam"
|
24 |
+
,type="filepath"),
|
25 |
+
outputs=gr.Label(num_top_classes=3, label="Predicted Class"),
|
26 |
+
)
|
27 |
+
|
28 |
+
oi.launch()
|