Sapphire-356 commited on
Commit
aa34300
·
1 Parent(s): d5c573d

Change to the CPU version

Browse files
common/inference_3d.py CHANGED
@@ -21,7 +21,7 @@ def get_varialbe(target):
21
  var = []
22
 
23
  for i in range(num):
24
- temp = Variable(target[i]).contiguous().cuda().type(torch.cuda.FloatTensor)
25
  var.append(temp)
26
 
27
  return var
@@ -59,12 +59,12 @@ def step(opt, dataLoader, model, optimizer=None, epoch=None):
59
  out = []
60
  for _, batch, batch_2d, batch_2d_flip in dataLoader.next_epoch():
61
  #[gt_3D, input_2D] = get_varialbe([batch, batch_2d])
62
- #input_2D = Variable(batch_2d).contiguous().cuda().type(torch.cuda.FloatTensor)
63
  input_2D = torch.from_numpy(batch_2d.astype('float32'))
64
  input_2D_flip = torch.from_numpy(batch_2d_flip.astype('float32'))
65
  if torch.cuda.is_available():
66
- input_2D = input_2D.cuda()
67
- input_2D_flip = input_2D_flip.cuda()
68
 
69
  N = input_2D.size(0)
70
 
 
21
  var = []
22
 
23
  for i in range(num):
24
+ temp = Variable(target[i]).contiguous().type(torch.cuda.FloatTensor)
25
  var.append(temp)
26
 
27
  return var
 
59
  out = []
60
  for _, batch, batch_2d, batch_2d_flip in dataLoader.next_epoch():
61
  #[gt_3D, input_2D] = get_varialbe([batch, batch_2d])
62
+ #input_2D = Variable(batch_2d).contiguous().type(torch.cuda.FloatTensor)
63
  input_2D = torch.from_numpy(batch_2d.astype('float32'))
64
  input_2D_flip = torch.from_numpy(batch_2d_flip.astype('float32'))
65
  if torch.cuda.is_available():
66
+ input_2D = input_2D
67
+ input_2D_flip = input_2D_flip
68
 
69
  N = input_2D.size(0)
70
 
common/utils.py CHANGED
@@ -184,7 +184,7 @@ def evaluate(test_generator, model_pos, action=None, return_predictions=False):
184
  for _, batch, batch_2d in test_generator.next_epoch():
185
  inputs_2d = torch.from_numpy(batch_2d.astype('float32'))
186
  if torch.cuda.is_available():
187
- inputs_2d = inputs_2d.cuda()
188
  # Positional model
189
  predicted_3d_pos = model_pos(inputs_2d)
190
  if test_generator.augment_enabled():
 
184
  for _, batch, batch_2d in test_generator.next_epoch():
185
  inputs_2d = torch.from_numpy(batch_2d.astype('float32'))
186
  if torch.cuda.is_available():
187
+ inputs_2d = inputs_2d
188
  # Positional model
189
  predicted_3d_pos = model_pos(inputs_2d)
190
  if test_generator.augment_enabled():
joints_detectors/Alphapose/SPPE/src/main_fast_inference.py CHANGED
@@ -24,7 +24,7 @@ class InferenNet(nn.Module):
24
  def __init__(self, kernel_size, dataset):
25
  super(InferenNet, self).__init__()
26
 
27
- model = createModel().cuda()
28
  print('Loading pose model from {}'.format('joints_detectors/Alphapose/models/sppe/duc_se.pth'))
29
  sys.stdout.flush()
30
  model.load_state_dict(torch.load('joints_detectors/Alphapose/models/sppe/duc_se.pth'))
@@ -52,7 +52,7 @@ class InferenNet_fast(nn.Module):
52
  def __init__(self, kernel_size, dataset):
53
  super(InferenNet_fast, self).__init__()
54
 
55
- model = createModel().cuda()
56
  print('Loading pose model from {}'.format('models/sppe/duc_se.pth'))
57
  model.load_state_dict(torch.load('models/sppe/duc_se.pth'))
58
  model.eval()
 
24
  def __init__(self, kernel_size, dataset):
25
  super(InferenNet, self).__init__()
26
 
27
+ model = createModel()
28
  print('Loading pose model from {}'.format('joints_detectors/Alphapose/models/sppe/duc_se.pth'))
29
  sys.stdout.flush()
30
  model.load_state_dict(torch.load('joints_detectors/Alphapose/models/sppe/duc_se.pth'))
 
52
  def __init__(self, kernel_size, dataset):
53
  super(InferenNet_fast, self).__init__()
54
 
