RedSparkie commited on
Commit
0685e13
1 Parent(s): bfbf18d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -26,7 +26,7 @@ LORA_OPTIONS = {
26
  DEFAULT_MODEL = "black-forest-labs/FLUX.1-dev"
27
 
28
  # Función principal
29
- def query(lora_name, prompt, steps=20, cfg_scale=3.5, randomize_seed=True, seed=-1, width=1024, height=1024):
30
  if not prompt:
31
  return None
32
 
@@ -52,7 +52,7 @@ def query(lora_name, prompt, steps=20, cfg_scale=3.5, randomize_seed=True, seed=
52
  if response.status_code == 200:
53
  try:
54
  image = Image.open(io.BytesIO(response.content))
55
- return image, seed
56
  except Exception as e:
57
  raise gr.Error(f"Error al procesar la imagen: {e}")
58
  elif response.status_code == 503:
@@ -69,7 +69,7 @@ with gr.Blocks() as app:
69
  gr.Markdown("<center><h1>Generador de Imágenes</h1></center>")
70
 
71
  with gr.Row():
72
- lora_selector = gr.Dropdown(label="Modelo", choices=list(LORA_OPTIONS.keys()), value="")
73
  text_prompt = gr.Textbox(label="Prompt", placeholder="Describe tu imagen")
74
 
75
  with gr.Row():
@@ -78,6 +78,7 @@ with gr.Blocks() as app:
78
  steps = gr.Slider(label="Pasos", minimum=1, maximum=100, step=1, value=20)
79
  cfg = gr.Slider(label="CFG Scale", minimum=1, maximum=20, step=0.5, value=3.5)
80
  randomize_seed = gr.Checkbox(label="Randomizar semilla", value=True)
 
81
 
82
  image_output = gr.Image(type="pil", label="Resultado")
83
  seed_output = gr.Textbox(label="Semilla utilizada", interactive=False)
@@ -85,8 +86,8 @@ with gr.Blocks() as app:
85
 
86
  generate_button.click(
87
  query,
88
- inputs=[lora_selector, text_prompt, steps, cfg, randomize_seed, -1, width, height],
89
  outputs=[image_output, seed_output]
90
  )
91
 
92
- app.launch(share=True)
 
26
  DEFAULT_MODEL = "black-forest-labs/FLUX.1-dev"
27
 
28
  # Función principal
29
+ def query(lora_name, prompt, steps, cfg_scale, randomize_seed, seed, width, height):
30
  if not prompt:
31
  return None
32
 
 
52
  if response.status_code == 200:
53
  try:
54
  image = Image.open(io.BytesIO(response.content))
55
+ return image, str(seed)
56
  except Exception as e:
57
  raise gr.Error(f"Error al procesar la imagen: {e}")
58
  elif response.status_code == 503:
 
69
  gr.Markdown("<center><h1>Generador de Imágenes</h1></center>")
70
 
71
  with gr.Row():
72
+ lora_selector = gr.Dropdown(label="Modelo", choices=list(LORA_OPTIONS.keys()), value="", allow_custom_value=True)
73
  text_prompt = gr.Textbox(label="Prompt", placeholder="Describe tu imagen")
74
 
75
  with gr.Row():
 
78
  steps = gr.Slider(label="Pasos", minimum=1, maximum=100, step=1, value=20)
79
  cfg = gr.Slider(label="CFG Scale", minimum=1, maximum=20, step=0.5, value=3.5)
80
  randomize_seed = gr.Checkbox(label="Randomizar semilla", value=True)
81
+ seed = gr.Textbox(label="Semilla", placeholder="-1 para aleatorio", value="-1")
82
 
83
  image_output = gr.Image(type="pil", label="Resultado")
84
  seed_output = gr.Textbox(label="Semilla utilizada", interactive=False)
 
86
 
87
  generate_button.click(
88
  query,
89
+ inputs=[lora_selector, text_prompt, steps, cfg, randomize_seed, seed, width, height],
90
  outputs=[image_output, seed_output]
91
  )
92
 
93
+ app.launch(share=True)