Spaces:
Runtime error
Runtime error
wew
Browse files- .gitignore +3 -2
- app.py +7 -3
.gitignore
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
./_pycache_/*
|
| 4 |
__pycache__/controlnet_flux.cpython-310.pyc
|
| 5 |
__pycache__/pipeline_flux_controlnet_inpaint.cpython-310.pyc
|
| 6 |
__pycache__/transformer_flux.cpython-310.pyc
|
|
|
|
|
|
| 1 |
+
__pycache__
|
| 2 |
+
__pycache__/*
|
| 3 |
./_pycache_/*
|
| 4 |
__pycache__/controlnet_flux.cpython-310.pyc
|
| 5 |
__pycache__/pipeline_flux_controlnet_inpaint.cpython-310.pyc
|
| 6 |
__pycache__/transformer_flux.cpython-310.pyc
|
| 7 |
+
__pycache__/pipeline_flux_cnet.cpython-310.pyc
|
app.py
CHANGED
|
@@ -10,7 +10,7 @@ from PIL import Image, ImageDraw
|
|
| 10 |
import numpy as np
|
| 11 |
import subprocess
|
| 12 |
|
| 13 |
-
subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
|
| 14 |
|
| 15 |
|
| 16 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
@@ -92,7 +92,7 @@ def create_diptych_image(image):
|
|
| 92 |
return diptych
|
| 93 |
|
| 94 |
@spaces.GPU()
|
| 95 |
-
def inpaint_image(image, prompt, editor_value):
|
| 96 |
# Load image and mask
|
| 97 |
size = (1536, 768)
|
| 98 |
image = load_image(image).convert("RGB").resize((768, 768))
|
|
@@ -125,10 +125,13 @@ def inpaint_image(image, prompt, editor_value):
|
|
| 125 |
# Convert to bfloat16 to match model dtype
|
| 126 |
full_attn_scale_mask = full_attn_scale_mask.to(device=pipe.transformer.device, dtype=torch.bfloat16)
|
| 127 |
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
# Inpaint
|
| 130 |
result = pipe(
|
| 131 |
-
prompt=
|
| 132 |
height=size[1],
|
| 133 |
width=size[0],
|
| 134 |
control_image=diptych_image,
|
|
@@ -149,6 +152,7 @@ iface = gr.Interface(
|
|
| 149 |
inputs=[
|
| 150 |
gr.Image(type="filepath", label="Upload Image"),
|
| 151 |
gr.Textbox(lines=2, placeholder="Enter your prompt here (e.g., 'wearing a christmas hat, in a busy street')", label="Prompt"),
|
|
|
|
| 152 |
gr.ImageEditor(type="pil", label="Image with Mask", sources="upload", interactive=True)
|
| 153 |
],
|
| 154 |
outputs=[
|
|
|
|
| 10 |
import numpy as np
|
| 11 |
import subprocess
|
| 12 |
|
| 13 |
+
# subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
|
| 14 |
|
| 15 |
|
| 16 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
|
| 92 |
return diptych
|
| 93 |
|
| 94 |
@spaces.GPU()
|
| 95 |
+
def inpaint_image(image, prompt, subject, editor_value):
|
| 96 |
# Load image and mask
|
| 97 |
size = (1536, 768)
|
| 98 |
image = load_image(image).convert("RGB").resize((768, 768))
|
|
|
|
| 125 |
# Convert to bfloat16 to match model dtype
|
| 126 |
full_attn_scale_mask = full_attn_scale_mask.to(device=pipe.transformer.device, dtype=torch.bfloat16)
|
| 127 |
|
| 128 |
+
subject_name=subject
|
| 129 |
+
target_text_prompt=prompt
|
| 130 |
+
prompt_final=f'A two side-by-side image of same {subject_name}. LEFT: a photo of the {subject_name}; RIGHT: a photo of the {subject_name} {target_text_prompt}.'
|
| 131 |
|
| 132 |
# Inpaint
|
| 133 |
result = pipe(
|
| 134 |
+
prompt=prompt_final,
|
| 135 |
height=size[1],
|
| 136 |
width=size[0],
|
| 137 |
control_image=diptych_image,
|
|
|
|
| 152 |
inputs=[
|
| 153 |
gr.Image(type="filepath", label="Upload Image"),
|
| 154 |
gr.Textbox(lines=2, placeholder="Enter your prompt here (e.g., 'wearing a christmas hat, in a busy street')", label="Prompt"),
|
| 155 |
+
gr.Textbox(lines=1, placeholder="Enter your subject", label="Subject"),
|
| 156 |
gr.ImageEditor(type="pil", label="Image with Mask", sources="upload", interactive=True)
|
| 157 |
],
|
| 158 |
outputs=[
|