lucky0146 commited on
Commit
8fd5dd4
·
verified ·
1 Parent(s): 4518c9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -36,8 +36,11 @@ def setup_environment():
36
  # Load CodeFormer model
37
  def load_codeformer():
38
  setup_environment()
39
- model = CodeFormer(dim_embd=512, codebook_size=1024, n_head=8, n_layers=9, connect_list=['32', '64', '128', '256']) # Changed n_layer to n_layers
40
- model.load_state_dict(torch.load("weights/CodeFormer/codeformer.pth", map_location='cpu'))
 
 
 
41
  model.eval()
42
  model = model.to('cpu') # Force CPU
43
  return model
 
36
  # Load CodeFormer model
37
  def load_codeformer():
38
  setup_environment()
39
+ model = CodeFormer(dim_embd=512, codebook_size=1024, n_head=8, n_layers=9, connect_list=['32', '64', '128', '256'])
40
+ # Load the state dict, extracting the 'params_ema' key
41
+ checkpoint = torch.load("weights/CodeFormer/codeformer.pth", map_location='cpu')
42
+ state_dict = checkpoint['params_ema'] if 'params_ema' in checkpoint else checkpoint
43
+ model.load_state_dict(state_dict, strict=False) # Use strict=False to ignore missing keys
44
  model.eval()
45
  model = model.to('cpu') # Force CPU
46
  return model