55
+ model = createModel()
56
  print('Loading pose model from {}'.format('models/sppe/duc_se.pth'))
57
  model.load_state_dict(torch.load('models/sppe/duc_se.pth'))
58
  model.eval()
joints_detectors/Alphapose/SPPE/src/utils/img.py CHANGED
@@ -333,7 +333,7 @@ def flip(x):
333
 
334
  x = torch.from_numpy(x.copy())
335
  if is_cuda:
336
- x = x.cuda()
337
  return x
338
 
339
 
 
333
 
334
  x = torch.from_numpy(x.copy())
335
  if is_cuda:
336
+ x = x
337
  return x
338
 
339
 
joints_detectors/Alphapose/dataloader.py CHANGED
@@ -277,7 +277,7 @@ class DetectionLoader:
277
  self.det_inp_dim = int(self.det_model.net_info['height'])
278
  assert self.det_inp_dim % 32 == 0
279
  assert self.det_inp_dim > 32
280
- self.det_model.cuda()
281
  self.det_model.eval()
282
 
283
  self.stopped = False
@@ -318,7 +318,7 @@ class DetectionLoader:
318
 
319
  with torch.no_grad():
320
  # Human Detection
321
- img = img.cuda()
322
  prediction = self.det_model(img, CUDA=True)
323
  # NMS process
