INNER CODE UNIT · Python
predict
minivision-ai/Silent-Face-Anti-Spoofing · src/anti_spoof_predict.py:81
def predict(self, img, model_path):
test_transform = trans.Compose([
trans.ToTensor(),
])
img = test_transform(img)
img = img.unsqueeze(0).to(self.device)
self._load_model(model_path)
self.model.eval()
with torch.no_grad():
result = self.model.forward(img)
result = F.softmax(result).cpu().numpy()
return result