danielroich / PTI

Official Implementation for "Pivotal Tuning for Latent-based editing of Real Images" (ACM TOG 2022) https://arxiv.org/abs/2106.05744
MIT License
897 stars 112 forks source link

KeyError: 'FullyConnectedLayer' #20

Closed mapleyuan closed 3 years ago

mapleyuan commented 3 years ago

hi, i have run the file run_PTI, but get the error: KeyError: 'FullyConnectedLayer' detail: KeyError Traceback (most recent call last)

in ----> 1 model_id = run_PTI(use_wandb=False, use_multi_id_training=use_multi_id_training) ~/ali_repo/PTI/scripts/run_pti.py in run_PTI(run_name, use_wandb, use_multi_id_training) 41 coach = MultiIDCoach(dataloader, use_wandb) 42 else: ---> 43 coach = SingleIDCoach(dataloader, use_wandb) 44 45 coach.train() ~/ali_repo/PTI/training/coaches/single_id_coach.py in __init__(self, data_loader, use_wandb) 10 11 def __init__(self, data_loader, use_wandb): ---> 12 super().__init__(data_loader, use_wandb) 13 14 def train(self): ~/ali_repo/PTI/training/coaches/base_coach.py in __init__(self, data_loader, use_wandb) 37 self.lpips_loss = LPIPS(net=hyperparameters.lpips_type).to(global_config.device).eval() 38 ---> 39 self.restart_training() 40 41 # Initialize checkpoint dir ~/ali_repo/PTI/training/coaches/base_coach.py in restart_training(self) 46 47 # Initialize networks ---> 48 self.G = load_old_G() 49 toogle_grad(self.G, True) 50 ~/ali_repo/PTI/utils/models_utils.py in load_old_G() 21 def load_old_G(): 22 with open(paths_config.stylegan2_ada_ffhq, 'rb') as f: ---> 23 old_G = pickle.load(f)['G_ema'].to(global_config.device).eval() 24 old_G = old_G.float() 25 return old_G ~/ali_repo/PTI/torch_utils/persistence.py in _reconstruct_persistent_obj(meta) 191 192 assert meta.type == 'class' --> 193 orig_class = module.__dict__[meta.class_name] 194 decorator_class = persistent_class(orig_class) 195 obj = decorator_class.__new__(decorator_class) KeyError: 'FullyConnectedLayer'
mapleyuan commented 3 years ago

I have solve prob. check the path config

perkz123 commented 1 year ago

could you please tell me how I can fix the error that is similar to you,I would be appreciative if you could help me KeyError Traceback (most recent call last) Input In [36], in <cell line: 1>() 3 device = 'cuda:0' # please use GPU, do not use CPU 4 path = 'COCO2014_Language-free_Gaussian.pkl' # pre-trained model ----> 5 generator = Generator(device=device, path=path) 6 clipmodel, = clip.load("ViT-B/32", device=device) 7 clip_model = clip_model.eval()

Input In [35], in Generator.init(self, device, path) 2 def init(self, device, path): 3 self.name = 'generator' ----> 4 self.model = self.load_model(device, path) 5 self.device = device 6 self.force_32 = False

Input In [35], in Generator.load_model(self, device, path) 8 def load_model(self, device, path): 9 with dnnlib.util.open_url(path) as f: ---> 10 network= legacy.load_network_pkl(f) 11 self.G_ema = network['G_ema'].to(device) 12 self.D = network['D'].to(device)

File D:\Lafite-main\legacy.py:14, in load_network_pkl(f, force_fp16) 13 def load_network_pkl(f, force_fp16=False): ---> 14 data = _LegacyUnpickler(f).load() 16 # Legacy TensorFlow pickle => convert. 17 if isinstance(data, tuple) and len(data) == 3 and all(isinstance(net, _TFNetworkStub) for net in data):

File D:\Lafite-main\torch_utils\persistence.py:186, in _reconstruct_persistent_obj(meta) 183 module = _src_to_module(meta.module_src) 185 assert meta.type == 'class' --> 186 orig_class = module.dict[meta.class_name] 187 decorator_class = persistent_class(orig_class) 188 obj = decorator_class.new(decorator_class)

KeyError: 'FullyConnectedLayer'