Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,9 @@ from diffusers import QwenImageEditPipeline, FlowMatchEulerDiscreteScheduler
|
|
11 |
from huggingface_hub import InferenceClient
|
12 |
import math
|
13 |
|
|
|
|
|
|
|
14 |
# --- Prompt Enhancement using Hugging Face InferenceClient ---
|
15 |
def polish_prompt_hf(original_prompt, system_prompt, img):
|
16 |
"""
|
@@ -417,7 +420,7 @@ def infer(
|
|
417 |
).images
|
418 |
|
419 |
# Return the first (and only) image
|
420 |
-
return images[0], seed
|
421 |
|
422 |
except Exception as e:
|
423 |
print(f"Error during inference: {e}")
|
@@ -488,17 +491,18 @@ with gr.Blocks(css=css) as demo:
|
|
488 |
scale=1
|
489 |
)
|
490 |
# Changed from Gallery to Image
|
491 |
-
result = gr.
|
492 |
label="Result",
|
493 |
show_label=True,
|
494 |
type="pil"
|
495 |
)
|
|
|
496 |
|
497 |
with gr.Row():
|
498 |
prompt = gr.Text(
|
499 |
label="Edit Instruction",
|
500 |
show_label=False,
|
501 |
-
placeholder="
|
502 |
container=False,
|
503 |
)
|
504 |
run_button = gr.Button("Edit!", variant="primary")
|
@@ -551,7 +555,7 @@ with gr.Blocks(css=css) as demo:
|
|
551 |
["./assets/pexels-pixabay-355465.jpg", "daylight, bright sunshine", "custom", "auto" ]
|
552 |
],
|
553 |
inputs=[input_image, prompt, illumination_dropdown, direction_dropdown],
|
554 |
-
outputs=[result, seed],
|
555 |
fn=infer,
|
556 |
cache_examples="lazy"
|
557 |
)
|
@@ -576,7 +580,7 @@ with gr.Blocks(css=css) as demo:
|
|
576 |
rewrite_prompt,
|
577 |
# Removed num_images_per_prompt from inputs
|
578 |
],
|
579 |
-
outputs=[result, seed],
|
580 |
)
|
581 |
|
582 |
if __name__ == "__main__":
|
|
|
11 |
from huggingface_hub import InferenceClient
|
12 |
import math
|
13 |
|
14 |
+
import base64
|
15 |
+
from io import BytesIO
|
16 |
+
|
17 |
# --- Prompt Enhancement using Hugging Face InferenceClient ---
|
18 |
def polish_prompt_hf(original_prompt, system_prompt, img):
|
19 |
"""
|
|
|
420 |
).images
|
421 |
|
422 |
# Return the first (and only) image
|
423 |
+
return [image,images[0]], seed, final_prompt
|
424 |
|
425 |
except Exception as e:
|
426 |
print(f"Error during inference: {e}")
|
|
|
491 |
scale=1
|
492 |
)
|
493 |
# Changed from Gallery to Image
|
494 |
+
result = gr.ImageSlider(
|
495 |
label="Result",
|
496 |
show_label=True,
|
497 |
type="pil"
|
498 |
)
|
499 |
+
final_prompt = gr.Textbox(label="Processed prompt")
|
500 |
|
501 |
with gr.Row():
|
502 |
prompt = gr.Text(
|
503 |
label="Edit Instruction",
|
504 |
show_label=False,
|
505 |
+
placeholder="describe the edit instruction",
|
506 |
container=False,
|
507 |
)
|
508 |
run_button = gr.Button("Edit!", variant="primary")
|
|
|
555 |
["./assets/pexels-pixabay-355465.jpg", "daylight, bright sunshine", "custom", "auto" ]
|
556 |
],
|
557 |
inputs=[input_image, prompt, illumination_dropdown, direction_dropdown],
|
558 |
+
outputs=[result, seed, final_prompt],
|
559 |
fn=infer,
|
560 |
cache_examples="lazy"
|
561 |
)
|
|
|
580 |
rewrite_prompt,
|
581 |
# Removed num_images_per_prompt from inputs
|
582 |
],
|
583 |
+
outputs=[result, seed, final_prompt],
|
584 |
)
|
585 |
|
586 |
if __name__ == "__main__":
|