Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
NNNNAI committed Jul 3, 2021
1 parent 875c48c commit 5dd24d6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from torchvision import transforms
from models.models import create_model
from options.test_options import TestOptions
from insightface_func.face_detect_crop_mutil import Face_detect_crop
from util.videoswap_mutilspecific import video_swap
from insightface_func.face_detect_crop_multi import Face_detect_crop
from util.videoswap_multispecific import video_swap
import os
import glob

Expand Down Expand Up @@ -37,7 +37,7 @@ def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0
start_epoch, epoch_iter = 1, 0
crop_size = 224

mutilsepcific_dir = opt.mutilsepcific_dir
multisepcific_dir = opt.multisepcific_dir
torch.nn.Module.dump_patches = True
model = create_model(opt)
model.eval()
Expand All @@ -49,7 +49,7 @@ def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0
# The specific person to be swapped(source)

source_specific_id_nonorm_list = []
source_path = os.path.join(mutilsepcific_dir,'source','*')
source_path = os.path.join(multisepcific_dir,'SRC_*')
source_specific_images_path = sorted(glob.glob(source_path))

for source_specific_image_path in source_specific_images_path:
Expand All @@ -68,7 +68,7 @@ def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0

# The person who provides id information (list)
target_id_norm_list = []
target_path = os.path.join(mutilsepcific_dir,'target','*')
target_path = os.path.join(multisepcific_dir,'DST_*')
target_images_path = sorted(glob.glob(target_path))

for target_image_path in target_images_path:
Expand Down
2 changes: 1 addition & 1 deletion test_video_swapmutil.py → test_video_swapmulti.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torchvision import transforms
from models.models import create_model
from options.test_options import TestOptions
from insightface_func.face_detect_crop_mutil import Face_detect_crop
from insightface_func.face_detect_crop_multi import Face_detect_crop
from util.videoswap import video_swap
import os

Expand Down
2 changes: 1 addition & 1 deletion test_video_swapspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torchvision import transforms
from models.models import create_model
from options.test_options import TestOptions
from insightface_func.face_detect_crop_mutil import Face_detect_crop
from insightface_func.face_detect_crop_multi import Face_detect_crop
from util.videoswap_specific import video_swap
import os

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torchvision import transforms
from models.models import create_model
from options.test_options import TestOptions
from insightface_func.face_detect_crop_mutil import Face_detect_crop
from insightface_func.face_detect_crop_multi import Face_detect_crop
from util.reverse2original import reverse2wholeimage
import os
from util.add_watermark import watermark_image
Expand Down Expand Up @@ -39,7 +39,7 @@ def _toarctensor(array):
start_epoch, epoch_iter = 1, 0
crop_size = 224

mutilsepcific_dir = opt.mutilsepcific_dir
multisepcific_dir = opt.multisepcific_dir

torch.nn.Module.dump_patches = True
logoclass = watermark_image('./simswaplogo/simswaplogo.png')
Expand All @@ -56,7 +56,7 @@ def _toarctensor(array):
# The specific person to be swapped(source)

source_specific_id_nonorm_list = []
source_path = os.path.join(mutilsepcific_dir,'source','*')
source_path = os.path.join(multisepcific_dir,'SRC_*')
source_specific_images_path = sorted(glob.glob(source_path))

for source_specific_image_path in source_specific_images_path:
Expand All @@ -75,7 +75,7 @@ def _toarctensor(array):

# The person who provides id information (list)
target_id_norm_list = []
target_path = os.path.join(mutilsepcific_dir,'target','*')
target_path = os.path.join(multisepcific_dir,'DST_*')
target_images_path = sorted(glob.glob(target_path))

for target_image_path in target_images_path:
Expand Down Expand Up @@ -135,7 +135,7 @@ def _toarctensor(array):

if len(swap_result_list) !=0:

reverse2wholeimage(swap_result_list, swap_result_matrix_list, crop_size, img_b_whole, logoclass, os.path.join(opt.output_path, 'result_whole_swap_mutilspecific.jpg'), opt.no_simswaplogo)
reverse2wholeimage(swap_result_list, swap_result_matrix_list, crop_size, img_b_whole, logoclass, os.path.join(opt.output_path, 'result_whole_swap_multispecific.jpg'), opt.no_simswaplogo)

print(' ')

Expand Down
4 changes: 2 additions & 2 deletions test_wholeimage_swapmutil.py → test_wholeimage_swapmulti.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torchvision import transforms
from models.models import create_model
from options.test_options import TestOptions
from insightface_func.face_detect_crop_mutil import Face_detect_crop
from insightface_func.face_detect_crop_multi import Face_detect_crop
from util.reverse2original import reverse2wholeimage
import os
from util.add_watermark import watermark_image
Expand Down Expand Up @@ -74,7 +74,7 @@ def _totensor(array):
swap_result_list.append(swap_result)


reverse2wholeimage(swap_result_list, b_mat_list, crop_size, img_b_whole, logoclass, os.path.join(opt.output_path, 'result_whole_swapmutil.jpg'),opt.no_simswaplogo)
reverse2wholeimage(swap_result_list, b_mat_list, crop_size, img_b_whole, logoclass, os.path.join(opt.output_path, 'result_whole_swapmulti.jpg'),opt.no_simswaplogo)
print(' ')

print('************ Done ! ************')
2 changes: 1 addition & 1 deletion test_wholeimage_swapspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torchvision import transforms
from models.models import create_model
from options.test_options import TestOptions
from insightface_func.face_detect_crop_mutil import Face_detect_crop
from insightface_func.face_detect_crop_multi import Face_detect_crop
from util.reverse2original import reverse2wholeimage
import os
from util.add_watermark import watermark_image
Expand Down
File renamed without changes.

0 comments on commit 5dd24d6

Please sign in to comment.