leuschnm commited on
Commit
18a2e37
·
1 Parent(s): d8cab4b
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -27,7 +27,7 @@ from model import SASNet
27
  warnings.filterwarnings('ignore')
28
 
29
  # define the GPU id to be used
30
- os.environ['CUDA_VISIBLE_DEVICES'] = '0'
31
 
32
  class data(Dataset):
33
  def __init__(self, img, transform=None):
@@ -63,7 +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().cuda()
 
67
  model_path = "./SHHA.pth"
68
  # load the trained model
69
  model.load_state_dict(torch.load(model_path))
@@ -74,9 +75,9 @@ def predict(img):
74
 
75
  for vi, data in enumerate(test_loader, 0):
76
  img = data
77
- img = img.cuda()
78
  pred_map = model(img)
79
- pred_map = pred_map.data.cpu().numpy()
80
  for i_img in range(pred_map.shape[0]):
81
  pred_cnt = np.sum(pred_map[i_img]) / 1000
82
 
 
27
  warnings.filterwarnings('ignore')
28
 
29
  # define the GPU id to be used
30
+ #os.environ['CUDA_VISIBLE_DEVICES'] = '0'
31
 
32
  class data(Dataset):
33
  def __init__(self, img, transform=None):
 
63
  def predict(img):
64
  """the main process of inference"""
65
  test_loader = loading_data(img)
66
+ model = SASNet()
67
+ #model = SASNet().cuda()
68
  model_path = "./SHHA.pth"
69
  # load the trained model
70
  model.load_state_dict(torch.load(model_path))
 
75
 
76
  for vi, data in enumerate(test_loader, 0):
77
  img = data
78
+ #img = img.cuda()
79
  pred_map = model(img)
80
+ #pred_map = pred_map.data.cpu().numpy()
81
  for i_img in range(pred_map.shape[0]):
82
  pred_cnt = np.sum(pred_map[i_img]) / 1000
83