Spaces:
Sleeping
Sleeping
lichorosario
commited on
Commit
·
bfb7036
1
Parent(s):
260ee77
feat: Corregir manejo de excepción en app.py
Browse filesEl manejo de excepción en app.py ha sido corregido para lanzar una excepción de tipo `gr.Error` en lugar de utilizar `gr.Alert`. Esto asegura que se capture y maneje adecuadamente cualquier error que ocurra durante el proceso de aumento de resolución de imágenes.
app.py
CHANGED
@@ -10,41 +10,45 @@ with open('loras.json', 'r') as f:
|
|
10 |
job = None
|
11 |
|
12 |
def infer(selected_index, prompt, style_prompt, inf_steps, guidance_scale, width, height, seed, lora_weight, progress=gr.Progress(track_tqdm=True)):
|
13 |
-
|
14 |
-
if selected_index is None:
|
15 |
-
raise gr.Error("You must select a LoRA before proceeding.")
|
16 |
-
|
17 |
-
selected_lora = loras[selected_index]
|
18 |
-
custom_model = selected_lora["repo"]
|
19 |
-
trigger_word = selected_lora["trigger_word"]
|
20 |
-
|
21 |
-
client = Client("fffiloni/sd-xl-custom-model")
|
22 |
-
result = client.submit(
|
23 |
-
custom_model=custom_model,
|
24 |
-
api_name="/load_model"
|
25 |
-
)
|
26 |
-
weight_name = result.result()[2]['value']
|
27 |
-
|
28 |
-
client = Client("fffiloni/sd-xl-custom-model")
|
29 |
-
prompt_arr = [trigger_word, prompt, style_prompt]
|
30 |
-
prompt = '. '.join([element.strip() for element in prompt_arr if element.strip() != ''])
|
31 |
-
|
32 |
-
job = client.submit(
|
33 |
-
custom_model=custom_model,
|
34 |
-
weight_name=weight_name,
|
35 |
-
prompt=prompt,
|
36 |
-
inf_steps=inf_steps,
|
37 |
-
guidance_scale=guidance_scale,
|
38 |
-
width=width,
|
39 |
-
height=height,
|
40 |
-
seed=seed,
|
41 |
-
lora_weight=lora_weight,
|
42 |
-
api_name="/infer"
|
43 |
-
)
|
44 |
-
result = job.result()
|
45 |
-
new_result = result + (prompt, )
|
46 |
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
def cancel_infer():
|
50 |
global job
|
|
|
10 |
job = None
|
11 |
|
12 |
def infer(selected_index, prompt, style_prompt, inf_steps, guidance_scale, width, height, seed, lora_weight, progress=gr.Progress(track_tqdm=True)):
|
13 |
+
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
global job
|
16 |
+
if selected_index is None:
|
17 |
+
raise gr.Error("You must select a LoRA before proceeding.")
|
18 |
+
|
19 |
+
selected_lora = loras[selected_index]
|
20 |
+
custom_model = selected_lora["repo"]
|
21 |
+
trigger_word = selected_lora["trigger_word"]
|
22 |
+
|
23 |
+
client = Client("fffiloni/sd-xl-custom-model")
|
24 |
+
result = client.submit(
|
25 |
+
custom_model=custom_model,
|
26 |
+
api_name="/load_model"
|
27 |
+
)
|
28 |
+
weight_name = result.result()[2]['value']
|
29 |
+
|
30 |
+
client = Client("fffiloni/sd-xl-custom-model")
|
31 |
+
prompt_arr = [trigger_word, prompt, style_prompt]
|
32 |
+
prompt = '. '.join([element.strip() for element in prompt_arr if element.strip() != ''])
|
33 |
+
|
34 |
+
job = client.submit(
|
35 |
+
custom_model=custom_model,
|
36 |
+
weight_name=weight_name,
|
37 |
+
prompt=prompt,
|
38 |
+
inf_steps=inf_steps,
|
39 |
+
guidance_scale=guidance_scale,
|
40 |
+
width=width,
|
41 |
+
height=height,
|
42 |
+
seed=seed,
|
43 |
+
lora_weight=lora_weight,
|
44 |
+
api_name="/infer"
|
45 |
+
)
|
46 |
+
result = job.result()
|
47 |
+
new_result = result + (prompt, )
|
48 |
+
|
49 |
+
return new_result
|
50 |
+
except Exception as e:
|
51 |
+
gr.Warning("Error: " + str(e))
|
52 |
|
53 |
def cancel_infer():
|
54 |
global job
|