Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,10 +30,9 @@ def get_default_negative_prompt(existing_json: dict) -> str:
|
|
| 30 |
def generate_json_prompt(
|
| 31 |
prompt,
|
| 32 |
prompt_inspire_image,
|
| 33 |
-
use_inspire,
|
| 34 |
):
|
| 35 |
with torch.inference_mode():
|
| 36 |
-
if
|
| 37 |
output = vlm_pipe(image=prompt_inspire_image, prompt="")
|
| 38 |
else:
|
| 39 |
output = vlm_pipe(prompt=prompt)
|
|
@@ -46,7 +45,6 @@ def generate_json_prompt(
|
|
| 46 |
def generate_image(
|
| 47 |
prompt,
|
| 48 |
prompt_inspire_image,
|
| 49 |
-
use_inspire,
|
| 50 |
prompt_in_json,
|
| 51 |
negative_prompt="",
|
| 52 |
seed=42,
|
|
@@ -62,7 +60,7 @@ def generate_image(
|
|
| 62 |
with torch.inference_mode():
|
| 63 |
# If JSON prompt is empty or None, generate it first
|
| 64 |
if not prompt_in_json or prompt_in_json == "":
|
| 65 |
-
if
|
| 66 |
output = vlm_pipe(image=prompt_inspire_image, prompt="")
|
| 67 |
else:
|
| 68 |
output = vlm_pipe(prompt=prompt)
|
|
@@ -160,12 +158,11 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
|
|
| 160 |
with gr.Row(elem_id="col-container"):
|
| 161 |
with gr.Column(scale=1):
|
| 162 |
|
| 163 |
-
with gr.Accordion("Inspire from Image", open=False) as inspire_accordion:
|
| 164 |
prompt_inspire_image = gr.Image(
|
| 165 |
label="Inspiration Image",
|
| 166 |
type="pil",
|
| 167 |
)
|
| 168 |
-
use_inspire = gr.Checkbox(label="Use inspiration image", value=False)
|
| 169 |
|
| 170 |
prompt_generate = gr.Textbox(
|
| 171 |
label="Prompt",
|
|
@@ -180,10 +177,10 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
|
|
| 180 |
|
| 181 |
with gr.Row():
|
| 182 |
generate_json_btn = gr.Button("Generate JSON Prompt", variant="secondary")
|
| 183 |
-
generate_image_btn = gr.Button("Generate Image", variant="primary")
|
| 184 |
|
| 185 |
# Refine button - initially hidden
|
| 186 |
-
refine_btn = gr.Button("Refine
|
| 187 |
|
| 188 |
with gr.Accordion("Advanced Settings", open=False):
|
| 189 |
with gr.Row():
|
|
@@ -209,7 +206,6 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
|
|
| 209 |
inputs=[
|
| 210 |
prompt_generate,
|
| 211 |
prompt_inspire_image,
|
| 212 |
-
use_inspire,
|
| 213 |
],
|
| 214 |
outputs=[prompt_in_json],
|
| 215 |
)
|
|
@@ -220,7 +216,6 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
|
|
| 220 |
inputs=[
|
| 221 |
prompt_generate,
|
| 222 |
prompt_inspire_image,
|
| 223 |
-
use_inspire,
|
| 224 |
prompt_in_json,
|
| 225 |
negative_prompt,
|
| 226 |
seed,
|
|
|
|
| 30 |
def generate_json_prompt(
|
| 31 |
prompt,
|
| 32 |
prompt_inspire_image,
|
|
|
|
| 33 |
):
|
| 34 |
with torch.inference_mode():
|
| 35 |
+
if prompt_inspire_image is not None:
|
| 36 |
output = vlm_pipe(image=prompt_inspire_image, prompt="")
|
| 37 |
else:
|
| 38 |
output = vlm_pipe(prompt=prompt)
|
|
|
|
| 45 |
def generate_image(
|
| 46 |
prompt,
|
| 47 |
prompt_inspire_image,
|
|
|
|
| 48 |
prompt_in_json,
|
| 49 |
negative_prompt="",
|
| 50 |
seed=42,
|
|
|
|
| 60 |
with torch.inference_mode():
|
| 61 |
# If JSON prompt is empty or None, generate it first
|
| 62 |
if not prompt_in_json or prompt_in_json == "":
|
| 63 |
+
if prompt_inspire_image is not None:
|
| 64 |
output = vlm_pipe(image=prompt_inspire_image, prompt="")
|
| 65 |
else:
|
| 66 |
output = vlm_pipe(prompt=prompt)
|
|
|
|
| 158 |
with gr.Row(elem_id="col-container"):
|
| 159 |
with gr.Column(scale=1):
|
| 160 |
|
| 161 |
+
with gr.Accordion("Inspire from Image Reference", open=False) as inspire_accordion:
|
| 162 |
prompt_inspire_image = gr.Image(
|
| 163 |
label="Inspiration Image",
|
| 164 |
type="pil",
|
| 165 |
)
|
|
|
|
| 166 |
|
| 167 |
prompt_generate = gr.Textbox(
|
| 168 |
label="Prompt",
|
|
|
|
| 177 |
|
| 178 |
with gr.Row():
|
| 179 |
generate_json_btn = gr.Button("Generate JSON Prompt", variant="secondary")
|
| 180 |
+
generate_image_btn = gr.Button("Generate New Image", variant="primary")
|
| 181 |
|
| 182 |
# Refine button - initially hidden
|
| 183 |
+
refine_btn = gr.Button("Refine Existing Image", variant="primary", visible=False)
|
| 184 |
|
| 185 |
with gr.Accordion("Advanced Settings", open=False):
|
| 186 |
with gr.Row():
|
|
|
|
| 206 |
inputs=[
|
| 207 |
prompt_generate,
|
| 208 |
prompt_inspire_image,
|
|
|
|
| 209 |
],
|
| 210 |
outputs=[prompt_in_json],
|
| 211 |
)
|
|
|
|
| 216 |
inputs=[
|
| 217 |
prompt_generate,
|
| 218 |
prompt_inspire_image,
|
|
|
|
| 219 |
prompt_in_json,
|
| 220 |
negative_prompt,
|
| 221 |
seed,
|