Stefano5699 commited on
Commit
79ca19a
·
verified ·
1 Parent(s): 3d560b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
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)))