Przeglądaj źródła

do not stop working on failed hypernetwork load

AUTOMATIC 2 lat temu
rodzic
commit
97bc0b9504
1 zmienionych plików z 9 dodań i 2 usunięć
  1. 9 2
      modules/hypernetwork.py

+ 9 - 2
modules/hypernetwork.py

@@ -1,5 +1,8 @@
 import glob
 import os
+import sys
+import traceback
+
 import torch
 from modules import devices
 
@@ -36,8 +39,12 @@ def load_hypernetworks(path):
     res = {}
 
     for filename in glob.iglob(path + '**/*.pt', recursive=True):
-        hn = Hypernetwork(filename)
-        res[hn.name] = hn
+        try:
+            hn = Hypernetwork(filename)
+            res[hn.name] = hn
+        except Exception:
+            print(f"Error loading hypernetwork {filename}", file=sys.stderr)
+            print(traceback.format_exc(), file=sys.stderr)
 
     return res