woctezuma / SimSwap-colab

Colab notebooks to apply SimSwap to images, animated GIF, and videos.
MIT License
86 stars 19 forks source link

Gpen dont works #18

Closed nascacorp closed 11 months ago

nascacorp commented 11 months ago

Gpen on simswap colab dont works (image)

woctezuma commented 11 months ago

Right.

%cd /content/GPEN
!python demo.py --sr_scale 1

Running the cell above results in:

/content/GPEN/align_faces.py:251: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if align_type is 'cv2_affine':
/content/GPEN/align_faces.py:254: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif align_type is 'affine':
/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
  warnings.warn(
/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=None`.
  warnings.warn(msg)
Traceback (most recent call last):
  File "/content/GPEN/demo.py", line 97, in <module>
    processer = FaceEnhancement(args, in_size=args.in_size, model=args.model, use_sr=args.use_sr, device='cuda' if args.use_cuda else 'cpu')
  File "/content/GPEN/face_enhancement.py", line 17, in __init__
    self.facedetector = RetinaFaceDetection(base_dir, device)
  File "/content/GPEN/face_detect/retinaface_detection.py", line 27, in __init__
    self.load_model()
  File "/content/GPEN/face_detect/retinaface_detection.py", line 51, in load_model
    pretrained_dict = torch.load(self.pretrained_path, map_location=torch.device('cpu'))
  File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 1028, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 1246, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
EOFError: Ran out of input

The error happens at this line:

class RetinaFaceDetection(object):
    # [...]
    def load_model(self, load_to_cpu=False):
        #if load_to_cpu:
        #    pretrained_dict = torch.load(self.pretrained_path, map_location=lambda storage, loc: storage)
        #else:
        #    pretrained_dict = torch.load(self.pretrained_path, map_location=lambda storage, loc: storage.cuda())
        pretrained_dict = torch.load(self.pretrained_path, map_location=torch.device('cpu'))
    # [...]
woctezuma commented 11 months ago

As suggested in this StackOverflow answer, the pickle error arises because the model files are empty.

This is confirmed by looking at the cell where GPEN model files are downloaded and met with status code ERROR 403: Forbidden.

--2023-12-15 22:37:34--  https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/RetinaFace-R50.pth?OSSAccessKeyId=LTAI4G6bfnyW4TA4wFUXTYBe&Expires=1961116085&Signature=GlUNW6%2B8FxvxWmE9jKIZYOOciKQ%3D
Resolving public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)... 47.101.88.10
Connecting to public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)|47.101.88.10|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-12-15 22:37:35 ERROR 403: Forbidden.

--2023-12-15 22:37:35--  https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-BFR-512.pth?OSSAccessKeyId=LTAI4G6bfnyW4TA4wFUXTYBe&Expires=1961116208&Signature=hBgvVvKVSNGeXqT8glG%2Bd2t2OKc%3D
Resolving public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)... 47.101.88.10
Connecting to public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)|47.101.88.10|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-12-15 22:37:36 ERROR 403: Forbidden.

--2023-12-15 22:37:36--  https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/realesrnet_x1.pth?OSSAccessKeyId=LTAI4G6bfnyW4TA4wFUXTYBe&Expires=1968049923&Signature=omV%2Fb8Jibkgl1FggsR%2B821jQvOI%3D
Resolving public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)... 47.101.88.10
Connecting to public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)|47.101.88.10|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-12-15 22:37:37 ERROR 403: Forbidden.

--2023-12-15 22:37:37--  https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/ParseNet-latest.pth?OSSAccessKeyId=LTAI4G6bfnyW4TA4wFUXTYBe&Expires=1961116134&Signature=bnMwU1JogmNbARto6G%2B7iaJQCHs%3D
Resolving public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)... 47.101.88.10
Connecting to public-vigen-video.oss-cn-shanghai.aliyuncs.com (public-vigen-video.oss-cn-shanghai.aliyuncs.com)|47.101.88.10|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-12-15 22:37:38 ERROR 403: Forbidden.
woctezuma commented 11 months ago

Fixed.