prithivMLmods commited on
Commit
a6f8034
·
verified ·
1 Parent(s): 07844d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -13,9 +13,10 @@ 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 both 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
 
20
 
21
  @spaces.GPU
@@ -29,7 +30,7 @@ def infer(input_image, prompt, lora_adapter, seed=42, randomize_seed=False, guid
29
  Args:
30
  input_image (PIL.Image.Image): The input image to be edited.
31
  prompt (str): Text description of the desired edit.
32
- lora_adapter (str): The name of the LoRA adapter to use ("PhotoCleanser" or "PhotoRestorer").
33
  seed (int, optional): Random seed for reproducible generation. Defaults to 42.
34
  randomize_seed (bool, optional): If True, generates a random seed. Defaults to False.
35
  guidance_scale (float, optional): Controls adherence to the prompt. Defaults to 2.5.
@@ -44,6 +45,8 @@ def infer(input_image, prompt, lora_adapter, seed=42, randomize_seed=False, guid
44
  pipe.set_adapters(["cleanser"], adapter_weights=[1.0])
45
  elif lora_adapter == "PhotoRestorer":
46
  pipe.set_adapters(["restorer"], adapter_weights=[1.0])
 
 
47
 
48
  if randomize_seed:
49
  seed = random.randint(0, MAX_SEED)
@@ -94,7 +97,7 @@ with gr.Blocks(css=css) as demo:
94
  input_image = gr.Image(label="Upload the image for editing", type="pil", height="300")
95
  lora_adapter = gr.Dropdown(
96
  label="Choose Adapter",
97
- choices=["PhotoCleanser", "PhotoRestorer"],
98
  value="PhotoCleanser"
99
  )
100
  with gr.Row():
@@ -160,6 +163,16 @@ with gr.Blocks(css=css) as demo:
160
  "photorestore/2.png",
161
  "[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.",
162
  "PhotoRestorer"
 
 
 
 
 
 
 
 
 
 
163
  ]
164
  ],
165
  # 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 three 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
 
21
 
22
  @spaces.GPU
 
30
  Args:
31
  input_image (PIL.Image.Image): The input image to be edited.
32
  prompt (str): Text description of the desired edit.
33
+ lora_adapter (str): The name of the LoRA adapter to use.
34
  seed (int, optional): Random seed for reproducible generation. Defaults to 42.
35
  randomize_seed (bool, optional): If True, generates a random seed. Defaults to False.
36
  guidance_scale (float, optional): Controls adherence to the prompt. Defaults to 2.5.
 
45
  pipe.set_adapters(["cleanser"], adapter_weights=[1.0])
46
  elif lora_adapter == "PhotoRestorer":
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)
 
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():
 
163
  "photorestore/2.png",
164
  "[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.",
165
  "PhotoRestorer"
166
+ ],
167
+ [
168
+ "polaroid/1.png",
169
+ "[photo content], apply a warm, vintage Polaroid-style filter, enhancing the image with nostalgic tones, soft focus, and characteristic light leaks for an authentic, retro feel.",
170
+ "PolaroidWarm"
171
+ ],
172
+ [
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