Update app.py
Browse files
app.py
CHANGED
|
@@ -16,13 +16,17 @@ def preprocess_image(image):
|
|
| 16 |
return image
|
| 17 |
|
| 18 |
def predict_image(model, image):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
model.eval()
|
| 20 |
with torch.no_grad():
|
| 21 |
output = model(image)
|
| 22 |
-
|
| 23 |
_, predicted = torch.max(output.data, 1)
|
| 24 |
return predicted.item()
|
| 25 |
-
|
| 26 |
def main():
|
| 27 |
|
| 28 |
model = SimpleCNN()
|
|
|
|
| 16 |
return image
|
| 17 |
|
| 18 |
def predict_image(model, image):
|
| 19 |
+
|
| 20 |
+
if torch.sum(image) == 0:
|
| 21 |
+
return "empty image"
|
| 22 |
+
|
| 23 |
model.eval()
|
| 24 |
with torch.no_grad():
|
| 25 |
output = model(image)
|
| 26 |
+
|
| 27 |
_, predicted = torch.max(output.data, 1)
|
| 28 |
return predicted.item()
|
| 29 |
+
|
| 30 |
def main():
|
| 31 |
|
| 32 |
model = SimpleCNN()
|