gruhit-patel
commited on
Commit
•
c4684e7
1
Parent(s):
d4b5c06
Backend bugfix
Browse files- backend.py +4 -3
backend.py
CHANGED
@@ -5,6 +5,7 @@ from fastapi import FastAPI, UploadFile, File
|
|
5 |
import json
|
6 |
from PIL import Image
|
7 |
from io import BytesIO
|
|
|
8 |
|
9 |
from model import get_model
|
10 |
|
@@ -40,7 +41,7 @@ def get_prediction(image):
|
|
40 |
label = np.argmax(probs)
|
41 |
|
42 |
return {
|
43 |
-
'pred_probs':
|
44 |
'label': int(label)
|
45 |
}
|
46 |
|
@@ -52,8 +53,8 @@ def foo():
|
|
52 |
|
53 |
|
54 |
@app.post("/get_prediction")
|
55 |
-
async def predict(
|
56 |
-
image = load_image(await
|
57 |
|
58 |
image = preprocess(image)
|
59 |
result = get_prediction(image)
|
|
|
5 |
import json
|
6 |
from PIL import Image
|
7 |
from io import BytesIO
|
8 |
+
import numpy as np
|
9 |
|
10 |
from model import get_model
|
11 |
|
|
|
41 |
label = np.argmax(probs)
|
42 |
|
43 |
return {
|
44 |
+
'pred_probs': probs.tolist(),
|
45 |
'label': int(label)
|
46 |
}
|
47 |
|
|
|
53 |
|
54 |
|
55 |
@app.post("/get_prediction")
|
56 |
+
async def predict(face_img: UploadFile = File(...)):
|
57 |
+
image = load_image(await face_img.read())
|
58 |
|
59 |
image = preprocess(image)
|
60 |
result = get_prediction(image)
|