Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,10 +13,11 @@ MAX_SEED = np.iinfo(np.int32).max
|
|
| 13 |
|
| 14 |
pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to("cuda")
|
| 15 |
|
| 16 |
-
# Add all
|
| 17 |
pipe.load_lora_weights("prithivMLmods/PhotoCleanser-i2i", weight_name="PhotoCleanser-i2i.safetensors", adapter_name="cleanser")
|
| 18 |
pipe.load_lora_weights("prithivMLmods/Photo-Restore-i2i", weight_name="Photo-Restore-i2i.safetensors", adapter_name="restorer")
|
| 19 |
pipe.load_lora_weights("prithivMLmods/Polaroid-Warm-i2i", weight_name="Polaroid-Warm-i2i.safetensors", adapter_name="polaroid")
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
@spaces.GPU
|
|
@@ -47,6 +48,8 @@ def infer(input_image, prompt, lora_adapter, seed=42, randomize_seed=False, guid
|
|
| 47 |
pipe.set_adapters(["restorer"], adapter_weights=[1.0])
|
| 48 |
elif lora_adapter == "PolaroidWarm":
|
| 49 |
pipe.set_adapters(["polaroid"], adapter_weights=[1.0])
|
|
|
|
|
|
|
| 50 |
|
| 51 |
if randomize_seed:
|
| 52 |
seed = random.randint(0, MAX_SEED)
|
|
@@ -95,11 +98,6 @@ with gr.Blocks(css=css) as demo:
|
|
| 95 |
with gr.Row():
|
| 96 |
with gr.Column():
|
| 97 |
input_image = gr.Image(label="Upload the image for editing", type="pil", height="300")
|
| 98 |
-
lora_adapter = gr.Dropdown(
|
| 99 |
-
label="Choose Adapter",
|
| 100 |
-
choices=["PhotoCleanser", "PhotoRestorer", "PolaroidWarm"],
|
| 101 |
-
value="PhotoCleanser"
|
| 102 |
-
)
|
| 103 |
with gr.Row():
|
| 104 |
prompt = gr.Text(
|
| 105 |
label="Prompt",
|
|
@@ -140,7 +138,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 140 |
with gr.Column():
|
| 141 |
result = gr.Image(label="Result", show_label=False, interactive=False, format="png")
|
| 142 |
reuse_button = gr.Button("Reuse this image", visible=False)
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
# Consolidate all examples into a single component with a new "Selected LoRA" column
|
| 145 |
gr.Examples(
|
| 146 |
examples=[
|
|
@@ -173,6 +177,16 @@ with gr.Blocks(css=css) as demo:
|
|
| 173 |
"polaroid/2.png",
|
| 174 |
"[photo content], give the image a classic Polaroid look with warm, saturated colors, gentle fading, and a subtle vignette effect, evoking a sense of timeless memories.",
|
| 175 |
"PolaroidWarm"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
]
|
| 177 |
],
|
| 178 |
# The inputs now include the lora_adapter dropdown
|
|
|
|
| 13 |
|
| 14 |
pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to("cuda")
|
| 15 |
|
| 16 |
+
# Add all four adapters to the app with unique names
|
| 17 |
pipe.load_lora_weights("prithivMLmods/PhotoCleanser-i2i", weight_name="PhotoCleanser-i2i.safetensors", adapter_name="cleanser")
|
| 18 |
pipe.load_lora_weights("prithivMLmods/Photo-Restore-i2i", weight_name="Photo-Restore-i2i.safetensors", adapter_name="restorer")
|
| 19 |
pipe.load_lora_weights("prithivMLmods/Polaroid-Warm-i2i", weight_name="Polaroid-Warm-i2i.safetensors", adapter_name="polaroid")
|
| 20 |
+
pipe.load_lora_weights("prithivMLmods/Monochrome-Pencil", weight_name="Monochrome-Pencil-i2i.safetensors", adapter_name="pencil")
|
| 21 |
|
| 22 |
|
| 23 |
@spaces.GPU
|
|
|
|
| 48 |
pipe.set_adapters(["restorer"], adapter_weights=[1.0])
|
| 49 |
elif lora_adapter == "PolaroidWarm":
|
| 50 |
pipe.set_adapters(["polaroid"], adapter_weights=[1.0])
|
| 51 |
+
elif lora_adapter == "MonochromePencil":
|
| 52 |
+
pipe.set_adapters(["pencil"], adapter_weights=[1.0])
|
| 53 |
|
| 54 |
if randomize_seed:
|
| 55 |
seed = random.randint(0, MAX_SEED)
|
|
|
|
| 98 |
with gr.Row():
|
| 99 |
with gr.Column():
|
| 100 |
input_image = gr.Image(label="Upload the image for editing", type="pil", height="300")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
with gr.Row():
|
| 102 |
prompt = gr.Text(
|
| 103 |
label="Prompt",
|
|
|
|
| 138 |
with gr.Column():
|
| 139 |
result = gr.Image(label="Result", show_label=False, interactive=False, format="png")
|
| 140 |
reuse_button = gr.Button("Reuse this image", visible=False)
|
| 141 |
+
with gr.Row():
|
| 142 |
+
lora_adapter = gr.Dropdown(
|
| 143 |
+
label="Choose Adapter",
|
| 144 |
+
choices=["PhotoCleanser", "PhotoRestorer", "PolaroidWarm", "MonochromePencil"],
|
| 145 |
+
value="PhotoCleanser"
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
# Consolidate all examples into a single component with a new "Selected LoRA" column
|
| 149 |
gr.Examples(
|
| 150 |
examples=[
|
|
|
|
| 177 |
"polaroid/2.png",
|
| 178 |
"[photo content], give the image a classic Polaroid look with warm, saturated colors, gentle fading, and a subtle vignette effect, evoking a sense of timeless memories.",
|
| 179 |
"PolaroidWarm"
|
| 180 |
+
],
|
| 181 |
+
[
|
| 182 |
+
"pencil/1.png",
|
| 183 |
+
"[photo content], transform the image into a detailed monochrome pencil sketch, emphasizing sharp lines, textures, and shading for a classic hand-drawn look.",
|
| 184 |
+
"MonochromePencil"
|
| 185 |
+
],
|
| 186 |
+
[
|
| 187 |
+
"pencil/2.png",
|
| 188 |
+
"[photo content], convert the photo into a realistic graphite pencil drawing, capturing the subject's form and depth with varied strokes and contrast.",
|
| 189 |
+
"MonochromePencil"
|
| 190 |
]
|
| 191 |
],
|
| 192 |
# The inputs now include the lora_adapter dropdown
|