Spaces:
Running
on
Zero
Running
on
Zero
gokaygokay
commited on
Commit
•
e18b028
1
Parent(s):
0598d11
prompt
Browse files
app.py
CHANGED
@@ -162,9 +162,18 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue", secondar
|
|
162 |
with gr.Group(elem_classes="input-group"):
|
163 |
input_image = gr.Image(label="Input Image (Florence-2 Captioner)", height=512)
|
164 |
|
165 |
-
with gr.Accordion("
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
167 |
negative_prompt = gr.Textbox(label="Negative Prompt")
|
|
|
|
|
|
|
|
|
168 |
use_enhancer = gr.Checkbox(label="Use Prompt Enhancer", value=False)
|
169 |
use_llm_generator = gr.Checkbox(label="Use LLM Prompt Generator", value=False)
|
170 |
llm_provider = gr.Dropdown(
|
@@ -185,38 +194,45 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue", secondar
|
|
185 |
value="Random",
|
186 |
visible=False
|
187 |
)
|
188 |
-
|
189 |
-
|
190 |
-
width = gr.Slider(label="Width", minimum=512, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
191 |
-
height = gr.Slider(label="Height", minimum=512, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
192 |
-
guidance_scale = gr.Slider(label="Guidance Scale", minimum=0.0, maximum=7.5, step=0.1, value=4.5)
|
193 |
-
num_inference_steps = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=40)
|
194 |
|
195 |
generate_btn = gr.Button("Generate Image", elem_classes="submit-btn")
|
196 |
|
197 |
with gr.Column(scale=1):
|
198 |
with gr.Group(elem_classes="output-group"):
|
199 |
output_image = gr.Image(label="Result", elem_id="gallery", show_label=False)
|
200 |
-
final_prompt = gr.Textbox(label="Final Prompt Used")
|
201 |
used_seed = gr.Number(label="Seed Used")
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
)
|
215 |
|
216 |
generate_btn.click(
|
217 |
fn=process_workflow,
|
218 |
inputs=[
|
219 |
-
input_image,
|
220 |
seed, randomize_seed, width, height, guidance_scale, num_inference_steps, negative_prompt
|
221 |
],
|
222 |
outputs=[output_image, final_prompt, used_seed]
|
|
|
162 |
with gr.Group(elem_classes="input-group"):
|
163 |
input_image = gr.Image(label="Input Image (Florence-2 Captioner)", height=512)
|
164 |
|
165 |
+
with gr.Accordion("Image Settings", open=False):
|
166 |
+
width = gr.Slider(label="Width", minimum=512, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
167 |
+
height = gr.Slider(label="Height", minimum=512, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
168 |
+
guidance_scale = gr.Slider(label="Guidance Scale", minimum=0.0, maximum=7.5, step=0.1, value=4.5)
|
169 |
+
num_inference_steps = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=40)
|
170 |
+
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
|
171 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
|
172 |
negative_prompt = gr.Textbox(label="Negative Prompt")
|
173 |
+
|
174 |
+
with gr.Column(scale=1):
|
175 |
+
with gr.Group(elem_classes="input-group"):
|
176 |
+
text_prompt = gr.Textbox(label="Text Prompt (optional, used if no image is uploaded)")
|
177 |
use_enhancer = gr.Checkbox(label="Use Prompt Enhancer", value=False)
|
178 |
use_llm_generator = gr.Checkbox(label="Use LLM Prompt Generator", value=False)
|
179 |
llm_provider = gr.Dropdown(
|
|
|
194 |
value="Random",
|
195 |
visible=False
|
196 |
)
|
197 |
+
generate_prompt_btn = gr.Button("Generate Prompt", elem_classes="submit-btn")
|
198 |
+
final_prompt = gr.Textbox(label="Final Prompt", interactive=False)
|
|
|
|
|
|
|
|
|
199 |
|
200 |
generate_btn = gr.Button("Generate Image", elem_classes="submit-btn")
|
201 |
|
202 |
with gr.Column(scale=1):
|
203 |
with gr.Group(elem_classes="output-group"):
|
204 |
output_image = gr.Image(label="Result", elem_id="gallery", show_label=False)
|
|
|
205 |
used_seed = gr.Number(label="Seed Used")
|
206 |
+
|
207 |
+
# ... existing code for update_llm_visibility function ...
|
208 |
+
|
209 |
+
def generate_prompt(image, text_prompt, use_enhancer, use_llm_generator, llm_provider, llm_model, prompt_type):
|
210 |
+
if image is not None:
|
211 |
+
caption = florence_caption(image)
|
212 |
+
if use_llm_generator:
|
213 |
+
prompt = generate_llm_prompt(caption, llm_provider, llm_model, prompt_type)
|
214 |
+
else:
|
215 |
+
prompt = caption
|
216 |
+
else:
|
217 |
+
prompt = text_prompt
|
218 |
+
|
219 |
+
if use_enhancer:
|
220 |
+
prompt = enhance_prompt(prompt)
|
221 |
+
|
222 |
+
return prompt
|
223 |
+
|
224 |
+
generate_prompt_btn.click(
|
225 |
+
fn=generate_prompt,
|
226 |
+
inputs=[
|
227 |
+
input_image, text_prompt, use_enhancer, use_llm_generator, llm_provider, llm_model, prompt_type
|
228 |
+
],
|
229 |
+
outputs=[final_prompt]
|
230 |
)
|
231 |
|
232 |
generate_btn.click(
|
233 |
fn=process_workflow,
|
234 |
inputs=[
|
235 |
+
input_image, final_prompt, use_enhancer, use_llm_generator, llm_provider, llm_model, prompt_type,
|
236 |
seed, randomize_seed, width, height, guidance_scale, num_inference_steps, negative_prompt
|
237 |
],
|
238 |
outputs=[output_image, final_prompt, used_seed]
|