answers_all / main.py
capNimo's picture
Upload 8 files
2f97760 verified
raw
history blame contribute delete
450 Bytes
from model import model_pipeline
from typing import Union
from fastapi import FastAPI, UploadFile
import io
from PIL import Image
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.post("/ask")
def ask(text: str, image: UploadFile):
photos = image.file.read()
image = Image.open(io.BytesIO(photos))
result = model_pipeline(text, image)
return {"answer": result}