soiz1 commited on
Commit
094f851
·
verified ·
1 Parent(s): d5f75d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -192,26 +192,26 @@ def load_model():
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")
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
 
 
192
  continue
193
  model_title = info['title']
194
  model_name = info['model_path']
195
+ model_author = info.get("author", None)
196
+ model_cover = f"/weights/{category_folder}/{character_name}/{info['cover']}"
197
+ model_index = f"/weights/{category_folder}/{character_name}/{info['feature_retrieval_library']}"
198
+ if info['feature_retrieval_library'] == "None":
199
+ model_index = None
200
+ if model_index:
201
+ assert os.path.exists(model_index), f"Model {model_title} failed to load index."
202
+ if not (model_author in authors or "/" in model_author or "&" in model_author):
203
+ authors.append(model_author)
204
+ model_path = f"/weights/{category_folder}/{character_name}/{model_name}"
205
+ import pickle
206
  path = f"/weights/{category_folder}/{character_name}/{model_name}"
207
+
 
208
  if not os.path.exists(path):
209
  print(f"Model file not found: {path}")
210
+ cpt = torch.load(f"/weights/{category_folder}/{character_name}/{model_name}", map_location="cpu")
211
+ model_version = cpt.get("version", "v1")
212
+ print(f"Indexed model {model_title} by {model_author} ({model_version})")
213
+ models.append((character_name, model_title, model_author, model_cover, model_version, model_path, model_index))
214
+ del cpt
 
 
 
 
 
 
 
 
 
 
215
  categories.append([category_title, category_folder, models])
216
  return categories
217