Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
|
@@ -210,7 +210,7 @@ async def classify(image: UploadFile = File(...)):
|
|
| 210 |
else:
|
| 211 |
return {"error": "No image provided"}
|
| 212 |
|
| 213 |
-
|
| 214 |
@app.post("/multiclassify")
|
| 215 |
async def classify(image: UploadFile = File(...)):
|
| 216 |
if image is not None:
|
|
@@ -229,7 +229,7 @@ async def classify(image: UploadFile = File(...)):
|
|
| 229 |
cropped_image = cropped_image.resize((64,64))
|
| 230 |
img_array = np.array(cropped_image) / 255.0
|
| 231 |
img_array = np.expand_dims(img_array, axis=0)
|
| 232 |
-
predictions =
|
| 233 |
predicted_class_idx = np.argmax(predictions)
|
| 234 |
predicted_class_idx = int(predicted_class_idx)
|
| 235 |
|
|
|
|
| 210 |
else:
|
| 211 |
return {"error": "No image provided"}
|
| 212 |
|
| 213 |
+
yolomodel = YOLO("yolo11m.pt")
|
| 214 |
@app.post("/multiclassify")
|
| 215 |
async def classify(image: UploadFile = File(...)):
|
| 216 |
if image is not None:
|
|
|
|
| 229 |
cropped_image = cropped_image.resize((64,64))
|
| 230 |
img_array = np.array(cropped_image) / 255.0
|
| 231 |
img_array = np.expand_dims(img_array, axis=0)
|
| 232 |
+
predictions = yolomodel.predict(img_array)
|
| 233 |
predicted_class_idx = np.argmax(predictions)
|
| 234 |
predicted_class_idx = int(predicted_class_idx)
|
| 235 |
|