324
  dets = dynamic_write_results(prediction, opt.confidence,
@@ -435,7 +435,7 @@ class VideoDetectionLoader:
435
  self.det_inp_dim = int(self.det_model.net_info['height'])
436
  assert self.det_inp_dim % 32 == 0
437
  assert self.det_inp_dim > 32
438
- self.det_model.cuda()
439
  self.det_model.eval()
440
 
441
  self.stream = cv2.VideoCapture(path)
@@ -493,9 +493,9 @@ class VideoDetectionLoader:
493
  ht = inp[0].size(1)
494
  wd = inp[0].size(2)
495
  # Human Detection
496
- img = Variable(torch.cat(img)).cuda()
497
  im_dim_list = torch.FloatTensor(im_dim_list).repeat(1, 2)
498
- im_dim_list = im_dim_list.cuda()
499
 
500
  prediction = self.det_model(img, CUDA=True)
501
  # NMS process
 
277
  self.det_inp_dim = int(self.det_model.net_info['height'])
278
  assert self.det_inp_dim % 32 == 0
279
  assert self.det_inp_dim > 32
280
+ self.det_model
281
  self.det_model.eval()
282
 
283
  self.stopped = False
 
318
 
319
  with torch.no_grad():
320
  # Human Detection
321
+ img = img
322
  prediction = self.det_model(img, CUDA=True)
323
  # NMS process
324
  dets = dynamic_write_results(prediction, opt.confidence,
 
435
  self.det_inp_dim = int(self.det_model.net_info['height'])
436
  assert self.det_inp_dim % 32 == 0
437
  assert self.det_inp_dim > 32
438
+ self.det_model
439
  self.det_model.eval()
440
 
441
  self.stream = cv2.VideoCapture(path)
 
493
  ht = inp[0].size(1)
494
  wd = inp[0].size(2)
495
  # Human Detection
496
+ img = Variable(torch.cat(img))
497
  im_dim_list = torch.FloatTensor(im_dim_list).repeat(1, 2)
498
+ im_dim_list = im_dim_list
499
 
500
  prediction = self.det_model(img, CUDA=True)
501
  # NMS process
joints_detectors/Alphapose/dataloader_webcam.py CHANGED
@@ -119,7 +119,7 @@ class DetectionLoader:
119
  self.det_inp_dim = int(self.det_model.net_info['height'])
120
  assert self.det_inp_dim % 32 == 0
121
  assert self.det_inp_dim > 32
122
- self.det_model.cuda()
123
  self.det_model.eval()
124
 
125
  self.stopped = False
@@ -144,7 +144,7 @@ class DetectionLoader:
144
  self.dataloder.Q.queue.clear()
145
  with torch.no_grad():
146
  # Human Detection
147
- img = img.cuda()
148
  prediction = self.det_model(img, CUDA=True)
149
  # NMS process
150
  dets = dynamic_write_results(prediction, opt.confidence,
@@ -250,7 +250,7 @@ class WebcamDetectionLoader:
250
  self.det_inp_dim = int(self.det_model.net_info['height'])
251
  assert self.det_inp_dim % 32 == 0
252
  assert self.det_inp_dim > 32
253
- self.det_model.cuda()
254
  self.det_model.eval()
255
 
256
  self.stream = cv2.VideoCapture(int(webcam))
@@ -299,9 +299,9 @@ class WebcamDetectionLoader:
299
  ht = inp[0].size(1)
300
  wd = inp[0].size(2)
301
  # Human Detection
302
- img = Variable(torch.cat(img)).cuda()
303
  im_dim_list = torch.FloatTensor(im_dim_list).repeat(1,2)
304
- im_dim_list = im_dim_list.cuda()
305
 
306
  prediction = self.det_model(img, CUDA=True)
307
  # NMS process
 
119
  self.det_inp_dim = int(self.det_model.net_info['height'])
120
  assert self.det_inp_dim % 32 == 0
121
  assert self.det_inp_dim > 32
122
+ self.det_model
123
  self.det_model.eval()
124
 
125
  self.stopped = False
 
144
  self.dataloder.Q.queue.clear()
145
  with torch.no_grad():
146
  # Human Detection
147
+ img = img
148
  prediction = self.det_model(img, CUDA=True)
149
  # NMS process
150
  dets = dynamic_write_results(prediction, opt.confidence,
 
250
  self.det_inp_dim = int(self.det_model.net_info['height'])
251
  assert self.det_inp_dim % 32 == 0
252
  assert self.det_inp_dim > 32
253
+ self.det_model
254
  self.det_model.eval()
255
 
256
  self.stream = cv2.VideoCapture(int(webcam))
 
299
  ht = inp[0].size(1)
300
  wd = inp[0].size(2)
301
  # Human Detection
302
+ img = Variable(torch.cat(img))
303
  im_dim_list = torch.FloatTensor(im_dim_list).repeat(1,2)
304
+ im_dim_list = im_dim_list
305
 
306
  prediction = self.det_model(img, CUDA=True)
307
  # NMS process
joints_detectors/Alphapose/demo.py CHANGED
@@ -44,7 +44,7 @@
44
  # pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
45
  # else:
46
  # pose_model = InferenNet(4 * 1 + 1, pose_dataset)
47
- # pose_model.cuda()
48
  # pose_model.eval()
49
  #
50
  # runtime_profile = {
@@ -79,7 +79,7 @@
79
  # num_batches = datalen // batchSize + leftover
80
  # hm = []
81
  # for j in range(num_batches):
82
- # inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)].cuda()
83
  # hm_j = pose_model(inps_j)
84
  # hm.append(hm_j)
85
  # hm = torch.cat(hm)
 
44
  # pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
45
  # else:
46
  # pose_model = InferenNet(4 * 1 + 1, pose_dataset)
47
+ # pose_model
48
  # pose_model.eval()
49
  #
50
  # runtime_profile = {
 
79
  # num_batches = datalen // batchSize + leftover
80
  # hm = []
81
  # for j in range(num_batches):
82
+ # inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)]
83
  # hm_j = pose_model(inps_j)
84
  # hm.append(hm_j)
85
  # hm = torch.cat(hm)
joints_detectors/Alphapose/gene_npz.py CHANGED
@@ -122,7 +122,7 @@ def handle_video(video_file):
122
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
123
  else:
124
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
125
- pose_model.cuda()
126
  pose_model.eval()
127
  runtime_profile = {
128
  'dt': [],
@@ -159,7 +159,7 @@ def handle_video(video_file):
159
  num_batches = datalen // batchSize + leftover
160
  hm = []
161
  for j in range(num_batches):
162
- inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)].cuda()
163
  hm_j = pose_model(inps_j)
164
  hm.append(hm_j)
165
  hm = torch.cat(hm)
 
122
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
123
  else:
124
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
125
+ pose_model
126
  pose_model.eval()
127
  runtime_profile = {
128
  'dt': [],
 
159
  num_batches = datalen // batchSize + leftover
160
  hm = []
161
  for j in range(num_batches):
162
+ inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)]
163
  hm_j = pose_model(inps_j)
164
  hm.append(hm_j)
165
  hm = torch.cat(hm)
joints_detectors/Alphapose/online_demo.py CHANGED
@@ -56,7 +56,7 @@ if __name__ == "__main__":
56
  det_inp_dim = int(det_model.net_info['height'])
57
  assert det_inp_dim % 32 == 0
58
  assert det_inp_dim > 32
59
- det_model.cuda()
60
  det_model.eval()
61
 
62
  # Load pose model
@@ -65,7 +65,7 @@ if __name__ == "__main__":
65
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
66
  else:
67
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
68
- pose_model.cuda()
69
  pose_model.eval()
70
 
71
  runtime_profile = {
@@ -88,8 +88,8 @@ if __name__ == "__main__":
88
  runtime_profile['ld'].append(load_time)
89
  with torch.no_grad():
90
  # Human Detection
91
- img = Variable(img).cuda()
92
- im_dim_list = im_dim_list.cuda()
93
 
94
  prediction = det_model(img, CUDA=True)
95
  ckpt_time, det_time = getTime(ckpt_time)
@@ -120,7 +120,7 @@ if __name__ == "__main__":
120
  pt1 = torch.zeros(boxes.size(0), 2)
121
  pt2 = torch.zeros(boxes.size(0), 2)
122
  inps, pt1, pt2 = crop_from_dets(inp, boxes, inps, pt1, pt2)
123
- inps = Variable(inps.cuda())
124
 
125
  hm = pose_model(inps)
126
  ckpt_time, pose_time = getTime(ckpt_time)
 
56
  det_inp_dim = int(det_model.net_info['height'])
57
  assert det_inp_dim % 32 == 0
58
  assert det_inp_dim > 32
59
+ det_model
60
  det_model.eval()
61
 
62
  # Load pose model
 
65
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
66
  else:
67
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
68
+ pose_model
69
  pose_model.eval()
70
 
71
  runtime_profile = {
 
88
  runtime_profile['ld'].append(load_time)
89
  with torch.no_grad():
90
  # Human Detection
91
+ img = Variable(img)
92
+ im_dim_list = im_dim_list
93
 
94
  prediction = det_model(img, CUDA=True)
95
  ckpt_time, det_time = getTime(ckpt_time)
 
120
  pt1 = torch.zeros(boxes.size(0), 2)
121
  pt2 = torch.zeros(boxes.size(0), 2)
122
  inps, pt1, pt2 = crop_from_dets(inp, boxes, inps, pt1, pt2)
123
+ inps = Variable(inps)
124
 
125
  hm = pose_model(inps)
126
  ckpt_time, pose_time = getTime(ckpt_time)
joints_detectors/Alphapose/train_sppe/src/evaluation.py CHANGED
@@ -40,7 +40,7 @@ g = torch.from_numpy(gaussian(4 * 1 + 1)).clone()
40
  g = torch.unsqueeze(g, 1)
41
  g = g.repeat(17, 1, 1, 1)
42
  gaussian_kernel.weight.data = g.float()
43
- gaussian_kernel.cuda()
44
 
45
 
46
  def prediction(model):
@@ -54,7 +54,7 @@ def prediction(model):
54
 
55
  tmp_inp = {}
56
  for i, (inp, box, im_name, metaData) in enumerate(minival_loader_desc):
57
- #inp = torch.autograd.Variable(inp.cuda(), volatile=True)
58
  pt1, pt2, ori_inp = metaData
59
  #with torch.autograd.profiler.profile(use_cuda=True) as prof:
60
  if im_name[0] in tmp_inp.keys():
 
40
  g = torch.unsqueeze(g, 1)
41
  g = g.repeat(17, 1, 1, 1)
42
  gaussian_kernel.weight.data = g.float()
43
+ gaussian_kernel
44
 
45
 
46
  def prediction(model):
 
54
 
55
  tmp_inp = {}
56
  for i, (inp, box, im_name, metaData) in enumerate(minival_loader_desc):
57
+ #inp = torch.autograd.Variable(inp, volatile=True)
58
  pt1, pt2, ori_inp = metaData
59
  #with torch.autograd.profiler.profile(use_cuda=True) as prof:
60
  if im_name[0] in tmp_inp.keys():
joints_detectors/Alphapose/train_sppe/src/train.py CHANGED
@@ -25,9 +25,9 @@ def train(train_loader, m, criterion, optimizer, writer):
25
  train_loader_desc = tqdm(train_loader)
26
 
27
  for i, (inps, labels, setMask, imgset) in enumerate(train_loader_desc):
28
- inps = inps.cuda().requires_grad_()
29
- labels = labels.cuda()
30
- setMask = setMask.cuda()
31
  out = m(inps)
32
 
33
  loss = criterion(out.mul(setMask), labels)
@@ -68,9 +68,9 @@ def valid(val_loader, m, criterion, optimizer, writer):
68
  val_loader_desc = tqdm(val_loader)
69
 
70
  for i, (inps, labels, setMask, imgset) in enumerate(val_loader_desc):
71
- inps = inps.cuda()
72
- labels = labels.cuda()
73
- setMask = setMask.cuda()
74
 
75
  with torch.no_grad():
76
  out = m(inps)
@@ -109,7 +109,7 @@ def valid(val_loader, m, criterion, optimizer, writer):
109
  def main():
110
 
111
  # Model Initialize
112
- m = createModel().cuda()
113
  if opt.loadModel:
114
  print('Loading Model from {}'.format(opt.loadModel))
115
  m.load_state_dict(torch.load(opt.loadModel))
@@ -128,7 +128,7 @@ def main():
128
  os.mkdir("../exp/{}".format(opt.dataset))
129
  os.mkdir("../exp/{}/{}".format(opt.dataset, opt.expID))
130
 
131
- criterion = torch.nn.MSELoss().cuda()
132
 
133
  if opt.optMethod == 'rmsprop':
134
  optimizer = torch.optim.RMSprop(m.parameters(),
@@ -158,7 +158,7 @@ def main():
158
  val_dataset, batch_size=opt.validBatch, shuffle=False, num_workers=opt.nThreads, pin_memory=True)
159
 
160
  # Model Transfer
161
- m = torch.nn.DataParallel(m).cuda()
162
 
163
  # Start Training
164
  for i in range(opt.nEpochs):
 
25
  train_loader_desc = tqdm(train_loader)
26
 
27
  for i, (inps, labels, setMask, imgset) in enumerate(train_loader_desc):
28
+ inps = inps.requires_grad_()
29
+ labels = labels
30
+ setMask = setMask
31
  out = m(inps)
32
 
33
  loss = criterion(out.mul(setMask), labels)
 
68
  val_loader_desc = tqdm(val_loader)
69
 
70
  for i, (inps, labels, setMask, imgset) in enumerate(val_loader_desc):
71
+ inps = inps
72
+ labels = labels
73
+ setMask = setMask
74
 
75
  with torch.no_grad():
76
  out = m(inps)
 
109
  def main():
110
 
111
  # Model Initialize
112
+ m = createModel()
113
  if opt.loadModel:
114
  print('Loading Model from {}'.format(opt.loadModel))
115
  m.load_state_dict(torch.load(opt.loadModel))
 
128
  os.mkdir("../exp/{}".format(opt.dataset))
129
  os.mkdir("../exp/{}/{}".format(opt.dataset, opt.expID))
130
 
131
+ criterion = torch.nn.MSELoss()
132
 
133
  if opt.optMethod == 'rmsprop':
134
  optimizer = torch.optim.RMSprop(m.parameters(),
 
158
  val_dataset, batch_size=opt.validBatch, shuffle=False, num_workers=opt.nThreads, pin_memory=True)
159
 
160
  # Model Transfer
161
+ m = torch.nn.DataParallel(m)
162
 
163
  # Start Training
164
  for i in range(opt.nEpochs):
joints_detectors/Alphapose/train_sppe/src/utils/img.py CHANGED
@@ -208,7 +208,7 @@ def flip(x):
208
  np.fliplr(np.transpose(x[i], (0, 2, 1))), (0, 2, 1))
209
  x = torch.from_numpy(x.copy())
210
  if is_cuda:
211
- x = x.cuda()
212
  return x
213
 
214
 
 
208
  np.fliplr(np.transpose(x[i], (0, 2, 1))), (0, 2, 1))
209
  x = torch.from_numpy(x.copy())
210
  if is_cuda:
211
+ x = x
212
  return x
213
 
214
 
joints_detectors/Alphapose/video_demo.py CHANGED
@@ -38,7 +38,7 @@ def main(args):
38
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
39
  else:
40
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
41
- pose_model.cuda()
42
  pose_model.eval()
43
 
44
  runtime_profile = {
@@ -73,7 +73,7 @@ def main(args):
73
  num_batches = datalen // batchSize + leftover
74
  hm = []
75
  for j in range(num_batches):
76
- inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)].cuda()
77
  hm_j = pose_model(inps_j)
78
  hm.append(hm_j)
79
  hm = torch.cat(hm)
 
38
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
39
  else:
40
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
41
+ pose_model
42
  pose_model.eval()
43
 
44
  runtime_profile = {
 
73
  num_batches = datalen // batchSize + leftover
74
  hm = []
75
  for j in range(num_batches):
76
+ inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)]
77
  hm_j = pose_model(inps_j)
