Shisho_Sama:

fname = ‘cached_weights_s3fd.pt’ test_imgs = Detector.gen_fake_img(batch=1) traced = torch.jit.trace(self.detector, test_imgs, check_trace=False) script = traced.save(fname) self.detector = torch.jit.load(fname)


The cached weights are not generated, it fails before that.
You can replicate  the issue by cloning this repo : https://github.com/1adrianb/face-alignment 5
and running this snippet :
import face_alignment
import torch
import torchvision as tv

def gen_fake_img(samples=1000, batch=10, image_size=(3, 224, 224), num_classes=2):
        fake_dt = tv.datasets.FakeData(samples,
                             image_size, num_classes,
                             tv.transforms.ToTensor())
        dt_ldr = torch.utils.data.DataLoader(fake_dt, batch, pin_memory=True)
        sample_imgs, _ = next(iter(dt_ldr))
        return sample_imgs

detector = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, device='cpu')

fname = 'cached_weights_s3fd.pt'
test_imgs = gen_fake_img(batch=1)
traced = torch.jit.trace(detector, test_imgs, check_trace=False)
script = traced.save(fname)
detector = torch.jit.load(fname)

fa.get_landmarks('test/assets/aflw-test.jpg')