FSGAN은 제일 좋은게 그냥 inference만 하면 되니까 training 따로 할 필요도 없고 한 30분이면
15초짜리 영상은 그냥 얼굴 합성을 할 수 있다는 거 ( source도 한 10~20초라고 할 때)
그런데 거지같은 코랩이 pro로 돈을 낸다고 해도 자꾸 cuda 메모리가 부족하다나 어쩐다나;;;
그러면서 뜨는 에러 문구를 보면 몇기가를 할당했는데 몇기가가 남았고 얼마나 필요해서 부족해;; 라고 하는데
그 말이 매번 바뀌고 지금 분명 GPU가 넉넉따리한데도 나 못해;;;하면서 돌다가 끊겨버림;
import os
from fsgan.inference.swap import FaceSwapping
from fsgan.criterions.vgg_loss import VGGLoss
#@markdown This step should only be done once unless one of the
#@markdown following parameters is changed:
#@markdown ---
#@markdown Path to the weights directory (make sure it is correct):
weights_dir = '/content/drive/My Drive/fsgan/weights' #@param {type:"string"}
#@markdown Number of finetune iterations on the source subject:
finetune_iterations = 1000 #@param {type:"slider", min:100, max:2000, step:10}
#@markdown If True, the inner part of the mouth will be removed from the segmentation:
seg_remove_mouth = True #@param {type:"boolean"}
#@markdown Segmentation batch size
seg_batch_size = 30 #@param {type:"slider", min:1, max:64, step:1}
#@markdown Inference batch size
batch_size = 30 #@param {type:"slider", min:1, max:64, step:1}
#@markdown ---
detection_model = os.path.join(weights_dir, 'v2/WIDERFace_DSFD_RES152.pth')
pose_model = os.path.join(weights_dir, 'shared/hopenet_robust_alpha1.pth')
lms_model = os.path.join(weights_dir, 'v2/hr18_wflw_landmarks.pth')
seg_model = os.path.join(weights_dir, 'v2/celeba_unet_256_1_2_segmentation_v2.pth')
reenactment_model = os.path.join(weights_dir, 'v2/nfv_msrunet_256_1_2_reenactment_v2.1.pth')
completion_model = os.path.join(weights_dir, 'v2/ijbc_msrunet_256_1_2_inpainting_v2.pth')
blending_model = os.path.join(weights_dir, 'v2/ijbc_msrunet_256_1_2_blending_v2.pth')
criterion_id_path = os.path.join(weights_dir, 'v2/vggface2_vgg19_256_1_2_id.pth')
criterion_id = VGGLoss(criterion_id_path)
face_swapping = FaceSwapping(
detection_model=detection_model, pose_model=pose_model, lms_model=lms_model,
seg_model=seg_model, reenactment_model=reenactment_model,
completion_model=completion_model, blending_model=blending_model,
criterion_id=criterion_id,
finetune=True, finetune_save=True, finetune_iterations=finetune_iterations,
seg_remove_mouth=finetune_iterations, batch_size=batch_size,
seg_batch_size=seg_batch_size, encoder_codec='mp4v')
더 여러번 실험해보면 더 늘릴 수도 있고 영상마다 좀 다르겠지만 소스 파일 20초 (720p), 타겟 파일 14초 (720p)일 때 iter=1000, batch size=30 까지 늘릴 수 있음. 근데 사실 원래가 각각 800, 8인데 이렇게 늘려도 육안상 성능이 향상되는지는 모르겠음 ㅡㅡ;;
'Project > AI_Human(GAN)' 카테고리의 다른 글
[AI Human 5] FSGAN inference 성능 높이기 간단 팁 (0) | 2021.11.04 |
---|---|
[AI Human 3] FSGAN으로 딥페이크 얼굴 영상합성 (ffmpeg 모듈 충돌 해결) (0) | 2021.11.02 |
[AI Human 2] StarGAN Voice Conversion 모델 사용하여 음성 합성하기 (0) | 2021.11.02 |
[AI Human 1] Python 음성데이터 (wav 파일) 길이 분포 알아보기 (0) | 2021.11.02 |