MVIG-SJTU / AlphaPose

Real-Time and Accurate Full-Body Multi-Person Pose Estimation&Tracking System
http://mvig.org/research/alphapose.html
Other
7.84k stars 1.96k forks source link

A block of code was found that severely impacted speed #1146

Open hhwer opened 1 year ago

hhwer commented 1 year ago

In file “AlphaPose/tree/master/scripts/demo_api.py” line 255-line 258,the operation on tensors takes a long time when there are many person.

  pose_coords.append(torch.from_numpy(pose_coord).unsqueeze(0))                  
  pose_scores.append(torch.from_numpy(pose_score).unsqueeze(0))     
    preds_img = torch.cat(pose_coords)        
    preds_scores = torch.cat(pose_scores)              

Just keep the data as numpy with original shape, and use numpy.stack to combine thems will save lots of time.

  pose_coords.append(pose_coord)
  pose_scores.append(pose_score)
    preds_img = np.stack(pose_coords)
    pose_scores =np.stack(pose_scores)