78
  hm.append(hm_j)
79
  hm = torch.cat(hm)
joints_detectors/Alphapose/webcam_demo.py CHANGED
@@ -45,7 +45,7 @@ if __name__ == "__main__":
45
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
46
  else:
47
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
48
- pose_model.cuda()
49
  pose_model.eval()
50
 
51
  # Data writer
@@ -82,7 +82,7 @@ if __name__ == "__main__":
82
  num_batches = datalen // batchSize + leftover
83
  hm = []
84
  for j in range(num_batches):
85
- inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)].cuda()
86
  hm_j = pose_model(inps_j)
87
  hm.append(hm_j)
88
  hm = torch.cat(hm)
 
45
  pose_model = InferenNet_fast(4 * 1 + 1, pose_dataset)
46
  else:
47
  pose_model = InferenNet(4 * 1 + 1, pose_dataset)
48
+ pose_model
49
  pose_model.eval()
50
 
51
  # Data writer
 
82
  num_batches = datalen // batchSize + leftover
83
  hm = []
84
  for j in range(num_batches):
85
+ inps_j = inps[j * batchSize:min((j + 1) * batchSize, datalen)]
86
  hm_j = pose_model(inps_j)
87
  hm.append(hm_j)
88
  hm = torch.cat(hm)
joints_detectors/Alphapose/yolo/bbox.py CHANGED
@@ -66,7 +66,7 @@ def bbox_iou(box1, box2):
66
 
