Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -37,42 +37,24 @@ def sanitize_file_name(file_name, max_length=100):
|
|
37 |
|
38 |
|
39 |
|
40 |
-
#def load_fn(models):
|
41 |
-
# global models_load
|
42 |
-
# models_load = {}
|
43 |
-
# for model in models:
|
44 |
-
# if model not in models_load.keys():
|
45 |
-
# try:
|
46 |
-
# m = gr.load(f'models/{model}')
|
47 |
-
# print(f"{m}\n");
|
48 |
-
# except Exception as error:
|
49 |
-
# print(f"Error loading model {model}: {error}\n")
|
50 |
-
# m = gr.Interface(lambda _: None, inputs=gr.Textbox(), outputs=gr.Image(), queue=False)
|
51 |
-
# models_load.update({model: m})
|
52 |
-
|
53 |
def load_fn(models):
|
54 |
-
models_load
|
55 |
-
|
56 |
for model in models:
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
traceback.print_exc() # Prints full error stack trace for debugging
|
69 |
-
|
70 |
-
# Assign a dummy interface to avoid crashes
|
71 |
-
#m = gr.Interface(fn=lambda _: None, inputs=gr.Textbox(), outputs=gr.Image(), queue=False)
|
72 |
-
models_load[model] = None
|
73 |
models_load[model] = m # Store in dictionary
|
74 |
|
75 |
-
return models_load # Return dictionary instead of using global
|
76 |
|
77 |
load_fn(models)
|
78 |
num_models = len(models)
|
|
|
37 |
|
38 |
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def load_fn(models):
|
41 |
+
global models_load
|
42 |
+
models_load = {}
|
43 |
for model in models:
|
44 |
+
if model not in models_load.keys():
|
45 |
+
try:
|
46 |
+
m = gr.load(f'models/{model}')
|
47 |
+
print(f"{m}\n");
|
48 |
+
except Exception as error:
|
49 |
+
print(f"Error loading model {model}: {error}\n")
|
50 |
+
m = gr.Interface(lambda _: None, inputs=gr.Textbox(), outputs=gr.Image(), queue=False)
|
51 |
+
models_load.update({model: m})
|
52 |
+
traceback.print_exc() # Prints full error stack trace for debugging
|
53 |
+
#m = gr.Interface(fn=lambda _: None, inputs=gr.Textbox(), outputs=gr.Image(), queue=False)
|
54 |
+
models_load[model] = None
|
|
|
|
|
|
|
|
|
|
|
55 |
models_load[model] = m # Store in dictionary
|
56 |
|
57 |
+
#return models_load # Return dictionary instead of using global
|
58 |
|
59 |
load_fn(models)
|
60 |
num_models = len(models)
|