Spaces:
Running on Zero
Running on Zero
update app
Browse files
app.py
CHANGED
|
@@ -99,19 +99,15 @@ if torch.cuda.is_available():
|
|
| 99 |
|
| 100 |
print("Using device:", device)
|
| 101 |
|
| 102 |
-
# --- Main Model Initialization ---
|
| 103 |
MAX_SEED = np.iinfo(np.int32).max
|
| 104 |
pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to("cuda")
|
| 105 |
|
| 106 |
-
|
| 107 |
-
pipe.load_lora_weights("prithivMLmods/
|
| 108 |
-
pipe.load_lora_weights("prithivMLmods/
|
| 109 |
-
pipe.load_lora_weights("prithivMLmods/
|
| 110 |
-
pipe.load_lora_weights("
|
| 111 |
-
pipe.load_lora_weights("prithivMLmods/LZO-1-Preview", weight_name="LZO-1-Preview.safetensors", adapter_name="lzo")
|
| 112 |
-
pipe.load_lora_weights("prithivMLmods/Kontext-Watermark-Remover", weight_name="Kontext-Watermark-Remover.safetensors", adapter_name="watermark-remover")
|
| 113 |
|
| 114 |
-
# --- Upscaler Model Initialization ---
|
| 115 |
aura_sr = AuraSR.from_pretrained("fal/AuraSR-v2")
|
| 116 |
|
| 117 |
@spaces.GPU
|
|
@@ -122,18 +118,16 @@ def infer(input_image, prompt, lora_adapter, upscale_image, seed=42, randomize_s
|
|
| 122 |
if not input_image:
|
| 123 |
raise gr.Error("Please upload an image for editing.")
|
| 124 |
|
| 125 |
-
if lora_adapter == "
|
| 126 |
-
pipe.set_adapters(["
|
| 127 |
-
elif lora_adapter == "
|
| 128 |
-
pipe.set_adapters(["
|
| 129 |
-
elif lora_adapter == "
|
| 130 |
-
pipe.set_adapters(["
|
| 131 |
-
elif lora_adapter == "
|
| 132 |
-
pipe.set_adapters(["
|
| 133 |
-
elif lora_adapter == "
|
| 134 |
-
pipe.set_adapters(["
|
| 135 |
-
elif lora_adapter == "Kontext-Watermark-Remover":
|
| 136 |
-
pipe.set_adapters(["watermark-remover"], adapter_weights=[1.0])
|
| 137 |
|
| 138 |
if randomize_seed:
|
| 139 |
seed = random.randint(0, MAX_SEED)
|
|
@@ -221,12 +215,12 @@ with gr.Blocks(css=css, theme=orange_red_theme) as demo:
|
|
| 221 |
with gr.Column():
|
| 222 |
output_slider = ImageSlider(label="Before / After", show_label=False, interactive=False)
|
| 223 |
reuse_button = gr.Button("Reuse this image", visible=False)
|
| 224 |
-
|
| 225 |
with gr.Row():
|
| 226 |
lora_adapter = gr.Dropdown(
|
| 227 |
label="Chosen LoRA",
|
| 228 |
-
choices=["
|
| 229 |
-
value="
|
| 230 |
)
|
| 231 |
|
| 232 |
with gr.Row():
|
|
@@ -234,14 +228,11 @@ with gr.Blocks(css=css, theme=orange_red_theme) as demo:
|
|
| 234 |
|
| 235 |
gr.Examples(
|
| 236 |
examples=[
|
| 237 |
-
["
|
| 238 |
-
["
|
| 239 |
-
["
|
| 240 |
-
["
|
| 241 |
-
["
|
| 242 |
-
["photorestore/2.png", "[photo content], restore and enhance the image by repairing any damage, scratches, or fading. Colorize the photo naturally while preserving authentic textures and details, maintaining a realistic and historically accurate look.", "PhotoRestorer"],
|
| 243 |
-
["polaroid/1.png", "[photo content], in the style of a vintage Polaroid, with warm, faded tones, and a white border.", "PolaroidWarm"],
|
| 244 |
-
["pencil/1.png", "[photo content], replicate the image as a pencil illustration, black and white, with sketch-like detailing.", "MonochromePencil"],
|
| 245 |
],
|
| 246 |
inputs=[input_image, prompt, lora_adapter],
|
| 247 |
outputs=[output_slider, seed],
|
|
|
|
| 99 |
|
| 100 |
print("Using device:", device)
|
| 101 |
|
|
|
|
| 102 |
MAX_SEED = np.iinfo(np.int32).max
|
| 103 |
pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to("cuda")
|
| 104 |
|
| 105 |
+
pipe.load_lora_weights("prithivMLmods/Kontext-Top-Down-View", weight_name="Kontext-Top-Down-View.safetensors", adapter_name="top-down")
|
| 106 |
+
pipe.load_lora_weights("prithivMLmods/Kontext-Bottom-Up-View", weight_name="Kontext-Bottom-Up-View.safetensors", adapter_name="bottom-up")
|
| 107 |
+
pipe.load_lora_weights("prithivMLmods/Kontext-CAM-Left-View", weight_name="Kontext-CAM-Left-View.safetensors", adapter_name="left-view")
|
| 108 |
+
pipe.load_lora_weights("prithivMLmods/Kontext-CAM-Right-View", weight_name="Kontext-CAM-Right-View.safetensors", adapter_name="right-view")
|
| 109 |
+
pipe.load_lora_weights("starsfriday/Kontext-Remover-General-LoRA", weight_name="kontext_remove.safetensors", adapter_name="kontext-remove")
|
|
|
|
|
|
|
| 110 |
|
|
|
|
| 111 |
aura_sr = AuraSR.from_pretrained("fal/AuraSR-v2")
|
| 112 |
|
| 113 |
@spaces.GPU
|
|
|
|
| 118 |
if not input_image:
|
| 119 |
raise gr.Error("Please upload an image for editing.")
|
| 120 |
|
| 121 |
+
if lora_adapter == "Kontext-Top-Down-View":
|
| 122 |
+
pipe.set_adapters(["top-down"], adapter_weights=[1.0])
|
| 123 |
+
elif lora_adapter == "Kontext-Bottom-Up-View":
|
| 124 |
+
pipe.set_adapters(["bottom-up"], adapter_weights=[1.0])
|
| 125 |
+
elif lora_adapter == "Kontext-CAM-Left-View":
|
| 126 |
+
pipe.set_adapters(["left-view"], adapter_weights=[1.0])
|
| 127 |
+
elif lora_adapter == "Kontext-CAM-Right-View":
|
| 128 |
+
pipe.set_adapters(["right-view"], adapter_weights=[1.0])
|
| 129 |
+
elif lora_adapter == "Kontext-Remover":
|
| 130 |
+
pipe.set_adapters(["kontext-remove"], adapter_weights=[1.0])
|
|
|
|
|
|
|
| 131 |
|
| 132 |
if randomize_seed:
|
| 133 |
seed = random.randint(0, MAX_SEED)
|
|
|
|
| 215 |
with gr.Column():
|
| 216 |
output_slider = ImageSlider(label="Before / After", show_label=False, interactive=False)
|
| 217 |
reuse_button = gr.Button("Reuse this image", visible=False)
|
| 218 |
+
|
| 219 |
with gr.Row():
|
| 220 |
lora_adapter = gr.Dropdown(
|
| 221 |
label="Chosen LoRA",
|
| 222 |
+
choices=["Kontext-Top-Down-View", "Kontext-Remover", "Kontext-Bottom-Up-View", "Kontext-CAM-Left-View", "Kontext-CAM-Right-View"],
|
| 223 |
+
value="Kontext-Top-Down-View"
|
| 224 |
)
|
| 225 |
|
| 226 |
with gr.Row():
|
|
|
|
| 228 |
|
| 229 |
gr.Examples(
|
| 230 |
examples=[
|
| 231 |
+
["examples/1.png", "[photo content], recreate the scene from a top-down perspective. Maintain all visual proportions, lighting consistency, and realistic spatial relationships. Ensure the background, textures, and environmental shadows remain naturally aligned from this elevated angle.", "PhotoCleanser"],
|
| 232 |
+
["examples/2.png", "[photo content], remove the football from the image while preserving the background and remaining elements, maintaining realism and original details.", "PhotoCleanser"],
|
| 233 |
+
["examples/3.jpeg", "[photo content], remove any watermark text or logos from the image while preserving the background, texture, lighting, and overall realism. Ensure the edited areas blend seamlessly with surrounding details, leaving no visible traces of watermark removal.", "Kontext-Watermark-Remover"],
|
| 234 |
+
["examples/4.png", "[photo content], restore and enhance the image by repairing any damage, scratches, or fading. Colorize the photo naturally while preserving authentic textures and details, maintaining a realistic and historically accurate look.", "PhotoRestorer"],
|
| 235 |
+
["examples/5.png", "[photo content], restore and enhance the image by repairing any damage, scratches, or fading. Colorize the photo naturally while preserving authentic textures and details, maintaining a realistic and historically accurate look.", "PhotoRestorer"],
|
|
|
|
|
|
|
|
|
|
| 236 |
],
|
| 237 |
inputs=[input_image, prompt, lora_adapter],
|
| 238 |
outputs=[output_slider, seed],
|