Lisandro commited on
Commit
b3fc20d
·
1 Parent(s): fab03a8

feat: Fix selected space loading in app.py

Browse files

This commit fixes the loading of the selected space in the `infer` function of `app.py`. Previously, the code was not properly handling the case when the selected space failed to load. The updated code now attempts to load the next available space from the list of spaces until a successful load is achieved. This ensures that the model is properly loaded and prevents any errors from occurring during inference.

Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -49,9 +49,10 @@ def infer(selected_space_index, prompt, seed=42, randomize_seed=False, width=102
49
  except ValueError as e:
50
  client = None
51
  selected_space_index = (selected_space_index + 1) % len(flux_1_schell_spaces)
 
52
  raise gr.Error(e)
53
 
54
- return (selected_space_index, ) + result
55
 
56
  examples = [
57
  "a tiny astronaut hatching from an egg on the moon",
@@ -77,6 +78,9 @@ with gr.Blocks(css=css) as demo:
77
  """)
78
 
79
  with gr.Row():
 
 
 
80
 
81
  prompt = gr.Text(
82
  label="Prompt",
@@ -143,7 +147,7 @@ with gr.Blocks(css=css) as demo:
143
  triggers=[run_button.click, prompt.submit],
144
  fn = infer,
145
  inputs = [selected_space_index, prompt, seed, randomize_seed, width, height, num_inference_steps],
146
- outputs = [selected_space_index, result, seed]
147
  )
148
 
149
  demo.launch()
 
49
  except ValueError as e:
50
  client = None
51
  selected_space_index = (selected_space_index + 1) % len(flux_1_schell_spaces)
52
+ selected_space = flux_1_schell_spaces[selected_space_index]
53
  raise gr.Error(e)
54
 
55
+ return (selected_space_index, selected_space) + result
56
 
57
  examples = [
58
  "a tiny astronaut hatching from an egg on the moon",
 
78
  """)
79
 
80
  with gr.Row():
81
+ space = gr.Text(
82
+ label="HF Space",
83
+ )
84
 
85
  prompt = gr.Text(
86
  label="Prompt",
 
147
  triggers=[run_button.click, prompt.submit],
148
  fn = infer,
149
  inputs = [selected_space_index, prompt, seed, randomize_seed, width, height, num_inference_steps],
150
+ outputs = [selected_space_index, space, result, seed]
151
  )
152
 
153
  demo.launch()