diff --git a/face_analysis/bisenet_model.py b/face_analysis/bisenet_model.py index aa224dd..cfed71a 100644 --- a/face_analysis/bisenet_model.py +++ b/face_analysis/bisenet_model.py @@ -79,7 +79,7 @@ class Resnet18(nn.Module): def init_weight(self): # 优先本地骨干权重(内网离线),缺失才回退 torch model_zoo(会查缓存)。 if os.path.isfile(_LOCAL_RESNET18): - state_dict = torch.load(_LOCAL_RESNET18, map_location="cpu") + state_dict = torch.load(_LOCAL_RESNET18, map_location="cpu", weights_only=False) else: state_dict = modelzoo.load_url(resnet18_url) self_state_dict = self.state_dict() diff --git a/face_analysis/hair_segmenter.py b/face_analysis/hair_segmenter.py index ff2c05f..f0ce40a 100644 --- a/face_analysis/hair_segmenter.py +++ b/face_analysis/hair_segmenter.py @@ -52,7 +52,7 @@ class HairSegmenter: self._torch = torch self.device = _select_device(torch) self.net = BiSeNet(n_classes=N_CLASSES) - state = torch.load(weights_path, map_location="cpu") + state = torch.load(weights_path, map_location="cpu", weights_only=False) self.net.load_state_dict(state) self.net.to(self.device) self.net.eval()