67
  #Intersection area
68
 
69
- inter_area = torch.max(inter_rect_x2 - inter_rect_x1 + 1,torch.zeros(inter_rect_x2.shape).cuda())*torch.max(inter_rect_y2 - inter_rect_y1 + 1, torch.zeros(inter_rect_x2.shape).cuda())
70
 
71
  #Union Area
72
  b1_area = (b1_x2 - b1_x1 + 1)*(b1_y2 - b1_y1 + 1)
 
66
 
67
  #Intersection area
68
 
69
+ inter_area = torch.max(inter_rect_x2 - inter_rect_x1 + 1,torch.zeros(inter_rect_x2.shape))*torch.max(inter_rect_y2 - inter_rect_y1 + 1, torch.zeros(inter_rect_x2.shape))
70
 
71
  #Union Area
72
  b1_area = (b1_x2 - b1_x1 + 1)*(b1_y2 - b1_y1 + 1)
joints_detectors/Alphapose/yolo/cam_demo.py CHANGED
@@ -22,7 +22,7 @@ def get_test_input(input_dim, CUDA):
22
  img_ = Variable(img_)
23
 
24
  if CUDA:
25
- img_ = img_.cuda()
26
 
27
  return img_
28
 
@@ -97,7 +97,7 @@ if __name__ == '__main__':
97
  assert inp_dim > 32
