Skip to content

Instantly share code, notes, and snippets.

@cosmic-cortex
Last active January 27, 2020 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmic-cortex/4e90715a8c8f0624f7e8e2ad3ff95060 to your computer and use it in GitHub Desktop.
Save cosmic-cortex/4e90715a8c8f0624f7e8e2ad3ff95060 to your computer and use it in GitHub Desktop.
predict endpoint
import numpy as np
from fastapi import Depends
from .ml.model import get_model
@app.post("/predict", response_model=PredictResponse)
def predict(input: PredictRequest, model: Model = Depends(get_model)):
X = np.array(input.data)
y_pred = model.predict(X)
result = PredictResponse(data=y_pred.tolist())
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment