YuvalNirkin / fsgan

FSGAN - Official PyTorch Implementation
https://nirkin.com/fsgan
Creative Commons Zero v1.0 Universal
754 stars 147 forks source link

Some fixes and extra steps in colab #109

Closed princessmittens closed 3 years ago

princessmittens commented 3 years ago

Fixes and changes colab notebook:

'No module named named ffmpeg' 'No module named named yacs'

!cp -r /usr/local/lib/python3.8/site-packages/yacs/ /usr/local/lib/python3.6/dist-packages/yacs/
!cp -r /usr/local/lib/python3.8/site-packages/ffmpeg-python/ /usr/local/lib/python3.6/dist-packages/ffmpeg-python/`

Note: This fix is from issue #57

'RuntimeError: Cache file does not exist: /content/data/source/source_dsfd_seq.pkl'

!mv /content/data/source/source_dsfd.pkl /content/data/source/source_dsfd_seq.pkl

Not fixes necessarily but workflow downloading model easily:

Downloading GAN models from script (my script was located in the root directory of my google drive)

!cp '/content/drive/My Drive/download_fsgan_models.py' './download_fsgan_models.py'
!python ./download_fsgan_models.py -m v2

After that you should should see this if you run !ls you should get: download_fsgan_models.py face_detection_dsfd fsgan weights

I encountered an error finding the weights files I set my path for the weights to ./weights and then removed the v2 and shared directories manually from the code block. So final result is:

detection_model = os.path.join(weights_dir, 'WIDERFace_DSFD_RES152.pth')
pose_model = os.path.join(weights_dir, 'hopenet_robust_alpha1.pth')
lms_model = os.path.join(weights_dir, 'hr18_wflw_landmarks.pth')
seg_model = os.path.join(weights_dir, 'celeba_unet_256_1_2_segmentation_v2.pth')
reenactment_model = os.path.join(weights_dir, 'nfv_msrunet_256_1_2_reenactment_v2.1.pth')
completion_model = os.path.join(weights_dir, 'ijbc_msrunet_256_1_2_inpainting_v2.pth')
blending_model = os.path.join(weights_dir, 'ijbc_msrunet_256_1_2_blending_v2.pth')
criterion_id_path = os.path.join(weights_dir, 'vggface2_vgg19_256_1_2_id.pth')
criterion_id = VGGLoss(criterion_id_path)