def __init__(self, args, USE_SERVER_INSTEAD=False, PORT="8000"): self.USE_SERVER_INSTEAD = USE_SERVER_INSTEAD self.architecture = args.architecture if self.USE_SERVER_INSTEAD: # = HANDSHAKE ================================================= self.Handshake_REST_API_URL = "http://localhost:" + PORT + "/handshake" payload = {"client": "client", "backup_name": "Bob"} r = requests.post(self.Handshake_REST_API_URL, files=payload).json() print("Handshake request data", r) # = SEND BATCH OF IMAGES ===================================== self.Images_REST_API_URL = "http://localhost:" + PORT + "/get_image" serverside_handler = None settings = Settings() self.serverside_handler = None if not self.USE_SERVER_INSTEAD: if self.architecture == "ProgressiveGAN": self.serverside_handler = progressive_gan_handler.ProgressiveGAN_Handler( settings, args) if self.architecture == "StyleGAN2": import stylegan2_handler self.serverside_handler = stylegan2_handler.StyleGAN2_Handler( settings, args)
#### LOAD A SECOND NET: import mock import os args = mock.Mock() args.architecture = args_main.architecture args.model_path = args_main.network print(" ... loading from ... ", args.model_path) settings = Settings() serverside_handler = None if args.architecture == "ProgressiveGAN": import progressive_gan_handler serverside_handler = progressive_gan_handler.ProgressiveGAN_Handler( settings, args) if args.architecture == "StyleGAN2": import stylegan2_handler serverside_handler = stylegan2_handler.StyleGAN2_Handler( settings, args) loaded_net = serverside_handler._Gs print("reporting locally loaded net:", loaded_net) weights = {} for tensor_key in loaded_net.vars: try: first_net_weights = loaded_net.get_var(tensor_key) weights[tensor_key] = first_net_weights except Exception as e:
def load_serverside_handler(self, args): global serverside_handler serverside_handler = progressive_gan_handler.ProgressiveGAN_Handler( self.settings, args) print('Server GAN handler loaded.')