Last active
January 27, 2020 15:37
-
-
Save cosmic-cortex/4e90715a8c8f0624f7e8e2ad3ff95060 to your computer and use it in GitHub Desktop.
predict endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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