Update app.py
Browse files
app.py
CHANGED
|
@@ -63,8 +63,8 @@ def loading_data(img):
|
|
| 63 |
def predict(img):
|
| 64 |
"""the main process of inference"""
|
| 65 |
test_loader = loading_data(img)
|
| 66 |
-
model = SASNet()
|
| 67 |
-
|
| 68 |
model_path = "./SHHA.pth"
|
| 69 |
# load the trained model
|
| 70 |
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
|
|
@@ -76,8 +76,9 @@ def predict(img):
|
|
| 76 |
for vi, data in enumerate(test_loader, 0):
|
| 77 |
img = data
|
| 78 |
#img = img.cuda()
|
|
|
|
| 79 |
pred_map = model(img)
|
| 80 |
-
|
| 81 |
for i_img in range(pred_map.shape[0]):
|
| 82 |
pred_cnt = np.sum(pred_map[i_img]) / 1000
|
| 83 |
|
|
|
|
| 63 |
def predict(img):
|
| 64 |
"""the main process of inference"""
|
| 65 |
test_loader = loading_data(img)
|
| 66 |
+
#model = SASNet()
|
| 67 |
+
model = SASNet().cpu()
|
| 68 |
model_path = "./SHHA.pth"
|
| 69 |
# load the trained model
|
| 70 |
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
|
|
|
|
| 76 |
for vi, data in enumerate(test_loader, 0):
|
| 77 |
img = data
|
| 78 |
#img = img.cuda()
|
| 79 |
+
img = img.cpu()
|
| 80 |
pred_map = model(img)
|
| 81 |
+
pred_map = pred_map.data.cpu().numpy()
|
| 82 |
for i_img in range(pred_map.shape[0]):
|
| 83 |
pred_cnt = np.sum(pred_map[i_img]) / 1000
|
| 84 |
|