2
0
mirror of https://github.com/Shawn-Shan/fawkes.git synced 2024-12-22 07:09:33 +05:30
This commit is contained in:
Shawn-Shan 2021-05-03 16:45:10 -05:00
parent b9d3ca46da
commit 5d1c2ad2d7
2 changed files with 7 additions and 5 deletions

View File

@ -57,8 +57,8 @@ class Fawkes(object):
def mode2param(self, mode): def mode2param(self, mode):
if mode == 'low': if mode == 'low':
th = 0.005 th = 0.004
max_step = 30 max_step = 40
lr = 25 lr = 25
extractors = ["extractor_2"] extractors = ["extractor_2"]
@ -133,7 +133,7 @@ class Fawkes(object):
continue continue
p_img = final_images[i] p_img = final_images[i]
path = image_paths[i] path = image_paths[i]
file_name = "{}_{}_cloaked.{}".format(".".join(path.split(".")[:-1]), self.mode, format) file_name = "{}_cloaked.{}".format(".".join(path.split(".")[:-1]), format)
dump_image(p_img, file_name, format=format) dump_image(p_img, file_name, format=format)
print("Done!") print("Done!")

View File

@ -133,6 +133,7 @@ class Faces(object):
self.verbose = verbose self.verbose = verbose
self.no_align = no_align self.no_align = no_align
self.aligner = aligner self.aligner = aligner
self.margin = 30
self.org_faces = [] self.org_faces = []
self.cropped_faces = [] self.cropped_faces = []
self.cropped_faces_shape = [] self.cropped_faces_shape = []
@ -169,7 +170,8 @@ class Faces(object):
if eval_local: if eval_local:
base = resize(img, (IMG_SIZE, IMG_SIZE)) base = resize(img, (IMG_SIZE, IMG_SIZE))
else: else:
long_size = max([img.shape[1], img.shape[0]]) long_size = max([img.shape[1], img.shape[0]]) + self.margin
base = np.ones((long_size, long_size, 3)) * np.mean(img, axis=(0, 1)) base = np.ones((long_size, long_size, 3)) * np.mean(img, axis=(0, 1))
start1, end1 = get_ends(long_size, img.shape[0]) start1, end1 = get_ends(long_size, img.shape[0])
@ -215,7 +217,7 @@ class Faces(object):
org_shape = self.cropped_faces_shape[i] org_shape = self.cropped_faces_shape[i]
old_square_shape = max([org_shape[0], org_shape[1]]) old_square_shape = max([org_shape[0], org_shape[1]]) + self.margin
cur_protected = resize(cur_protected, (old_square_shape, old_square_shape)) cur_protected = resize(cur_protected, (old_square_shape, old_square_shape))
cur_original = resize(cur_original, (old_square_shape, old_square_shape)) cur_original = resize(cur_original, (old_square_shape, old_square_shape))