RizwanMunawar / yolov7-pose-estimation

YOLOv7 Pose estimation using OpenCV, PyTorch
GNU General Public License v3.0
344 stars 82 forks source link

Potentially redundant code in image-> tensor conversion? #26

Open mazatov opened 1 year ago

mazatov commented 1 year ago

I was a bit confused by the lines 62,63 in your code line 62

Seems like you are converting from numpy to tensor, back to numpy, and then back to tensor. Wouldn't there by an easier way to do this?

    image = transforms.ToTensor()(image)
    image = torch.tensor(np.array([image.numpy()]))

Would this achieve the same?

image = torch.tensor(np.expand_dims(np.rollaxis(image,2)/255.0, -1))

Also is the first dimension of the image, batch? Could we technically pass multiple images here?