98
 
99
  if CUDA:
100
- model.cuda()
101
 
102
  model.eval()
103
 
@@ -120,8 +120,8 @@ if __name__ == '__main__':
120
 
121
 
122
  if CUDA:
123
- im_dim = im_dim.cuda()
124
- img = img.cuda()
125
 
126
 
127
  output = model(Variable(img), CUDA)
 
22
  img_ = Variable(img_)
23
 
24
  if CUDA:
25
+ img_ = img_
26
 
27
  return img_
28
 
 
97
  assert inp_dim > 32
98
 
99
  if CUDA:
100
+ model
101
 
102
  model.eval()
103
 
 
120
 
121
 
122
  if CUDA:
123
+ im_dim = im_dim
124
+ img = img
125
 
126
 
127
  output = model(Variable(img), CUDA)
joints_detectors/Alphapose/yolo/detect.py CHANGED
@@ -43,7 +43,7 @@ if __name__ == '__main__':
43
 
44
  #If there's a GPU availible, put the model on GPU
45
  if CUDA:
46
- model.cuda()
47
 
48
  #Set the model in evaluation mode
49
  model.eval()
@@ -63,13 +63,13 @@ if __name__ == '__main__':
63
  im_dim_list = torch.FloatTensor(im_dim_list).repeat(1, 2)
64
 
65
  if CUDA:
66
- im_dim_list = im_dim_list.cuda()
67
 
68
 
69
  for batch in im_batches:
70
  #load the image
71
  if CUDA:
72
- batch = batch.cuda()
73
  with torch.no_grad():
74
  prediction = model(Variable(batch), CUDA)
75
 
 
43
 
44
  #If there's a GPU availible, put the model on GPU
45
  if CUDA:
46
+ model
47
 
48
  #Set the model in evaluation mode
49
  model.eval()
 
63
  im_dim_list = torch.FloatTensor(im_dim_list).repeat(1, 2)
64
 
65
  if CUDA:
66
+ im_dim_list = im_dim_list
67
 
68
 
69
  for batch in im_batches:
70
  #load the image
71
  if CUDA:
72
+ batch = batch
73
  with torch.no_grad():
