Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
|
@@ -78,23 +78,21 @@ def detect_hands(image):
|
|
| 78 |
|
| 79 |
return subImgs
|
| 80 |
|
| 81 |
-
def predict(image):
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
|
| 88 |
# Prediction function
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
# print(predicted_label)
|
| 97 |
-
# return predicted_label
|
| 98 |
|
| 99 |
@app.post("/ipredict")
|
| 100 |
async def ipredict(image: UploadFile = File(...)):
|
|
|
|
| 78 |
|
| 79 |
return subImgs
|
| 80 |
|
| 81 |
+
# def predict(image):
|
| 82 |
+
# img = image.astype("float32") / 255.0
|
| 83 |
+
# img = np.expand_dims(img, axis=0)
|
| 84 |
+
# pred = model.predict(img, verbose=0)
|
| 85 |
+
# label = label_encoder.inverse_transform([np.argmax(pred)])[0]
|
| 86 |
+
# return label
|
| 87 |
|
| 88 |
# Prediction function
|
| 89 |
+
def predict(image):
|
| 90 |
+
img = cv2.resize(image, (64, 64))
|
| 91 |
+
img = np.expand_dims(img, axis=0) # Add batch dimension
|
| 92 |
+
prediction = model.predict(img, verbose=0)
|
| 93 |
+
predicted_class = np.argmax(prediction)
|
| 94 |
+
predicted_label = label_encoder.classes_[predicted_class]
|
| 95 |
+
return predicted_label
|
|
|
|
|
|
|
| 96 |
|
| 97 |
@app.post("/ipredict")
|
| 98 |
async def ipredict(image: UploadFile = File(...)):
|