BartPoint commited on
Commit
9445938
1 Parent(s): 6c72a59

Update app_multi.py

Browse files
Files changed (1) hide show
  1. app_multi.py +22 -28
app_multi.py CHANGED
@@ -103,35 +103,29 @@ for model_name in multi_cfg.get('models'):
103
  else:
104
  net_g = SynthesizerTrnMs768NSFsid_nono(*cpt['config'])
105
 
106
- if 'enc_p.emb_phone.weight' in cpt['weight']:
107
- old_shape = cpt['weight']['enc_p.emb_phone.weight'].shape
108
- new_shape = net_g.enc_p.emb_phone.weight.shape
109
- if old_shape != new_shape:
110
- print(f"Upgrading enc_p.emb_phone.weight size: {old_shape} -> {new_shape}")
111
- weight = cpt['weight']['enc_p.emb_phone.weight']
112
- upgraded_weight = torch.zeros(new_shape)
113
- upgraded_weight[:, :old_shape[1]] = weight
114
- cpt['weight']['enc_p.emb_phone.weight'] = upgraded_weight
115
-
116
- del net_g.enc_q
117
-
118
- # According to original code, this thing seems necessary.
119
- print(net_g.load_state_dict(cpt['weight'], strict=False))
120
-
121
- net_g.eval().to(config.device)
122
- net_g = net_g.half() if util.is_half(config.device) else net_g.float()
123
-
124
- vc = VC(tgt_sr, config)
125
-
126
- loaded_models.append(dict(
127
- name=model_name,
128
- metadata=model_info,
129
- vc=vc,
130
- net_g=net_g,
131
- if_f0=if_f0,
132
- target_sr=tgt_sr
133
- ))
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  print(f'Models loaded: {len(loaded_models)}')
136
 
137
  # Edge TTS speakers
 
103
  else:
104
  net_g = SynthesizerTrnMs768NSFsid_nono(*cpt['config'])
105
 
106
+ if 'enc_p.emb_phone.weight' not in cpt['weight']:
107
+
108
+ del net_g.enc_q
109
+
110
+ # According to original code, this thing seems necessary.
111
+ print(net_g.load_state_dict(cpt['weight'], strict=False))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
+ net_g.eval().to(config.device)
114
+ net_g = net_g.half() if util.is_half(config.device) else net_g.float()
115
+
116
+ vc = VC(tgt_sr, config)
117
+
118
+ loaded_models.append(dict(
119
+ name=model_name,
120
+ metadata=model_info,
121
+ vc=vc,
122
+ net_g=net_g,
123
+ if_f0=if_f0,
124
+ target_sr=tgt_sr
125
+ ))
126
+ else:
127
+ print("Skip one module, because is too big")
128
+
129
  print(f'Models loaded: {len(loaded_models)}')
130
 
131
  # Edge TTS speakers