soiz1 commited on
Commit
b61e5bf
·
verified ·
1 Parent(s): 45c032e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -174,7 +174,6 @@ def infer(name, path, index, vc_input, vc_upload, tts_text, tts_voice, f0_up_key
174
  info = traceback.format_exc()
175
  print(info)
176
  return info, (None, None)
177
-
178
  def load_model():
179
  categories = []
180
  with open("/weights/folder_info.json", "r", encoding="utf-8") as f:
@@ -193,26 +192,26 @@ def load_model():
193
  continue
194
  model_title = info['title']
195
  model_name = info['model_path']
196
- model_author = info.get("author", None)
197
- model_cover = f"/weights/{category_folder}/{character_name}/{info['cover']}"
198
- model_index = f"/weights/{category_folder}/{character_name}/{info['feature_retrieval_library']}"
199
- if info['feature_retrieval_library'] == "None":
200
- model_index = None
201
- if model_index:
202
- assert os.path.exists(model_index), f"Model {model_title} failed to load index."
203
- if not (model_author in authors or "/" in model_author or "&" in model_author):
204
- authors.append(model_author)
205
- model_path = f"/weights/{category_folder}/{character_name}/{model_name}"
206
- import pickle
207
  path = f"/weights/{category_folder}/{character_name}/{model_name}"
208
-
 
209
  if not os.path.exists(path):
210
  print(f"Model file not found: {path}")
211
- cpt = torch.load(f"/weights/{category_folder}/{character_name}/{model_name}", map_location="cpu", pickle_module=pickle)
212
- model_version = cpt.get("version", "v1")
213
- print(f"Indexed model {model_title} by {model_author} ({model_version})")
214
- models.append((character_name, model_title, model_author, model_cover, model_version, model_path, model_index))
215
- del cpt
 
 
 
 
 
 
 
 
 
 
216
  categories.append([category_title, category_folder, models])
217
  return categories
218
 
 
174
  info = traceback.format_exc()
175
  print(info)
176
  return info, (None, None)
 
177
  def load_model():
178
  categories = []
179
  with open("/weights/folder_info.json", "r", encoding="utf-8") as f:
 
192
  continue
193
  model_title = info['title']
194
  model_name = info['model_path']
 
 
 
 
 
 
 
 
 
 
 
195
  path = f"/weights/{category_folder}/{character_name}/{model_name}"
196
+
197
+ # ファイルの存在確認
198
  if not os.path.exists(path):
199
  print(f"Model file not found: {path}")
200
+ continue
201
+
202
+ print(f"Loading model from: {path}")
203
+ try:
204
+ cpt = torch.load(path, map_location="cpu", pickle_module=pickle)
205
+ model_version = cpt.get("version", "v1")
206
+ print(f"Indexed model {model_title} by {info.get('author', 'Unknown')} ({model_version})")
207
+ except Exception as e:
208
+ print(f"Error loading model {model_title}: {e}")
209
+ continue
210
+
211
+ models.append((character_name, model_title, info.get('author', 'Unknown'),
212
+ f"/weights/{category_folder}/{character_name}/{info['cover']}",
213
+ model_version, path,
214
+ f"/weights/{category_folder}/{character_name}/{info['feature_retrieval_library']}"))
215
  categories.append([category_title, category_folder, models])
216
  return categories
217