Update app.py
Browse files
app.py
CHANGED
@@ -57,29 +57,37 @@ def update_imgbox(choices):
|
|
57 |
executor = ThreadPoolExecutor(max_workers=num_models)
|
58 |
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
def gen_fn(model_str, prompt):
|
|
|
61 |
if model_str == 'NA':
|
62 |
return None
|
63 |
-
|
|
|
64 |
noise = str(randint(0, 9999))
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
#
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
print(f"Error occurred: {e}")
|
82 |
-
return None
|
83 |
|
84 |
|
85 |
|
|
|
57 |
executor = ThreadPoolExecutor(max_workers=num_models)
|
58 |
|
59 |
|
60 |
+
#def gen_fn(model_str, prompt):
|
61 |
+
# if model_str == 'NA':
|
62 |
+
# return None#
|
63 |
+
#
|
64 |
+
# noise = str(randint(0, 9999))
|
65 |
+
# combined_prompt = f'{prompt}'
|
66 |
+
# print(f"Generating with prompt: {combined_prompt}")
|
67 |
+
|
68 |
def gen_fn(model_str, prompt):
|
69 |
+
global models_load
|
70 |
if model_str == 'NA':
|
71 |
return None
|
72 |
+
if models_load.get(model_str) is None:
|
73 |
+
models_load[model_str] = load_model(model_str) # Load the model if not already loaded
|
74 |
noise = str(randint(0, 9999))
|
75 |
+
return models_load[model_str](f'{prompt} {noise}')
|
76 |
+
|
77 |
|
78 |
+
# try:
|
79 |
+
# image_response = models_load[model_str](f'{prompt} {noise}')
|
80 |
+
|
81 |
+
# if isinstance(image_response, gr.Image):
|
82 |
+
# return image_response
|
83 |
+
# elif isinstance(image_response, str): # If the response is a path or URL, pass it as a string
|
84 |
+
# return gr.Image(image_response) # You can handle it based on your model's return type
|
85 |
+
# else:
|
86 |
+
# print(f"Unexpected response type: {type(image_response)}")
|
87 |
+
# return None
|
88 |
+
# except Exception as e:
|
89 |
+
# print(f"Error occurred: {e}")
|
90 |
+
# return None
|
|
|
|
|
91 |
|
92 |
|
93 |
|