Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from fastapi import FastAPI, UploadFile
|
2 |
from transformers import pipeline
|
3 |
from fastai.vision.all import *
|
|
|
4 |
|
5 |
# NOTE - we configure docs_url to serve the interactive Docs at the root path
|
6 |
# of the app. This way, we can use the docs as a landing page for the app on Spaces.
|
@@ -21,10 +22,8 @@ def generate(text: str):
|
|
21 |
return {"output": output[0]["generated_text"]}
|
22 |
|
23 |
@app.post("/uploadfile/")
|
24 |
-
async def create_upload_file(file: UploadFile):
|
25 |
request_object_content = await file.read()
|
26 |
img = Image.open(io.BytesIO(request_object_content))
|
27 |
pred, idx, probs = learn.predict(img)
|
28 |
-
return dict(zip(categories, map(float, probs)))
|
29 |
-
# pred, idx, probs = learn.predict(img)
|
30 |
-
# return dict(zip(categories, map(float, probs)))
|
|
|
1 |
from fastapi import FastAPI, UploadFile
|
2 |
from transformers import pipeline
|
3 |
from fastai.vision.all import *
|
4 |
+
from PIL import Image
|
5 |
|
6 |
# NOTE - we configure docs_url to serve the interactive Docs at the root path
|
7 |
# of the app. This way, we can use the docs as a landing page for the app on Spaces.
|
|
|
22 |
return {"output": output[0]["generated_text"]}
|
23 |
|
24 |
@app.post("/uploadfile/")
|
25 |
+
async def create_upload_file(file: UploadFile = File(...)):
|
26 |
request_object_content = await file.read()
|
27 |
img = Image.open(io.BytesIO(request_object_content))
|
28 |
pred, idx, probs = learn.predict(img)
|
29 |
+
return dict(zip(categories, map(float, probs)))
|
|
|
|