Example #1
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/uc?id=1JAPmhYIuzmNfjAdCnBDKOpK_BdpBkxyn", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/uc?id=1MZFFu14XWst-0Bz7n4odGb31oaqcX8V8", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #2
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/uc?id=1AbwUv2vKceRvpSh6cCKLS_13xnjrqeMl", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/uc?id=1R1NlG14nyMoaYTH17mmITzDDLcDXSQ6p", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #3
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/uc?id=1K0GAPKAM8BfcJ1WdKem32k9L5eMDxs9d", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/uc?id=1jw1V94Nc3dpJuPAvo9TfIgCVJ_Ljtr-v", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #4
0
    def __init__(self,
                 cache_dir,
                 synthesis_path=None,
                 mapping_path=None,
                 verbose=True):
        super(PULSE, self).__init__()

        self.device = torch.device(
            "cuda" if torch.cuda.is_available() else "cpu")
        self.synthesis = G_synthesis().to(self.device)
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        if synthesis_path is None:
            f = open_url(
                "https://drive.google.com/uc?id=1TCViX1YpQyRsklTVYEJwdbmK91vklCo8",
                cache_dir=cache_dir,
                verbose=verbose)
        else:
            f = open(synthesis_path, "rb")
        with f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt",
                                           map_location=self.device)
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().to(self.device)

            if mapping_path is None:
                f = open_url(
                    "https://drive.google.com/uc?id=14R6iHGf5iuVx3DMNsACAl7eBr7Vdpd0k",
                    cache_dir=cache_dir,
                    verbose=verbose)
            else:
                f = open(mapping_path, "rb")
            with f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device=self.device)
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #5
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/uc?id=1K7u64igPZmvl3BSxozVaHJVVdUuL5fxF", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/uc?id=1BHIHtKEhJNuim47MP8o4TImWOstPGLE7", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #6
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/uc?id=1y-NhHkCvgdSi5_Qfnds6w0ifJsGNA7gM", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/uc?id=1pG9XPl7I33Z0iT9y__kP5Iy5B09UqztH", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #7
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/file/d/19pglfAGL113rLzmHFjfu2Od-7jmWpuZf/view?usp=sharing", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/file/d/16YIeW-dr_XJWyHGEEL-yXx3Zif0WgCuB/view?usp=sharing", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #8
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/uc?id=1OwPUTcx_NZLJz0TGt-fTDEmhcrInWhM_",cache_dir=cache_dir,verbose=verbose) as f:
        #with open_url("https://drive.google.com/uc?id=1TCViX1YpQyRsklTVYEJwdbmK91vklCo8", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))
        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/uc?id=14R6iHGf5iuVx3DMNsACAl7eBr7Vdpd0k", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #9
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok = True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url("https://drive.google.com/uc?id=1ZbJffKU79LjMwsd3X-EIwecLvZvuYwAo", cache_dir=cache_dir, verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url("https://drive.google.com/uc?id=1J_E4OUjG7Vn2rS3ezT0CHhuE1fEG9cma", cache_dir=cache_dir, verbose=verbose) as f:
                    mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000,512),dtype=torch.float32, device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {"mean": latent_out.mean(0), "std": latent_out.std(0)}
                torch.save(self.gaussian_fit,"gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #10
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)

        print(
            "Plan to download https://drive.google.com/uc?id=1mAsooNngyIBinPr7nntOajWxP6z578a3"
        )

        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1mAsooNngyIBinPr7nntOajWxP6z578a3",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)
        print("\Do \"Synthesis Network.pt\"")

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()
            print(
                "Plan to download https://drive.google.com/uc?id=1QDawHIcIRlifgFZN5_3H0OzeVmHn7tS"
            )

            with open_url(
                    "https://drive.google.com/uc?id=1QDawHIcIRlifgFZN5_3H0OzeVmHn7tSK",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            print("\Do \"gaussian_fit.pt\"")

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #11
0
    def __init__(self,
                 cache_dir,
                 verbose=True,
                 synthesis_model_path=SYNTHESIS_MODEL_PATH,
                 mapping_model_path=MAPPING_MODEL_PATH):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(synthesis_model_path,
                      cache_dir=cache_dir,
                      verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(mapping_model_path,
                          cache_dir=cache_dir,
                          verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #12
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=13N1urNRhRLZbR9WG752LhQvGYO3x1QrW",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1laHsMRErPs7UTTzBwqlNsDlqgZ02TV6R",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #13
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1YUZZHNgphyOa1BfbxPBOPdfOOnS5CyV2",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1pnh91MlNhoSbvHuoivobIDMHq3zbbEmm",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #14
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network synthesis.pt")
        with open_url(
                "https://drive.google.com/uc?id=13ucp7AR4ucYrsMf-8etWxZk1MTGAcPIF",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()
            # mapping.pt
            with open_url(
                    "https://drive.google.com/uc?id=1CGJf_11_SotYL9HeFEhzXrYV4nyVGGrc",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #15
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=16laSZI4MayJmruuOS-Mfx9hYKxuVGQo-",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1Q7yCjWXxROjbWQujQ4pXDXUdcUJd-KuR",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #16
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1LKlTS6EP1A50pEfIXIBehcUh98PSSy85",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=19iPG6TwGEGV0wlY5PGGJCIQAEI6WhcX8",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #17
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=12OWpiWLh6vnlmq2v9Cj3X0AdJIGfXHU_",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1QLubl3N_1hoboM44vaAo8z7w4Qgh2hr3",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #18
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1bsU0ajxyN9adHGwwf0uVFgjRvLss6b4t",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1_kXc5fbjWu0IBBXHachSxWCI_XLvbYhi",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #19
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=18ugCo-zhghcBb19AqwF-hKpXE0PSg9-5",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1VijILYWDj8RQ7n7dp81kcQbEIlt82juh",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #20
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=15fTHGsxvpkQgU7E9a6Da9-eLc6xMT2CZ",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1rxU-mLpNfZOvHjelHdcGeSbW2Nd9r7WF",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #21
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1vpPD7-2oW-hznGcwGy9zAhgdmb0NvmLf",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=193h4RpWqae7lkqbBfI8Oc4lm6_gHwsBI",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #22
0
File: PULSE.py Project: b5071/pulse
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1bZfrPhsky3h3SeHjUHj71mqdspZfomPv",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1vscDi4yMuFUhAvL5sUjpWxGNbWQNQqxa",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #23
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1PG08CZbT0PSmyrCfvV8y3p1f3wwoCz61",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1k6O6isBC0OC5WcGWYWjZ2Ng2MkEGumgU",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #24
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1On4faywQ6XeIWV3QyaF1IOTdhGNFI0Tz",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1x94Ts5wAAFvBOW56EXbmggNOKLPuS0wb",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #25
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1xeZbIwYQqeEqAF__0A85709DPwKP9PZ5",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1wbgY2OH4uUFwUotRaV_s7md586dqEBt2",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #26
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1hY4qBMzhjuIbpqrg5LRU7Qi5VT9WCDNF",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1RRR5xYBmio4blj61E3AWAUVYz4cPPUBT",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #27
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=15VesUq_Z2-CGng62hlO7ZlcAOodEaEen",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1DBCVVfjfiTBeugOcRKKvy2NW_u5Z_JJS",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #28
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1r-sJ1y60A61G6pnxszgNPa0vLs7nTgMx",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1lrZIg8oD_y4KOv98TfFZIgJh0fG0rZxN",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #29
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1OjFOETBvDE3FOd1OmTP-ujSh3hCi7rgQ",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1eVGz3JTo7QuRUK7dqdlf5UkCcFJyGrUQ",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")
Example #30
0
    def __init__(self, cache_dir, verbose=True):
        super(PULSE, self).__init__()

        self.synthesis = G_synthesis().cuda()
        self.verbose = verbose

        cache_dir = Path(cache_dir)
        cache_dir.mkdir(parents=True, exist_ok=True)
        if self.verbose: print("Loading Synthesis Network")
        with open_url(
                "https://drive.google.com/uc?id=1RNIjPDQ0VoUREGyTaQ70INu5USKuwCgV",
                cache_dir=cache_dir,
                verbose=verbose) as f:
            self.synthesis.load_state_dict(torch.load(f))

        for param in self.synthesis.parameters():
            param.requires_grad = False

        self.lrelu = torch.nn.LeakyReLU(negative_slope=0.2)

        if Path("gaussian_fit.pt").exists():
            self.gaussian_fit = torch.load("gaussian_fit.pt")
        else:
            if self.verbose: print("\tLoading Mapping Network")
            mapping = G_mapping().cuda()

            with open_url(
                    "https://drive.google.com/uc?id=1hNysITDiQGR5QEWy2Ctb1BLokBrqiak_",
                    cache_dir=cache_dir,
                    verbose=verbose) as f:
                mapping.load_state_dict(torch.load(f))

            if self.verbose: print("\tRunning Mapping Network")
            with torch.no_grad():
                torch.manual_seed(0)
                latent = torch.randn((1000000, 512),
                                     dtype=torch.float32,
                                     device="cuda")
                latent_out = torch.nn.LeakyReLU(5)(mapping(latent))
                self.gaussian_fit = {
                    "mean": latent_out.mean(0),
                    "std": latent_out.std(0)
                }
                torch.save(self.gaussian_fit, "gaussian_fit.pt")
                if self.verbose: print("\tSaved \"gaussian_fit.pt\"")