Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,8 @@
|
|
1 |
-
|
2 |
-
import requests
|
3 |
-
import gradio as gr
|
4 |
-
|
5 |
from fastapi import FastAPI
|
6 |
-
|
7 |
-
|
8 |
-
CUSTOM_PATH = "/gradio"
|
9 |
-
|
10 |
app = FastAPI()
|
11 |
-
|
12 |
-
|
13 |
@app.get("/")
|
14 |
def read_main():
|
15 |
return {"message": "This is your main app"}
|
16 |
-
|
17 |
-
|
18 |
-
def classify_image(filepath):
|
19 |
-
"""
|
20 |
-
Function to send image to the FastAPI server for classification
|
21 |
-
and then return the results.
|
22 |
-
"""
|
23 |
-
print("============")
|
24 |
-
url = "http://18.220.25.54/predict"
|
25 |
-
with open(filepath, "rb") as f:
|
26 |
-
response = requests.post(url, files={"file": f})
|
27 |
-
print('ζε')
|
28 |
-
return response.json()['predictions']
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
oi = gr.Interface(
|
33 |
-
fn=classify_image,
|
34 |
-
inputs=gr.Image(
|
35 |
-
shape=(224, 224), source='upload',label="Upload Image or Capture from Webcam"
|
36 |
-
,type="filepath"),
|
37 |
-
outputs=gr.Label(num_top_classes=3, label="Predicted Class")
|
38 |
-
|
39 |
-
)
|
40 |
-
|
41 |
-
app = gr.mount_gradio_app(app, oi, path=CUSTOM_PATH)
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
import gradio as gr
|
|
|
|
|
|
|
3 |
app = FastAPI()
|
|
|
|
|
4 |
@app.get("/")
|
5 |
def read_main():
|
6 |
return {"message": "This is your main app"}
|
7 |
+
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
8 |
+
app = gr.mount_gradio_app(app, io, path="/gradio")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|