prithivMLmods commited on
Commit
451ef4f
·
verified ·
1 Parent(s): 63617d6

update app

Browse files
Files changed (1) hide show
  1. app.py +7 -71
app.py CHANGED
@@ -12,73 +12,6 @@ from diffusers.utils import load_image
12
  from huggingface_hub import hf_hub_download
13
  from aura_sr import AuraSR
14
  from gradio_imageslider import ImageSlider
15
- from gradio.themes import Soft
16
- from gradio.themes.utils import colors, fonts, sizes
17
-
18
- # --- Theme and CSS Definition ---
19
-
20
- # Define the new HotPink color palette
21
- colors.hot_pink = colors.Color(
22
- name="hot_pink",
23
- c50="#FFF0F7",
24
- c100="#FFE0EF",
25
- c200="#FFC2E0",
26
- c300="#FFA4D1",
27
- c400="#FF87C3",
28
- c500="#FF69B4", # HotPink base color
29
- c600="#E65FA2",
30
- c700="#CC5490",
31
- c800="#B34A7E",
32
- c900="#993F6C",
33
- c950="#80355A",
34
- )
35
-
36
- class HotPinkTheme(Soft):
37
- def __init__(
38
- self,
39
- *,
40
- primary_hue: colors.Color | str = colors.gray,
41
- secondary_hue: colors.Color | str = colors.hot_pink, # Use the new color
42
- neutral_hue: colors.Color | str = colors.slate,
43
- text_size: sizes.Size | str = sizes.text_lg,
44
- font: fonts.Font | str | Iterable[fonts.Font | str] = (
45
- fonts.GoogleFont("Outfit"), "Arial", "sans-serif",
46
- ),
47
- font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
48
- fonts.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace",
49
- ),
50
- ):
51
- super().__init__(
52
- primary_hue=primary_hue,
53
- secondary_hue=secondary_hue,
54
- neutral_hue=neutral_hue,
55
- text_size=text_size,
56
- font=font,
57
- font_mono=font_mono,
58
- )
59
- super().set(
60
- background_fill_primary="*primary_50",
61
- background_fill_primary_dark="*primary_900",
62
- body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
63
- body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
64
- button_primary_text_color="white",
65
- button_primary_text_color_hover="white",
66
- button_primary_background_fill="linear-gradient(90deg, *secondary_500, *secondary_600)",
67
- button_primary_background_fill_hover="linear-gradient(90deg, *secondary_600, *secondary_700)",
68
- button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_700)",
69
- button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_600)",
70
- slider_color="*secondary_500",
71
- slider_color_dark="*secondary_600",
72
- block_title_text_weight="600",
73
- block_border_width="2px",
74
- block_shadow="*shadow_drop_lg",
75
- button_primary_shadow="*shadow_drop_lg",
76
- button_large_padding="12px",
77
- block_label_background_fill="*primary_200",
78
- )
79
-
80
- # Instantiate the new theme
81
- hot_pink_theme = HotPinkTheme()
82
 
83
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
84
 
