PFLD-pytorch
PFLD-pytorch copied to clipboard
Out-of-Range Value for Landmarks
I am testing your model and the result looks pretty weird, some values are more than 1, so when multiply by 112, the value is out of the range [0, 112].
Here are my code
import torch
from torch.utils.data import DataLoader
from torchvision import transforms as tvTransforms
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
source_code = '../input/d/hariwh0/facial-landmark'
sys.path.append(source_code)
from dataset.datasets import WLFWDatasets
from models.pfld import PFLDInference
model_path = source_code + '/checkpoint/snapshot/checkpoint.pth.tar'
checkpoint = torch.load(model_path, map_location=device)
backbone = PFLDInference().to(device)
backbone.load_state_dict(checkpoint['pfld_backbone'])
backbone = backbone.to(device)
transform = tvTransforms.Compose([tvTransforms.ToTensor()])
face_path = '../input/vn-celeb/VN-celeb/1019/11.png'
face = Image.open(face_path)
face = face.resize((112, 112))
face_arr = np.array(face.getdata()).T.reshape((112,112,-1))
face_arr = face_arr / 255
face_arr = transform(face_arr).unsqueeze(0)
face_arr = face_arr.type(torch.float)
face_arr = face_arr.to(device)
_, landmarks = backbone(face_arr)
landmarks = landmarks.detach().numpy()
landmarks = landmarks.reshape(landmarks.shape[0], -1, 2)
face_landmarks = landmarks[0] * [112, 112]
face_landmarks = face_landmarks.astype(int).tolist()
You can see in the result that many values are larger than 112. Please show me where I am wrong, thank you in advance!!!
[[64, 168], [59, 169], [59, 156], [59, 167], [56, 176], [71, 181], [54, 180], [65, 195], [69, 198], [83, 191], [75, 191], [87, 198], [90, 173], [88, 190], [111, 188], [107, 184], [108, 219], [122, 213], [137, 233], [171, 233], [176, 228], [190, 226], [199, 198], [202, 191], [201, 187], [205, 179], [210, 152], [217, 143], [204, 127], [206, 118], [192, 99], [179, 99], [170, 85], [25, 139], [26, 112], [36, 96], [45, 75], [71, 83], [67, 82], [52, 92], [45, 103], [36, 112], [91, 67], [109, 62], [126, 65], [144, 62], [156, 79], [148, 71], [138, 62], [108, 71], [107, 68], [98, 97], [116, 121], [104, 140], [112, 156], [110, 161], [109, 165], [118, 150], [141, 149], [145, 146], [53, 123], [59, 129], [59, 123], [59, 108], [83, 114], [70, 119], [73, 126], [57, 129], [135, 108], [133, 95], [128, 93], [157, 94], [159, 90], [146, 96], [149, 93], [140, 105], [130, 171], [114, 171], [120, 156], [113, 155], [125, 153], [159, 148], [179, 153], [165, 165], [142, 188], [131, 203], [126, 192], [130, 171], [113, 185], [115, 154], [122, 158], [157, 153], [182, 155], [136, 181], [127, 196], [120, 201], [62, 124], [136, 95]]
You can found the image in folder 1019 picture 11.png at https://www.kaggle.com/hariwu1995/vn-celeb/