CapstoneFastAPI / app /routes /predict.py
AlekhyaC2005's picture
first commit
46fb1fc
Raw
History Blame Contribute Delete
384 Bytes
from fastapi import APIRouter, UploadFile, File
from PIL import Image
import io
from app.model.predictor import predict_image
router = APIRouter()
@router.post("/predict")
async def predict(
file: UploadFile = File(...)
):
image_bytes = await file.read()
image = Image.open(
io.BytesIO(image_bytes)
)
result = predict_image(image)
return result