Spaces:
Runtime error
Runtime error
Download app/routes/predict.py from AlekhyaC2005/CapstoneFastAPI: direct link, hf CLI and curl.
- Browser
- Download file 384 Bytes
-
https://huggingface.co/spaces/AlekhyaC2005/CapstoneFastAPI/resolve/main/app/routes/predict.py
- Command line
-
hf download hf://spaces/AlekhyaC2005/CapstoneFastAPI/app/routes/predict.py
-
curl -L -o predict.py https://huggingface.co/spaces/AlekhyaC2005/CapstoneFastAPI/resolve/main/app/routes/predict.py
384 Bytes
| from fastapi import APIRouter, UploadFile, File | |
| from PIL import Image | |
| import io | |
| from app.model.predictor import predict_image | |
| router = APIRouter() | |
| async def predict( | |
| file: UploadFile = File(...) | |
| ): | |
| image_bytes = await file.read() | |
| image = Image.open( | |
| io.BytesIO(image_bytes) | |
| ) | |
| result = predict_image(image) | |
| return result |