@@ -104,7 +37,7 @@ pipe.load_lora_weights("prithivMLmods/Photo-Restore-i2i", weight_name="Photo-Res
104
  pipe.load_lora_weights("prithivMLmods/Polaroid-Warm-i2i", weight_name="Polaroid-Warm-i2i.safetensors", adapter_name="polaroid")
105
  pipe.load_lora_weights("prithivMLmods/Monochrome-Pencil", weight_name="Monochrome-Pencil-i2i.safetensors", adapter_name="pencil")
106
  pipe.load_lora_weights("prithivMLmods/LZO-1-Preview", weight_name="LZO-1-Preview.safetensors", adapter_name="lzo")
107
-
108
 
109
  # --- Upscaler Model Initialization ---
110
  aura_sr = AuraSR.from_pretrained("fal/AuraSR-v2")
@@ -127,7 +60,9 @@ def infer(input_image, prompt, lora_adapter, upscale_image, seed=42, randomize_s
127
  pipe.set_adapters(["pencil"], adapter_weights=[1.0])
128
  elif lora_adapter == "LZO-Zoom":
129
  pipe.set_adapters(["lzo"], adapter_weights=[1.0])
130
-
 
 
131
  if randomize_seed:
132
  seed = random.randint(0, MAX_SEED)
133
 
@@ -165,7 +100,7 @@ css="""
165
  #main-title h1 {font-size: 2.1em !important;}
166
  """
167
 
168
- with gr.Blocks(css=css, theme=hot_pink_theme) as demo:
169
 
170
  with gr.Column(elem_id="col-container"):
171
  gr.Markdown("# **Photo-Mate-i2i**", elem_id="main-title")
@@ -218,7 +153,7 @@ with gr.Blocks(css=css, theme=hot_pink_theme) as demo:
218
  with gr.Row():
219
  lora_adapter = gr.Dropdown(
220
  label="Chosen LoRA",
221
- choices=["PhotoCleanser", "PhotoRestorer", "PolaroidWarm", "MonochromePencil", "LZO-Zoom"],
222
  value="PhotoCleanser"
223
  )
224
 
@@ -229,6 +164,7 @@ with gr.Blocks(css=css, theme=hot_pink_theme) as demo:
229
  examples=[
230
  ["photocleanser/2.png", "[photo content], remove the cat from the image while preserving the background and remaining elements, maintaining realism and original details.", "PhotoCleanser"],
231
  ["photocleanser/1.png", "[photo content], remove the football from the image while preserving the background and remaining elements, maintaining realism and original details.", "PhotoCleanser"],
 
232
  ["photorestore/1.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"],
233
  ["lzo/1.jpg", "[photo content], zoom in on the specified [face close-up], enhancing resolution and detail while preserving sharpness, realism, and original context. Maintain natural proportions and background continuity around the zoomed area.", "LZO-Zoom"],
234
  ["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"],
 
12
  from huggingface_hub import hf_hub_download
13
  from aura_sr import AuraSR
14
  from gradio_imageslider import ImageSlider
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
17
 
 
37
  pipe.load_lora_weights("prithivMLmods/Polaroid-Warm-i2i", weight_name="Polaroid-Warm-i2i.safetensors", adapter_name="polaroid")
38
  pipe.load_lora_weights("prithivMLmods/Monochrome-Pencil", weight_name="Monochrome-Pencil-i2i.safetensors", adapter_name="pencil")
39
  pipe.load_lora_weights("prithivMLmods/LZO-1-Preview", weight_name="LZO-1-Preview.safetensors", adapter_name="lzo")
40
+ pipe.load_lora_weights("prithivMLmods/Kontext-Watermark-Remover", weight_name="Kontext-Watermark-Remover.safetensors", adapter_name="watermark-remover")
41
 
42
  # --- Upscaler Model Initialization ---
43
  aura_sr = AuraSR.from_pretrained("fal/AuraSR-v2")
 
60
  pipe.set_adapters(["pencil"], adapter_weights=[1.0])
61
  elif lora_adapter == "LZO-Zoom":
62
  pipe.set_adapters(["lzo"], adapter_weights=[1.0])
63
+ elif lora_adapter == "Kontext-Watermark-Remover":
64
+ pipe.set_adapters(["watermark-remover"], adapter_weights=[1.0])
65
+
66
  if randomize_seed:
67
  seed = random.randint(0, MAX_SEED)
68
 
 
100
  #main-title h1 {font-size: 2.1em !important;}
101
  """
102
 
103
+ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
104
 
105
  with gr.Column(elem_id="col-container"):
106
  gr.Markdown("# **Photo-Mate-i2i**", elem_id="main-title")
 
153
  with gr.Row():
154
  lora_adapter = gr.Dropdown(
155
  label="Chosen LoRA",
156
+ choices=["PhotoCleanser", "PhotoRestorer", "PolaroidWarm", "MonochromePencil", "LZO-Zoom", "Kontext-Watermark-Remover"],
157
  value="PhotoCleanser"
158
  )
159
 
 
164
  examples=[
165
  ["photocleanser/2.png", "[photo content], remove the cat from the image while preserving the background and remaining elements, maintaining realism and original details.", "PhotoCleanser"],
166
  ["photocleanser/1.png", "[photo content], remove the football from the image while preserving the background and remaining elements, maintaining realism and original details.", "PhotoCleanser"],
167
+ ["watermark/12.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"],
168
  ["photorestore/1.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"],
169
  ["lzo/1.jpg", "[photo content], zoom in on the specified [face close-up], enhancing resolution and detail while preserving sharpness, realism, and original context. Maintain natural proportions and background continuity around the zoomed area.", "LZO-Zoom"],
170
  ["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"],