Skip to content

Commit

Permalink
ranked celeb support added
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 26, 2022
1 parent 8e7ed5c commit 7c76835
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dir_mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0
# transforms.Normalize([0, 0, 0], [1/0.229, 1/0.224, 1/0.225]),
# transforms.Normalize([-0.485, -0.456, -0.406], [1, 1, 1])
# ])
def single_src_dir_dst(src_img_file_path, targetDir, outDir):
def single_src_dir_dst(src_img_file_path, targetDir, outDir,count_limit = -1):

count_limit = -1
# count_limit = -1
opt = TestOptions().parse()

start_epoch, epoch_iter = 1, 0
Expand Down Expand Up @@ -89,14 +89,17 @@ def single_src_dir_dst(src_img_file_path, targetDir, outDir):
img_dir_swap(targetDir, latend_id, model, app, pic_apath.name,temp_results_dir=outDir,\
no_simswaplogo=opt.no_simswaplogo,use_mask=opt.use_mask,crop_size=crop_size,count=count_limit)

def src_dir(indir,target_dir,output_dir, randomize_src_files = False):
def src_dir(indir,target_dir,output_dir, randomize_src_files = False,trc = -1,selected_src_count=-1):
src_img_files = [x for x in Path(indir).glob('*.jpg')]


if randomize_src_files:
shuffle(src_img_files)

src_img_files = src_img_files[:selected_src_count]
for imgFilePath in src_img_files:
single_src_dir_dst(imgFilePath,target_dir,output_dir)
single_src_dir_dst(imgFilePath,target_dir,output_dir,trc)


if __name__ == '__main__':
indir_global = r'D:\paradise\stuff\simswappg\srcs'
# indir_global = r'D:\paradise\stuff\Essence\FS\all\Sluts'
Expand Down
22 changes: 22 additions & 0 deletions randFsCelebMaker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pathlib import Path
from random import shuffle
from dir_mage import src_dir

if __name__ == '__main__':
# indir_global = r'D:\paradise\stuff\simswappg\srcs'
indir_global = r'D:\paradise\stuff\Essence\FS\all\Sluts'
# targetDir_global = r'C:\Heaven\YummyBaker'
# targetDir_global = r'C:\Heaven\YummyBaker'
# targetDir_global = r'D:\paradise\stuff\new\imageset2\meri maa mujhse chud jati'
# targetDir_global =
# targetDir_global = r'D:\paradise\stuff\new\pvd2'
targetDir_global = r'D:\paradise\stuff\Essence\pictures\ranked2'

# outDir_global = r'D:\paradise\stuff\new\pvd\test'
outDir_global = r'D:\Developed\FaceSwapExperimental\TestResult'
# outDir_global = r'C:\Games\sacred2'
xtr = [x for x in Path(targetDir_global).glob('*') if x.is_dir()]
shuffle(xtr)
for dirt in xtr:
trc = int(dirt.name)
src_dir(indir_global,dirt,outDir_global,True,-1,trc)

0 comments on commit 7c76835

Please sign in to comment.