Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,19 +45,24 @@ def duplicate_horizontally(img):
|
|
| 45 |
# Load the mask image
|
| 46 |
mask = Image.open("mask_square.png")
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
@spaces.GPU
|
| 49 |
def generate(image, prompt_user, progress=gr.Progress(track_tqdm=True)):
|
| 50 |
prompt_structure = "The two-panel image showcases the logo of a brand, [LEFT] the left panel is showing the logo [RIGHT] the right panel has this logo applied to "
|
| 51 |
prompt = prompt_structure + prompt_user
|
| 52 |
|
| 53 |
-
cropped_image = square_center_crop(image)
|
| 54 |
-
logo_dupli = duplicate_horizontally(cropped_image)
|
| 55 |
|
| 56 |
out = pipe(
|
| 57 |
prompt=prompt,
|
| 58 |
-
image=
|
| 59 |
mask_image=mask,
|
| 60 |
-
guidance_scale=
|
| 61 |
height=768,
|
| 62 |
width=1536,
|
| 63 |
num_inference_steps=28,
|
|
@@ -81,6 +86,9 @@ with gr.Blocks() as demo:
|
|
| 81 |
type="pil",
|
| 82 |
height=384
|
| 83 |
)
|
|
|
|
|
|
|
|
|
|
| 84 |
prompt_input = gr.Textbox(
|
| 85 |
label="Where should the logo be applied?",
|
| 86 |
placeholder="e.g., a coffee cup on a wooden table",
|
|
@@ -103,8 +111,12 @@ with gr.Blocks() as demo:
|
|
| 103 |
|
| 104 |
# Set up the click event
|
| 105 |
generate_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
fn=generate,
|
| 107 |
-
inputs=[
|
| 108 |
outputs=[output_image, output_side]
|
| 109 |
)
|
| 110 |
|
|
|
|
| 45 |
# Load the mask image
|
| 46 |
mask = Image.open("mask_square.png")
|
| 47 |
|
| 48 |
+
def crop_input(image):
|
| 49 |
+
cropped_image = square_center_crop(image)
|
| 50 |
+
logo_dupli = duplicate_horizontally(cropped_image)
|
| 51 |
+
return logo_dupli
|
| 52 |
+
|
| 53 |
@spaces.GPU
|
| 54 |
def generate(image, prompt_user, progress=gr.Progress(track_tqdm=True)):
|
| 55 |
prompt_structure = "The two-panel image showcases the logo of a brand, [LEFT] the left panel is showing the logo [RIGHT] the right panel has this logo applied to "
|
| 56 |
prompt = prompt_structure + prompt_user
|
| 57 |
|
| 58 |
+
#cropped_image = square_center_crop(image)
|
| 59 |
+
#logo_dupli = duplicate_horizontally(cropped_image)
|
| 60 |
|
| 61 |
out = pipe(
|
| 62 |
prompt=prompt,
|
| 63 |
+
image=image,
|
| 64 |
mask_image=mask,
|
| 65 |
+
guidance_scale=3.75,
|
| 66 |
height=768,
|
| 67 |
width=1536,
|
| 68 |
num_inference_steps=28,
|
|
|
|
| 86 |
type="pil",
|
| 87 |
height=384
|
| 88 |
)
|
| 89 |
+
cropped_image = gr.Image(
|
| 90 |
+
visible=False
|
| 91 |
+
)
|
| 92 |
prompt_input = gr.Textbox(
|
| 93 |
label="Where should the logo be applied?",
|
| 94 |
placeholder="e.g., a coffee cup on a wooden table",
|
|
|
|
| 111 |
|
| 112 |
# Set up the click event
|
| 113 |
generate_btn.click(
|
| 114 |
+
fn=crop_input,
|
| 115 |
+
inputs=[input_image],
|
| 116 |
+
outputs=[cropped_image]
|
| 117 |
+
).then(
|
| 118 |
fn=generate,
|
| 119 |
+
inputs=[cropped_image, prompt_input],
|
| 120 |
outputs=[output_image, output_side]
|
| 121 |
)
|
| 122 |
|