Spaces:
Runtime error
Runtime error
Download routers/predict.py from yamunasivan/Embedded: direct link, hf CLI and curl.
- Browser
- Download file 459 Bytes
-
https://huggingface.co/spaces/yamunasivan/Embedded/resolve/main/routers/predict.py
- Command line
-
hf download hf://spaces/yamunasivan/Embedded/routers/predict.py
-
curl -L -o predict.py https://huggingface.co/spaces/yamunasivan/Embedded/resolve/main/routers/predict.py
459 Bytes
| from fastapi import APIRouter | |
| from schema.schemas import PredictionInput, PredictionOutput | |
| from service.classifier import load_model, predict | |
| router = APIRouter(prefix="/predict", tags=["Prediction"]) | |
| # Load the model once | |
| model, vectorizer = load_model() | |
| def make_prediction(input_data: PredictionInput): | |
| prediction = predict(input_data.text, model, vectorizer) | |
| return {"prediction": prediction} | |