2
0
mirror of https://github.com/Shawn-Shan/fawkes.git synced 2024-12-22 07:09:33 +05:30

fix issue on get_file download

This commit is contained in:
Shawn-Shan 2020-07-16 13:39:50 -05:00
parent 3c89d43cf1
commit aaaea79378
4 changed files with 15 additions and 19 deletions

View File

@ -4,7 +4,7 @@
# @Link : https://www.shawnshan.com/
__version__ = '0.0.6'
__version__ = '0.0.8'
from .detect_faces import create_mtcnn, run_detect_face
from .differentiator import FawkesMaskGeneration

View File

@ -19,6 +19,7 @@ from fawkes.differentiator import FawkesMaskGeneration
from fawkes.utils import load_extractor, init_gpu, select_target_label, dump_image, reverse_process_cloaked, \
Faces
from fawkes.align_face import aligner
from fawkes.utils import get_file
random.seed(12243)
np.random.seed(122412)
@ -61,6 +62,13 @@ class Fawkes(object):
self.gpu = gpu
self.batch_size = batch_size
self.sess = init_gpu(gpu)
model_dir = os.path.join(os.path.expanduser('~'), '.fawkes')
if not os.path.exists(os.path.join(model_dir, "mtcnn.p.gz")):
os.makedirs(model_dir, exist_ok=True)
get_file("mtcnn.p.gz", "http://sandlab.cs.uchicago.edu/fawkes/files/mtcnn.p.gz", cache_dir=model_dir,
cache_subdir='')
self.aligner = aligner(self.sess)
self.fs_names = [feature_extractor]
if isinstance(feature_extractor, list):
@ -76,7 +84,7 @@ class Fawkes(object):
elif mode == 'mid':
th = 0.005
max_step = 100
lr = 30
lr = 20
elif mode == 'high':
th = 0.008
max_step = 200

View File

@ -55,7 +55,6 @@ if sys.version_info[0] == 2:
else:
from six.moves.urllib.request import urlretrieve
def clip_img(X, preprocessing='raw'):
X = reverse_preprocess(X, preprocessing)
X = np.clip(X, 0.0, 255.0)
@ -92,11 +91,6 @@ def load_image(path):
class Faces(object):
def __init__(self, image_paths, aligner, verbose=1, eval_local=False):
model_dir = os.path.join(os.path.expanduser('~'), '.fawkes')
if not os.path.exists(os.path.join(model_dir, "mtcnn.p.gz")):
os.makedirs(model_dir, exist_ok=True)
get_file("mtcnn.p.gz", "http://sandlab.cs.uchicago.edu/fawkes/files/mtcnn.p.gz", cache_dir=model_dir,
cache_subdir='')
self.verbose = verbose
self.aligner = aligner
@ -366,13 +360,6 @@ def load_extractor(name):
if hasattr(model.layers[-1], "activation") and model.layers[-1].activation == "softmax":
raise Exception(
"Given extractor's last layer is softmax, need to remove the top layers to make it into a feature extractor")
# if "extract" in name.split("/")[-1]:
# pass
# else:
# print("Convert a model to a feature extractor")
# model = build_bottleneck_model(model, model.layers[layer_idx].name)
# model.save(name + "extract")
# model = keras.models.load_model(name + "extract")
return model
@ -524,13 +511,13 @@ def get_file(fname,
archive_format='auto',
cache_dir=None):
if cache_dir is None:
cache_dir = os.path.join(os.path.expanduser('~'), '.keras')
cache_dir = os.path.join(os.path.expanduser('~'), '.fawkes')
if md5_hash is not None and file_hash is None:
file_hash = md5_hash
hash_algorithm = 'md5'
datadir_base = os.path.expanduser(cache_dir)
if not os.access(datadir_base, os.W_OK):
datadir_base = os.path.join('/tmp', '.keras')
datadir_base = os.path.join('/tmp', '.fawkes')
datadir = os.path.join(datadir_base, cache_subdir)
_makedirs_exist_ok(datadir)

View File

@ -77,11 +77,12 @@ setup_requires = []
install_requires = [
'numpy==1.16.4',
# 'tensorflow-gpu>=1.13.1, <=1.14.0',
'tensorflow>=1.11.1, <=1.14.0',
'tensorflow>=1.12.0, <=1.15.0',
'argparse',
'keras==2.2.5',
'keras>=2.2.5, <=2.3.1',
'scikit-image',
'pillow>=7.0.0',
'bleach>=2.1.0'
]
setup(