0
@app.post("/predict/")
async def predict(file:UploadFile = File(...)):
    bytes_str = io.BytesIO(await file.read())
    img = Image.open(bytes_str)
    img_array = np.array(img.convert('RGB'))
    img_array = cv2.resize(img_array, (1024,1024))
    img_final = np.expand_dims(img_array, axis = 0)
    pred = model.predict(img_final)

This code returns a NumPy array and I need to return it on FastAPI on an endpoint, but what could be the strategy?

0

1 Answer 1

0

Try a simple pred.tolist() to return a normal list that fastapi understands.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.