Spaces:
Runtime error
Runtime error
feat: Enable lazy loading of examples in app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ client = None
|
|
13 |
job = None
|
14 |
|
15 |
|
16 |
-
def infer(
|
17 |
global job
|
18 |
global client
|
19 |
|
@@ -21,16 +21,12 @@ def infer(selected_space_index, prompt, seed=42, randomize_seed=False, width=102
|
|
21 |
max_attempts = len(flux_1_schell_spaces)
|
22 |
attempts = 0
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
print(f"Failed to load custom model from {selected_space}: {e}")
|
31 |
-
selected_space_index = (selected_space_index + 1) % len(flux_1_schell_spaces)
|
32 |
-
client = None
|
33 |
-
attempts += 1
|
34 |
|
35 |
if client is None:
|
36 |
raise gr.Error("Failed to load client after trying all spaces.")
|
@@ -76,7 +72,7 @@ with gr.Blocks(css=css) as demo:
|
|
76 |
12B param rectified flow transformer distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/) for 4 step generation
|
77 |
[[blog](https://blackforestlabs.ai/2024/07/31/announcing-black-forest-labs/)] [[model](https://huggingface.co/black-forest-labs/FLUX.1-schnell)]
|
78 |
""")
|
79 |
-
space = gr.Radio(flux_1_schell_spaces, label="HF Space")
|
80 |
|
81 |
|
82 |
with gr.Row():
|
@@ -144,7 +140,7 @@ with gr.Blocks(css=css) as demo:
|
|
144 |
gr.on(
|
145 |
triggers=[run_button.click, prompt.submit],
|
146 |
fn = infer,
|
147 |
-
inputs = [
|
148 |
outputs = [selected_space_index, space, result, seed]
|
149 |
)
|
150 |
|
|
|
13 |
job = None
|
14 |
|
15 |
|
16 |
+
def infer(selected_space, prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_inference_steps=4, progress=gr.Progress(track_tqdm=True)):
|
17 |
global job
|
18 |
global client
|
19 |
|
|
|
21 |
max_attempts = len(flux_1_schell_spaces)
|
22 |
attempts = 0
|
23 |
|
24 |
+
try:
|
25 |
+
client = Client(selected_space)
|
26 |
+
print(f"Loaded custom model from {selected_space}")
|
27 |
+
except ValueError as e:
|
28 |
+
print(f"Failed to load custom model from {selected_space}: {e}")
|
29 |
+
client = None
|
|
|
|
|
|
|
|
|
30 |
|
31 |
if client is None:
|
32 |
raise gr.Error("Failed to load client after trying all spaces.")
|
|
|
72 |
12B param rectified flow transformer distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/) for 4 step generation
|
73 |
[[blog](https://blackforestlabs.ai/2024/07/31/announcing-black-forest-labs/)] [[model](https://huggingface.co/black-forest-labs/FLUX.1-schnell)]
|
74 |
""")
|
75 |
+
space = gr.Radio(flux_1_schell_spaces, label="HF Space", value=flux_1_schell_spaces[0])
|
76 |
|
77 |
|
78 |
with gr.Row():
|
|
|
140 |
gr.on(
|
141 |
triggers=[run_button.click, prompt.submit],
|
142 |
fn = infer,
|
143 |
+
inputs = [space, prompt, seed, randomize_seed, width, height, num_inference_steps],
|
144 |
outputs = [selected_space_index, space, result, seed]
|
145 |
)
|
146 |
|