gokaygokay commited on
Commit
90a65c0
·
verified ·
1 Parent(s): cec9f33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -139,8 +139,8 @@ def generate_image(prompt, negative_prompt, seed, randomize_seed, width, height,
139
 
140
  # Gradio Interface
141
  @spaces.GPU
142
- def process_workflow(image, text_prompt, use_vlm, use_enhancer, model_choice, vlm_model_choice, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
143
- if use_vlm and image is not None:
144
  if vlm_model_choice == "Long Captioner":
145
  prompt = create_captions_rich(image)
146
  else: # Florence
@@ -182,23 +182,19 @@ title = """<h1 align="center">VLM Captioner + Prompt Enhancer + Kolors Image Gen
182
  </center></p>
183
  """
184
 
185
- # Gradio Interface
186
  with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue", secondary_hue="gray")) as demo:
187
  gr.HTML(title)
188
 
189
  with gr.Row():
190
  with gr.Column(scale=1):
191
  with gr.Group(elem_classes="input-group"):
192
- input_image = gr.Image(label="Input Image for VLM")
193
- use_vlm = gr.Checkbox(label="Use VLM Captioner", value=False)
194
  vlm_model_choice = gr.Radio(["Long Captioner", "Florence"], label="VLM Model", value="Long Captioner")
195
 
196
- with gr.Group(elem_classes="input-group"):
197
- text_prompt = gr.Textbox(label="Text Prompt")
198
  use_enhancer = gr.Checkbox(label="Use Prompt Enhancer", value=False)
199
  model_choice = gr.Radio(["Medium", "Long"], label="Enhancer Model", value="Long")
200
-
201
- with gr.Accordion("Advanced Settings", open=False):
202
  negative_prompt = gr.Textbox(label="Negative Prompt")
203
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
204
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
@@ -218,7 +214,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue", secondar
218
  generate_btn.click(
219
  fn=process_workflow,
220
  inputs=[
221
- input_image, text_prompt, use_vlm, use_enhancer, model_choice, vlm_model_choice,
222
  negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps
223
  ],
224
  outputs=[output_image, final_prompt, used_seed]
 
139
 
140
  # Gradio Interface
141
  @spaces.GPU
142
+ def process_workflow(image, text_prompt, vlm_model_choice, use_enhancer, model_choice, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
143
+ if image is not None:
144
  if vlm_model_choice == "Long Captioner":
145
  prompt = create_captions_rich(image)
146
  else: # Florence
 
182
  </center></p>
183
  """
184
 
 
185
  with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue", secondary_hue="gray")) as demo:
186
  gr.HTML(title)
187
 
188
  with gr.Row():
189
  with gr.Column(scale=1):
190
  with gr.Group(elem_classes="input-group"):
191
+ input_image = gr.Image(label="Input Image (VLM Captioner)")
 
192
  vlm_model_choice = gr.Radio(["Long Captioner", "Florence"], label="VLM Model", value="Long Captioner")
193
 
194
+ with gr.Accordion("Advanced Settings", open=False):
195
+ text_prompt = gr.Textbox(label="Text Prompt (optional, used if no image is uploaded)")
196
  use_enhancer = gr.Checkbox(label="Use Prompt Enhancer", value=False)
197
  model_choice = gr.Radio(["Medium", "Long"], label="Enhancer Model", value="Long")
 
 
198
  negative_prompt = gr.Textbox(label="Negative Prompt")
199
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
200
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
 
214
  generate_btn.click(
215
  fn=process_workflow,
216
  inputs=[
217
+ input_image, text_prompt, vlm_model_choice, use_enhancer, model_choice,
218
  negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps
219
  ],
220
  outputs=[output_image, final_prompt, used_seed]