diff --git a/README.rst b/README.rst index f9f916151b606180932d688af9fab5c461e84c8d..ec1af2c3be99aae4bf04a312ab7d87482254857e 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,7 @@ .. image:: https://img.shields.io/pypi/v/bob.paper.ijcb2021_synthetic_dataset.svg :target: https://pypi.python.org/pypi/bob.paper.ijcb2021_synthetic_dataset +.. sectionauthor:: Laurent Colbois <laurent.colbois@idiap.ch> ============= New package @@ -60,7 +61,8 @@ To install everything correctly, after pulling this repository from Gitlab, you conda env create -f generation_env.yml conda env create -f benchmark_env.yml -1. Run `buildout` to extend the generation environment with the tools available in this repository:: +1. Run `buildout` to extend the generation environment with the tools available in this repository +:: conda activate synface # Activate the generation env. buildout -c buildout.cfg # Run buildout @@ -192,15 +194,7 @@ the identities are split to generate all variations. Run benchmark experiments ************************* -Contrary to all previous scripts, the benchmark experiments are based on Bob 9.0 and Tensorflow 2. Therefore, one rerun the :code:`buildout` command with the Bob 9.0 environment as a basis. -This is done with: -:: - conda activate synbenchmark - buildout - -which should in particular create -1. `./bin/python` Custom Python executable containing the benchmark env. extended with `bob.paper.ijcb2021_synthetic_dataset` -2. `./bin/uniqueness_experiment.py` Custom benchmark script to compare identities from two different database (Seed and Synthetic). +Upcoming Contact diff --git a/bob/paper/ijcb2021_synthetic_dataset/stylegan2/generator.py b/bob/paper/ijcb2021_synthetic_dataset/stylegan2/generator.py index 96ab680185997e496b6a9c2584d5a5d5d795b2d3..0232f36fc0b6bd9b4a45070e2bad6ac753255d78 100644 --- a/bob/paper/ijcb2021_synthetic_dataset/stylegan2/generator.py +++ b/bob/paper/ijcb2021_synthetic_dataset/stylegan2/generator.py @@ -133,45 +133,4 @@ class StyleGAN2Generator(object): if return_w_latents: return self.run_from_Wplus(dlatents, **kwargs), repeated_w_latents, w_augmentations else: - return self.run_from_Wplus(dlatents, **kwargs) - - - -""" -def output_transform(images): - return tflib.convert_images_to_uint8(images, nchw_to_nhwc=False) - -def w_output_transform(images, w_latent): - return [tflib.convert_images_to_uint8(images, nchw_to_nhwc=False), w_latent] - -class StyleGAN2Generator(object): - def __init__(self, - network_path="/idiap/temp/lcolbois/networks/stylegan2-ffhq-config-f.pkl", - Gs_kwargs={}, - image_postprocessing_fn=None, - return_w_latent=True): - - self.return_w_latent = return_w_latent - self.image_postprocessing_fn=image_postprocessing_fn - if self.image_postprocessing_fn is None: - self.image_postprocessing_fn = (lambda x: x) - - _G, _D, Gs = pretrained_networks.load_networks(network_path) - self.Gs_kwargs = Gs_kwargs - if self.return_w_latent: - self.Gs = Gs.clone(return_dlatents=True) - self.Gs_kwargs.update({'return_dlatents': True, 'output_transform': dict(func=w_output_transform)}) - else: - self.Gs= Gs - self.Gs_kwargs.update({'output_transform': dict(func=output_transform)}) - - self.latent_dim = self.Gs.input_shape[1] - - def __call__(self, z_latent): - if self.return_w_latent: - images, w_latent = self.Gs.run(np.stack([z_latent]), None, **self.Gs_kwargs) - return self.image_postprocessing_fn(images[0]), w_latent[0][0] - else: - images = self.Gs.run(np.stack([z_latent]), None, **self.Gs_kwargs) - return self.image_postprocessing_fn(images[0]) -""" \ No newline at end of file + return self.run_from_Wplus(dlatents, **kwargs) \ No newline at end of file diff --git a/bob/paper/ijcb2021_synthetic_dataset/stylegan2/training/misc.py b/bob/paper/ijcb2021_synthetic_dataset/stylegan2/training/misc.py index fb559c417056ad86140bc7fe55efc397d67a0945..9b3444e85c70d9fe742bd2e8055a42210d857f8b 100755 --- a/bob/paper/ijcb2021_synthetic_dataset/stylegan2/training/misc.py +++ b/bob/paper/ijcb2021_synthetic_dataset/stylegan2/training/misc.py @@ -19,7 +19,7 @@ import dnnlib def open_file_or_url(file_or_url): if dnnlib.util.is_url(file_or_url): - return dnnlib.util.open_url(file_or_url, cache_dir='/idiap/temp/lcolbois/cache/stylegan2/') + return dnnlib.util.open_url(file_or_url, cache_dir='.stylegan2-cache') return open(file_or_url, 'rb') def load_pkl(file_or_url):