Ejemplo n.º 1
0
output_dir = './output/'
model_name = os.path.basename(model_path).split('.')[0]
file_results = os.path.join(output_dir,'results_' + model_name + '_.txt')
if not os.path.exists(output_dir):
    os.mkdir(output_dir)
output_dir = os.path.join(output_dir, 'density_maps_' + model_name)
if not os.path.exists(output_dir):
    os.mkdir(output_dir)


net = CrowdCounter()
      
trained_model = os.path.join(model_path)
network.load_net(trained_model, net)
net.cuda()
net.eval()
mae = 0.0
mse = 0.0

#load test data
data_loader = ImageDataLoader(data_path, gt_csv_path, shuffle=False, gt_downsample=True, pre_load=True)

#load test data gt
gt_files = os.listdir(gt_path)
gt_files.sort()

for i, blob in enumerate(data_loader):                        
    im_data = blob['data']
    gt_data = blob['gt_density']
    density_map = net(im_data, gt_data)
    density_map = density_map.data.cpu().numpy()
Ejemplo n.º 2
0
def open_model(model_path):
    model = CrowdCounter()
    network.load_net(model_path, model)
    model.eval()
    return model