Update app.py
Browse files
app.py
CHANGED
|
@@ -33,11 +33,23 @@ def update_imgbox(choices):
|
|
| 33 |
choices_plus = extend_choices(choices)
|
| 34 |
return [gr.Image(None, label=m, visible=(m != 'NA'), elem_id="custom_image") for m in choices_plus]
|
| 35 |
|
| 36 |
-
def gen_fn(model_str, prompt):
|
| 37 |
if model_str == 'NA':
|
| 38 |
return None
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
def make_me():
|
| 43 |
with gr.Row():
|
|
|
|
| 33 |
choices_plus = extend_choices(choices)
|
| 34 |
return [gr.Image(None, label=m, visible=(m != 'NA'), elem_id="custom_image") for m in choices_plus]
|
| 35 |
|
| 36 |
+
def gen_fn(model_str, prompt, max_retries=10):
|
| 37 |
if model_str == 'NA':
|
| 38 |
return None
|
| 39 |
+
|
| 40 |
+
retries = 0
|
| 41 |
+
while retries < max_retries:
|
| 42 |
+
try:
|
| 43 |
+
noise = str(randint(0, 9999999))
|
| 44 |
+
result = models_load[model_str](f'{prompt} {noise}')
|
| 45 |
+
return result
|
| 46 |
+
except Exception as e:
|
| 47 |
+
print(f"Error generating image: {e}")
|
| 48 |
+
retries += 1
|
| 49 |
+
if retries >= max_retries:
|
| 50 |
+
raise Exception(f"Failed to generate image after {max_retries} retries.")
|
| 51 |
+
|
| 52 |
+
return None
|
| 53 |
|
| 54 |
def make_me():
|
| 55 |
with gr.Row():
|