Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, File, UploadFile
|
| 2 |
+
from gradio_client import Client, handle_file
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
client = Client("Myloiose/mobilenetv1-tflite-demo")
|
| 6 |
+
|
| 7 |
+
@app.post("/predict")
|
| 8 |
+
async def predict(file: UploadFile = File(...)):
|
| 9 |
+
tmp = f"/tmp/{file.filename}"
|
| 10 |
+
with open(tmp, "wb") as f:
|
| 11 |
+
f.write(await file.read())
|
| 12 |
+
result = client.predict(image=handle_file(tmp), api_name="/predict")
|
| 13 |
+
return {"result": result}
|