74
  prediction = model(Variable(batch), CUDA)
75
 
joints_detectors/Alphapose/yolo/util.py CHANGED
@@ -57,8 +57,8 @@ def predict_transform(prediction, inp_dim, anchors, num_classes, CUDA = True):
57
  y_offset = torch.FloatTensor(b).view(-1,1)
58
 
59
  if CUDA:
60
- x_offset = x_offset.cuda()
61
- y_offset = y_offset.cuda()
62
 
63
  x_y_offset = torch.cat((x_offset, y_offset), 1).repeat(1,num_anchors).view(-1,2).unsqueeze(0)
64
 
@@ -68,7 +68,7 @@ def predict_transform(prediction, inp_dim, anchors, num_classes, CUDA = True):
68
  anchors = torch.FloatTensor(anchors)
69
 
70
  if CUDA:
71
- anchors = anchors.cuda()
72
 
73
  anchors = anchors.repeat(grid_size*grid_size, 1).unsqueeze(0)
74
  prediction[:,:,2:4] = torch.exp(prediction[:,:,2:4])*anchors
@@ -251,8 +251,8 @@ def predict_transform_half(prediction, inp_dim, anchors, num_classes, CUDA = Tru
251
  y_offset = torch.FloatTensor(b).view(-1,1)
252
 
253
  if CUDA:
254
- x_offset = x_offset.cuda().half()
255
- y_offset = y_offset.cuda().half()
256
 
257
  x_y_offset = torch.cat((x_offset, y_offset), 1).repeat(1,num_anchors).view(-1,2).unsqueeze(0)
258
 
@@ -262,7 +262,7 @@ def predict_transform_half(prediction, inp_dim, anchors, num_classes, CUDA = Tru
262
  anchors = torch.HalfTensor(anchors)
263
 
264
  if CUDA:
265
- anchors = anchors.cuda()
266
 
267
  anchors = anchors.repeat(grid_size*grid_size, 1).unsqueeze(0)
268
  prediction[:,:,2:4] = torch.exp(prediction[:,:,2:4])*anchors
 
57
  y_offset = torch.FloatTensor(b).view(-1,1)
58
 
59
  if CUDA:
60
+ x_offset = x_offset
61
+ y_offset = y_offset
62
 
63
  x_y_offset = torch.cat((x_offset, y_offset), 1).repeat(1,num_anchors).view(-1,2).unsqueeze(0)
64
 
 
68
  anchors = torch.FloatTensor(anchors)
69
 
70
  if CUDA:
71
+ anchors = anchors
72
 
73
  anchors = anchors.repeat(grid_size*grid_size, 1).unsqueeze(0)
74
  prediction[:,:,2:4] = torch.exp(prediction[:,:,2:4])*anchors
 
251
  y_offset = torch.FloatTensor(b).view(-1,1)
252
 
253
  if CUDA:
254
+ x_offset = x_offset.half()
255
+ y_offset = y_offset.half()
256
 
257
  x_y_offset = torch.cat((x_offset, y_offset), 1).repeat(1,num_anchors).view(-1,2).unsqueeze(0)
258
 
 
262
  anchors = torch.HalfTensor(anchors)
263
 
264
  if CUDA:
265
+ anchors = anchors
266
 
267
  anchors = anchors.repeat(grid_size*grid_size, 1).unsqueeze(0)
268
  prediction[:,:,2:4] = torch.exp(prediction[:,:,2:4])*anchors
joints_detectors/Alphapose/yolo/video_demo.py CHANGED
@@ -23,7 +23,7 @@ def get_test_input(input_dim, CUDA):
23
  img_ = Variable(img_)
24
 
25
  if CUDA:
26
- img_ = img_.cuda()
27
 
28
  return img_
29
 
@@ -106,7 +106,7 @@ if __name__ == '__main__':
106
  assert inp_dim > 32
107
 
108
  if CUDA:
109
- model.cuda()
110
 
111
  model(get_test_input(inp_dim, CUDA), CUDA)
112
 
@@ -132,8 +132,8 @@ if __name__ == '__main__':
132
 
133
 
134
  if CUDA:
135
- im_dim = im_dim.cuda()
136
- img = img.cuda()
137
 
138
  with torch.no_grad():
139
  output = model(Variable(img), CUDA)
 
23
  img_ = Variable(img_)
24
 
25
  if CUDA:
26
+ img_ = img_
27
 
28
  return img_
29
 
 
106
  assert inp_dim > 32
107
 
108
  if CUDA:
109
+ model
110
 
111
  model(get_test_input(inp_dim, CUDA), CUDA)
112
 
 
132
 
133
 
134
  if CUDA:
135
+ im_dim = im_dim
136
+ img = img
137
 
138
  with torch.no_grad():
139
  output = model(Variable(img), CUDA)
joints_detectors/Alphapose/yolo/video_demo_half.py CHANGED
@@ -23,7 +23,7 @@ def get_test_input(input_dim, CUDA):
23
  img_ = Variable(img_)
24
 
25
  if CUDA:
26
- img_ = img_.cuda()
27
 
28
  return img_
29
 
@@ -107,7 +107,7 @@ if __name__ == '__main__':
107
 
108
 
109
  if CUDA:
110
- model.cuda().half()
111
 
112
  model(get_test_input(inp_dim, CUDA), CUDA)
113
 
@@ -133,8 +133,8 @@ if __name__ == '__main__':
133
 
134
 
135
  if CUDA:
136
- img = img.cuda().half()
137
- im_dim = im_dim.half().cuda()
138
  write_results = write_results_half
139
  predict_transform = predict_transform_half
140
 
 
23
  img_ = Variable(img_)
24
 
25
  if CUDA:
26
+ img_ = img_
27
 
28
  return img_
29
 
 
107
 
108
 
109
  if CUDA:
110
+ model.half()
111
 
112
  model(get_test_input(inp_dim, CUDA), CUDA)
113
 
 
133
 
134
 
135
  if CUDA:
136
+ img = img.half()
137
+ im_dim = im_dim.half()
138
  write_results = write_results_half
139
  predict_transform = predict_transform_half
140
 
model/block/refine.py CHANGED
@@ -27,7 +27,7 @@ class refine(nn.Module):
27
  x_in = x_in.view(N, -1)
28
 
29
  score = self.post_refine(x_in).view(N,T,V,2)
30
- score_cm = Variable(torch.ones(score.size()), requires_grad=False).cuda() - score
31
  x_out = x.clone()
32
  x_out[:, :, :, :2] = score * x[:, :, :, :2] + score_cm * x_1[:, :, :, :2]
33
 
 
27
  x_in = x_in.view(N, -1)
28
 
29
  score = self.post_refine(x_in).view(N,T,V,2)
30
+ score_cm = Variable(torch.ones(score.size()), requires_grad=False) - score
31
  x_out = x.clone()
32
  x_out[:, :, :, :2] = score * x[:, :, :, :2] + score_cm * x_1[:, :, :, :2]
33
 
tools/utils.py CHANGED
@@ -140,7 +140,7 @@ def videopose_model_load():
140
  chk_filename = main_path + '/checkpoint/pretrained_h36m_detectron_coco.bin'
141
  checkpoint = torch.load(chk_filename, map_location=lambda storage, loc: storage) # 把loc映射到storage
142
  model_pos = TemporalModel(17, 2, 17, filter_widths=[3, 3, 3, 3, 3], causal=False, dropout=False, channels=1024, dense=False)
143
- model_pos = model_pos.cuda()
144
  model_pos.load_state_dict(checkpoint['model_pos'])
145
  receptive_field = model_pos.receptive_field()
146
  return model_pos
 
140
  chk_filename = main_path + '/checkpoint/pretrained_h36m_detectron_coco.bin'
141
  checkpoint = torch.load(chk_filename, map_location=lambda storage, loc: storage) # 把loc映射到storage
142
  model_pos = TemporalModel(17, 2, 17, filter_widths=[3, 3, 3, 3, 3], causal=False, dropout=False, channels=1024, dense=False)
143
+ model_pos = model_pos
144
  model_pos.load_state_dict(checkpoint['model_pos'])
145
  receptive_field = model_pos.receptive_field()
146
  return model_pos
videopose_PSTMO.py CHANGED
@@ -85,11 +85,11 @@ def main(args):
85
  # dense=args.dense)
86
 
87
  model = {}
88
- model['trans'] = Model(args).cuda()
89
 
90
 
91
  # if torch.cuda.is_available():
92
- # model_pos = model_pos.cuda()
93
 
94
  ckpt, time1 = ckpt_time(time0)
95
  print('-------------- load data spends {:.2f} seconds'.format(ckpt))
 
85
  # dense=args.dense)
86
 
87
  model = {}
88
+ model['trans'] = Model(args)
89
 
90
 
91
  # if torch.cuda.is_available():
92
+ # model_pos = model_pos
93
 
94
  ckpt, time1 = ckpt_time(time0)
95
  print('-------------- load data spends {:.2f} seconds'.format(ckpt))