Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
|
@@ -66,7 +66,8 @@ async def analyze_image(file: UploadFile = File(...)):
|
|
| 66 |
image = Image.open(io.BytesIO(contents)).convert('RGB')
|
| 67 |
image_tensor = test_transform(image).unsqueeze(0).to(device)
|
| 68 |
except Exception as e:
|
| 69 |
-
|
|
|
|
| 70 |
|
| 71 |
with torch.no_grad():
|
| 72 |
# First verify if it's a tomato leaf
|
|
|
|
| 66 |
image = Image.open(io.BytesIO(contents)).convert('RGB')
|
| 67 |
image_tensor = test_transform(image).unsqueeze(0).to(device)
|
| 68 |
except Exception as e:
|
| 69 |
+
print(f"FAILED TO LOAD IMAGE: {e}")
|
| 70 |
+
raise HTTPException(status_code=400, detail=f"Invalid image file or unsupported format: {str(e)}")
|
| 71 |
|
| 72 |
with torch.no_grad():
|
| 73 |
# First verify if it's a tomato leaf
|