Update app.py
Browse files
app.py
CHANGED
@@ -29,25 +29,25 @@ def load_fn(models):
|
|
29 |
# models_load.update({model: m})
|
30 |
try:
|
31 |
# Attempt to generate the image
|
32 |
-
|
33 |
|
34 |
# Check if the image_response is a tuple, handle accordingly
|
35 |
-
|
36 |
# If the response is a tuple, return the first item assuming it's the image
|
37 |
-
|
38 |
|
39 |
# Ensure the response is an image or image-like object
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
|
53 |
load_fn(models)
|
|
|
29 |
# models_load.update({model: m})
|
30 |
try:
|
31 |
# Attempt to generate the image
|
32 |
+
image_response = models_load[model_str](f'{prompt} {negative_prompt} {noise}')
|
33 |
|
34 |
# Check if the image_response is a tuple, handle accordingly
|
35 |
+
if isinstance(image_response, tuple):
|
36 |
# If the response is a tuple, return the first item assuming it's the image
|
37 |
+
image_response = image_response[0]
|
38 |
|
39 |
# Ensure the response is an image or image-like object
|
40 |
+
if isinstance(image_response, gr.Image):
|
41 |
+
return image_response
|
42 |
+
elif isinstance(image_response, str): # If the response is a path or URL, pass it as a string
|
43 |
+
return gr.Image(image_response) # You can handle it based on your model's return type
|
44 |
+
else:
|
45 |
+
print(f"Unexpected response type: {type(image_response)}")
|
46 |
+
return None
|
47 |
|
48 |
+
except Exception as e:
|
49 |
+
print(f"Error occurred: {e}")
|
50 |
+
return None
|
51 |
|
52 |
|
53 |
load_fn(models)
|