prithivMLmods commited on
Commit
a0da623
Β·
verified Β·
1 Parent(s): 7a007e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +394 -118
app.py CHANGED
@@ -11,20 +11,19 @@ from gradio.themes import Base
11
  from gradio.themes.utils import colors, fonts, sizes
12
 
13
 
14
- class MinimalSquareTheme(Base):
15
  def __init__(
16
  self,
17
  *,
18
- primary_hue: colors.Color | str = colors.gray,
19
- secondary_hue: colors.Color | str = colors.gray,
20
- neutral_hue: colors.Color | str = colors.gray,
21
  text_size: sizes.Size | str = sizes.text_md,
22
- radius_size: sizes.Size | str = sizes.radius_none,
23
  font: fonts.Font | str | Iterable[fonts.Font | str] = (
24
- fonts.GoogleFont("Inter"), "Arial", "sans-serif",
25
  ),
26
  font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
27
- fonts.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace",
28
  ),
29
  ):
30
  super().__init__(
@@ -32,90 +31,182 @@ class MinimalSquareTheme(Base):
32
  secondary_hue=secondary_hue,
33
  neutral_hue=neutral_hue,
34
  text_size=text_size,
35
- radius_size=radius_size,
36
  font=font,
37
  font_mono=font_mono,
38
  )
39
  super().set(
40
- # ---- Page / body ----
41
- body_background_fill="white",
42
- body_background_fill_dark="#0b0b0b",
43
- background_fill_primary="white",
44
- background_fill_primary_dark="#0b0b0b",
45
- background_fill_secondary="#f4f4f4",
46
- background_fill_secondary_dark="#161616",
47
- body_text_color="black",
48
- body_text_color_dark="white",
49
-
50
- # ---- Blocks / cards ----
51
- block_background_fill="white",
52
- block_background_fill_dark="#111111",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  block_border_width="1px",
54
- block_border_color="black",
55
- block_border_color_dark="#3a3a3a",
56
- block_radius="0px",
57
  block_shadow="none",
58
  block_shadow_dark="none",
59
- block_title_text_weight="600",
60
- block_label_background_fill="white",
61
- block_label_background_fill_dark="#111111",
 
 
 
62
  block_label_border_width="1px",
63
- block_label_radius="0px",
64
- block_label_text_color="black",
65
- block_label_text_color_dark="white",
66
-
67
- # ---- Primary button ----
68
- button_primary_background_fill="black",
69
- button_primary_background_fill_hover="#262626",
70
- button_primary_background_fill_dark="white",
71
- button_primary_background_fill_hover_dark="#e0e0e0",
72
- button_primary_text_color="white",
73
- button_primary_text_color_dark="black",
74
- button_primary_border_color="black",
75
- button_primary_border_color_dark="white",
76
- button_large_radius="0px",
77
- button_small_radius="0px",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  button_primary_shadow="none",
 
 
 
79
 
80
- # ---- Secondary button ----
81
- button_secondary_background_fill="white",
82
- button_secondary_background_fill_hover="#ececec",
83
  button_secondary_background_fill_dark="#1a1a1a",
 
84
  button_secondary_background_fill_hover_dark="#2a2a2a",
85
- button_secondary_text_color="black",
86
- button_secondary_text_color_dark="white",
87
- button_secondary_border_color="black",
88
- button_secondary_border_color_dark="white",
89
-
90
- # ---- Inputs (textbox, dropdown, etc.) ----
91
- input_background_fill="white",
92
- input_background_fill_dark="#111111",
93
- input_border_color="black",
94
- input_border_color_dark="#3a3a3a",
95
- input_radius="0px",
96
- input_shadow="none",
97
-
98
- # ---- Panels (groups / boxes) ----
99
- panel_background_fill="white",
100
- panel_background_fill_dark="#111111",
101
- panel_border_width="1px",
102
- panel_border_color="black",
103
- panel_border_color_dark="#3a3a3a",
104
-
105
- # ---- Checkbox / slider accents ----
106
- checkbox_background_color="white",
107
- checkbox_background_color_dark="#111111",
108
- checkbox_border_color="black",
 
 
 
 
 
 
 
 
 
 
 
109
  checkbox_border_color_dark="#3a3a3a",
110
- checkbox_border_radius="0px",
111
- checkbox_background_color_selected="black",
112
- checkbox_background_color_selected_dark="white",
113
- slider_color="black",
114
- slider_color_dark="white",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  )
116
 
117
 
118
- minimal_square_theme = MinimalSquareTheme()
119
 
120
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
121
 
@@ -131,7 +222,7 @@ from qwenimage.qwen_fa3_processor import QwenDoubleStreamAttnProcessorFA3
131
  dtype = torch.bfloat16
132
 
133
  pipe = QwenImageEditPlusPipeline.from_pretrained(
134
- "FireRedTeam/FireRed-Image-Edit-1.1", # ---> Prev: FireRedTeam/FireRed-Image-Edit-1.0
135
  transformer=QwenImageTransformer2DModel.from_pretrained(
136
  "prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V19",
137
  torch_dtype=dtype,
@@ -148,6 +239,7 @@ except Exception as e:
148
 
149
  MAX_SEED = np.iinfo(np.int32).max
150
 
 
151
  def update_dimensions_on_upload(image):
152
  if image is None:
153
  return 1024, 1024
@@ -168,7 +260,8 @@ def update_dimensions_on_upload(image):
168
 
169
  return new_width, new_height
170
 
171
- @spaces.GPU(size="xlarge")
 
172
  def infer(
173
  images,
174
  prompt,
@@ -210,7 +303,11 @@ def infer(
210
  seed = random.randint(0, MAX_SEED)
211
 
212
  generator = torch.Generator(device=device).manual_seed(seed)
213
- negative_prompt = "worst quality, low quality, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, blurry"
 
 
 
 
214
 
215
  width, height = update_dimensions_on_upload(pil_images[0])
216
 
@@ -234,7 +331,8 @@ def infer(
234
  gc.collect()
235
  torch.cuda.empty_cache()
236
 
237
- @spaces.GPU(size="xlarge")
 
238
  def infer_example(images, prompt):
239
  if not images:
240
  return None, 0
@@ -254,78 +352,256 @@ def infer_example(images, prompt):
254
  )
255
  return result, seed
256
 
 
257
  css = """
 
 
 
 
 
 
258
  #col-container {
259
  margin: 0 auto;
260
- max-width: 1000px;
 
261
  }
262
- #main-title h1 {font-size: 2.4em !important;}
263
 
264
- /* Force square corners everywhere, overriding any residual
265
- component-level border-radius that the theme doesn't reach. */
266
- *, *::before, *::after {
267
- border-radius: 0px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
  """
270
 
271
- with gr.Blocks() as demo:
272
  with gr.Column(elem_id="col-container"):
273
- gr.Markdown("# **FireRed-Image-Edit-1.0-Fast - [v@1.1](https://huggingface.co/FireRedTeam/FireRed-Image-Edit-1.1)**", elem_id="main-title")
274
- gr.Markdown("Perform image edits using [FireRed-Image-Edit-1.0](https://huggingface.co/FireRedTeam/FireRed-Image-Edit-1.0) with 4-step fast inference. Open on [GitHub](https://github.com/PRITHIVSAKTHIUR/FireRed-Image-Edit-1.0-Fast)")
275
 
276
- with gr.Row(equal_height=True):
277
- with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  images = gr.Gallery(
279
- label="Upload Images",
280
- #sources=["upload", "clipboard"],
281
  type="filepath",
282
  columns=2,
283
  rows=1,
284
- height=300,
285
- allow_preview=True
 
286
  )
287
 
288
- prompt = gr.Text(
289
- label="Edit Prompt",
290
- show_label=True,
291
- max_lines=2,
292
- placeholder="e.g., transform into anime, upscale, change lighting...",
293
  )
294
 
295
- run_button = gr.Button("Edit Image", variant="primary")
296
-
297
- with gr.Column():
298
- output_image = gr.Image(label="Output Image", interactive=False, format="png", height=395)
 
299
 
300
- with gr.Accordion("Advanced Settings", open=False, visible=False):
301
- seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
302
- randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
303
- guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=1.0)
304
- steps = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=4)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
 
306
  gr.Examples(
307
  examples=[
308
- [["examples/1.jpg"], "cinematic polaroid with soft grain subtle vignette gentle lighting white frame handwritten photographed 'Fire-Edit' preserving realistic texture and details."],
309
- [["examples/2.jpg"], "Transform the image into a dotted cartoon style."],
310
- [["examples/3.jpeg"], "Convert it to black and white."],
311
- [["examples/4.jpg", "examples/5.jpg"], "Replace her glasses with the new glasses from image 1."],
312
- [["examples/8.jpg", "examples/9.png"], "Replace the current clothing with the clothing from the reference image 2. Keep the person’s face, hairstyle, body pose, background, lighting, and camera angle unchanged. Ensure the new outfit fits naturally with realistic fabric texture, proper shadows, folds, and accurate proportions. Match the lighting, color tone, and overall style for a seamless and high-quality result."],
313
- [["examples/10.jpg", "examples/11.png"], "Replace the current clothing with the clothing from the reference image 2. Keep the person’s face, hairstyle, body pose, background, lighting, and camera angle unchanged. Ensure the new outfit fits naturally with realistic fabric texture, proper shadows, folds, and accurate proportions. Match the lighting, color tone, and overall style for a seamless and high-quality result."],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  ],
315
  inputs=[images, prompt],
316
  outputs=[output_image, seed],
317
  fn=infer_example,
318
  cache_examples=False,
319
- label="Examples"
 
320
  )
321
 
322
- gr.Markdown("[*](https://huggingface.co/FireRedTeam/FireRed-Image-Edit-1.0)This is still an experimental Space for FireRed-Image-Edit-1.0.")
 
 
 
 
323
 
 
324
  run_button.click(
325
  fn=infer,
326
  inputs=[images, prompt, seed, randomize_seed, guidance_scale, steps],
327
- outputs=[output_image, seed]
328
  )
329
 
330
  if __name__ == "__main__":
331
- demo.queue(max_size=30).launch(css=css, theme=minimal_square_theme, mcp_server=True, ssr_mode=False, show_error=True)
 
 
 
 
 
 
 
11
  from gradio.themes.utils import colors, fonts, sizes
12
 
13
 
14
+ class MinimalTheme(Base):
15
  def __init__(
16
  self,
17
  *,
18
+ primary_hue: colors.Color | str = colors.neutral,
19
+ secondary_hue: colors.Color | str = colors.zinc,
20
+ neutral_hue: colors.Color | str = colors.stone,
21
  text_size: sizes.Size | str = sizes.text_md,
 
22
  font: fonts.Font | str | Iterable[fonts.Font | str] = (
23
+ fonts.GoogleFont("Inter"), "system-ui", "sans-serif",
24
  ),
25
  font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
26
+ fonts.GoogleFont("JetBrains Mono"), "ui-monospace", "monospace",
27
  ),
28
  ):
29
  super().__init__(
 
31
  secondary_hue=secondary_hue,
32
  neutral_hue=neutral_hue,
33
  text_size=text_size,
 
34
  font=font,
35
  font_mono=font_mono,
36
  )
37
  super().set(
38
+ # ── Radius: zero everywhere ──────────────────────────────────────
39
+ radius_xxs="0px",
40
+ radius_xs="0px",
41
+ radius_sm="0px",
42
+ radius_md="0px",
43
+ radius_lg="0px",
44
+ radius_xl="0px",
45
+ radius_xxl="0px",
46
+
47
+ # ── Backgrounds ──────────────────────────────────────────────────
48
+ background_fill_primary="#ffffff",
49
+ background_fill_primary_dark="#0f0f0f",
50
+ background_fill_secondary="#f5f5f5",
51
+ background_fill_secondary_dark="#1a1a1a",
52
+ body_background_fill="#f0f0f0",
53
+ body_background_fill_dark="#0a0a0a",
54
+
55
+ # ── Body text ────────────────────────────────────────────────────
56
+ body_text_color="#111111",
57
+ body_text_color_dark="#e8e8e8",
58
+ body_text_color_subdued="#555555",
59
+ body_text_color_subdued_dark="#888888",
60
+
61
+ # ── Borders ──────────────────────────────────────────────────────
62
+ border_color_primary="#d0d0d0",
63
+ border_color_primary_dark="#2e2e2e",
64
+ border_color_accent="#999999",
65
+ border_color_accent_dark="#555555",
66
+
67
+ # ── Blocks ───────────────────────────────────────────────────────
68
+ block_background_fill="#ffffff",
69
+ block_background_fill_dark="#141414",
70
+ block_border_color="#d0d0d0",
71
+ block_border_color_dark="#2e2e2e",
72
  block_border_width="1px",
 
 
 
73
  block_shadow="none",
74
  block_shadow_dark="none",
75
+ block_label_background_fill="#f5f5f5",
76
+ block_label_background_fill_dark="#1a1a1a",
77
+ block_label_text_color="#333333",
78
+ block_label_text_color_dark="#cccccc",
79
+ block_label_border_color="#d0d0d0",
80
+ block_label_border_color_dark="#2e2e2e",
81
  block_label_border_width="1px",
82
+ block_title_text_color="#111111",
83
+ block_title_text_color_dark="#eeeeee",
84
+ block_title_text_weight="600",
85
+ block_title_padding="8px 0px",
86
+ block_padding="16px",
87
+
88
+ # ── Inputs ───────────────────────────────────────────────────────
89
+ input_background_fill="#ffffff",
90
+ input_background_fill_dark="#1a1a1a",
91
+ input_background_fill_focus="#ffffff",
92
+ input_background_fill_focus_dark="#222222",
93
+ input_border_color="#c0c0c0",
94
+ input_border_color_dark="#3a3a3a",
95
+ input_border_color_focus="#555555",
96
+ input_border_color_focus_dark="#888888",
97
+ input_border_width="1px",
98
+ input_shadow="none",
99
+ input_shadow_dark="none",
100
+ input_shadow_focus="none",
101
+ input_shadow_focus_dark="none",
102
+ input_text_color="#111111",
103
+ input_text_color_dark="#e8e8e8",
104
+ input_placeholder_color="#999999",
105
+ input_placeholder_color_dark="#666666",
106
+ input_padding="10px 12px",
107
+
108
+ # ── Primary button ───────────────────────────────────────────────
109
+ button_primary_background_fill="#111111",
110
+ button_primary_background_fill_dark="#e8e8e8",
111
+ button_primary_background_fill_hover="#333333",
112
+ button_primary_background_fill_hover_dark="#ffffff",
113
+ button_primary_text_color="#ffffff",
114
+ button_primary_text_color_dark="#111111",
115
+ button_primary_text_color_hover="#ffffff",
116
+ button_primary_text_color_hover_dark="#111111",
117
+ button_primary_border_color="#111111",
118
+ button_primary_border_color_dark="#e8e8e8",
119
  button_primary_shadow="none",
120
+ button_primary_shadow_dark="none",
121
+ button_primary_shadow_hover="none",
122
+ button_primary_shadow_hover_dark="none",
123
 
124
+ # ── Secondary button ─────────────────────────────────────────────
125
+ button_secondary_background_fill="#ffffff",
 
126
  button_secondary_background_fill_dark="#1a1a1a",
127
+ button_secondary_background_fill_hover="#f0f0f0",
128
  button_secondary_background_fill_hover_dark="#2a2a2a",
129
+ button_secondary_text_color="#111111",
130
+ button_secondary_text_color_dark="#e8e8e8",
131
+ button_secondary_text_color_hover="#111111",
132
+ button_secondary_text_color_hover_dark="#ffffff",
133
+ button_secondary_border_color="#c0c0c0",
134
+ button_secondary_border_color_dark="#3a3a3a",
135
+ button_secondary_shadow="none",
136
+ button_secondary_shadow_dark="none",
137
+
138
+ # ── Cancel button ────────────────────────────────────────────────
139
+ button_cancel_background_fill="#ffffff",
140
+ button_cancel_background_fill_dark="#1a1a1a",
141
+ button_cancel_text_color="#111111",
142
+ button_cancel_text_color_dark="#e8e8e8",
143
+ button_cancel_border_color="#c0c0c0",
144
+ button_cancel_border_color_dark="#3a3a3a",
145
+
146
+ # ── Button sizing ────────────────────────────────────────────────
147
+ button_large_padding="10px 20px",
148
+ button_small_padding="6px 12px",
149
+ button_large_text_size="14px",
150
+ button_small_text_size="12px",
151
+ button_large_text_weight="600",
152
+ button_small_text_weight="500",
153
+
154
+ # ── Slider ───────────────────────────────────────────────────────
155
+ slider_color="#111111",
156
+ slider_color_dark="#e8e8e8",
157
+
158
+ # ── Checkbox / Radio ─────────────────────────────────────────────
159
+ checkbox_background_color="#ffffff",
160
+ checkbox_background_color_dark="#1a1a1a",
161
+ checkbox_background_color_selected="#111111",
162
+ checkbox_background_color_selected_dark="#e8e8e8",
163
+ checkbox_border_color="#c0c0c0",
164
  checkbox_border_color_dark="#3a3a3a",
165
+ checkbox_border_color_focus="#555555",
166
+ checkbox_border_color_focus_dark="#888888",
167
+ checkbox_border_color_selected="#111111",
168
+ checkbox_border_color_selected_dark="#e8e8e8",
169
+ checkbox_label_text_color="#111111",
170
+ checkbox_label_text_color_dark="#e8e8e8",
171
+ checkbox_label_background_fill="#ffffff",
172
+ checkbox_label_background_fill_dark="#1a1a1a",
173
+ checkbox_label_background_fill_selected="#f5f5f5",
174
+ checkbox_label_background_fill_selected_dark="#222222",
175
+
176
+ # ── Accordion ────────────────────────────────────────────────────
177
+ accordion_text_color="#111111",
178
+ accordion_text_color_dark="#e8e8e8",
179
+
180
+ # ── Table ────────────────────────────────────────────────────────
181
+ table_border_color="#d0d0d0",
182
+ table_border_color_dark="#2e2e2e",
183
+ table_odd_background_fill="#fafafa",
184
+ table_odd_background_fill_dark="#161616",
185
+ table_even_background_fill="#ffffff",
186
+ table_even_background_fill_dark="#1a1a1a",
187
+ table_row_focus="#f0f0f0",
188
+ table_row_focus_dark="#222222",
189
+
190
+ # ── Shadow tokens ────────────────────────────────────────────────
191
+ shadow_drop="none",
192
+ shadow_drop_lg="none",
193
+ shadow_inset="none",
194
+
195
+ # ── Miscellaneous ────────────────────────────────────────────────
196
+ color_accent_soft="#f0f0f0",
197
+ color_accent_soft_dark="#1e1e1e",
198
+ link_text_color="#111111",
199
+ link_text_color_dark="#e8e8e8",
200
+ link_text_color_hover="#444444",
201
+ link_text_color_hover_dark="#ffffff",
202
+ link_text_color_active="#000000",
203
+ link_text_color_active_dark="#ffffff",
204
+ link_text_color_visited="#555555",
205
+ link_text_color_visited_dark="#aaaaaa",
206
  )
207
 
208
 
209
+ minimal_theme = MinimalTheme()
210
 
211
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
212
 
 
222
  dtype = torch.bfloat16
223
 
224
  pipe = QwenImageEditPlusPipeline.from_pretrained(
225
+ "FireRedTeam/FireRed-Image-Edit-1.1",
226
  transformer=QwenImageTransformer2DModel.from_pretrained(
227
  "prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V19",
228
  torch_dtype=dtype,
 
239
 
240
  MAX_SEED = np.iinfo(np.int32).max
241
 
242
+
243
  def update_dimensions_on_upload(image):
244
  if image is None:
245
  return 1024, 1024
 
260
 
261
  return new_width, new_height
262
 
263
+
264
+ @spaces.GPU
265
  def infer(
266
  images,
267
  prompt,
 
303
  seed = random.randint(0, MAX_SEED)
304
 
305
  generator = torch.Generator(device=device).manual_seed(seed)
306
+ negative_prompt = (
307
+ "worst quality, low quality, bad anatomy, bad hands, text, error, "
308
+ "missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, "
309
+ "signature, watermark, username, blurry"
310
+ )
311
 
312
  width, height = update_dimensions_on_upload(pil_images[0])
313
 
 
331
  gc.collect()
332
  torch.cuda.empty_cache()
333
 
334
+
335
+ @spaces.GPU
336
  def infer_example(images, prompt):
337
  if not images:
338
  return None, 0
 
352
  )
353
  return result, seed
354
 
355
+
356
  css = """
357
+ /* ── Reset all border-radius to zero ─────────────────────────── */
358
+ *, *::before, *::after {
359
+ border-radius: 0 !important;
360
+ }
361
+
362
+ /* ── Page layout ─────────────────────────────────────────────── */
363
  #col-container {
364
  margin: 0 auto;
365
+ max-width: 1020px;
366
+ padding: 24px 16px;
367
  }
 
368
 
369
+ /* ── Title ───────────────────────────────────────────────────── */
370
+ #main-title h1 {
371
+ font-size: 1.6em !important;
372
+ font-weight: 700 !important;
373
+ letter-spacing: -0.02em;
374
+ margin-bottom: 4px !important;
375
+ }
376
+
377
+ #main-title h1 a {
378
+ color: inherit !important;
379
+ text-decoration: none;
380
+ border-bottom: 2px solid currentColor;
381
+ }
382
+
383
+ /* ── Subtitle ────────────────────────────────────────────────── */
384
+ #subtitle p {
385
+ font-size: 0.88em !important;
386
+ opacity: 0.6;
387
+ margin-top: 0 !important;
388
+ }
389
+
390
+ /* ── Divider ─────────────────────────────────────────────────── */
391
+ #divider {
392
+ border: none;
393
+ border-top: 1px solid #d0d0d0;
394
+ margin: 16px 0 20px;
395
+ }
396
+
397
+ /* ── Gallery upload area ─────────────────────────────────────── */
398
+ .gallery-upload .wrap {
399
+ border: 1px dashed #c0c0c0 !important;
400
+ background: transparent !important;
401
+ }
402
+
403
+ /* ── Run button ──────────────────────────────────────────────── */
404
+ #run-btn {
405
+ width: 100%;
406
+ font-size: 14px !important;
407
+ font-weight: 600 !important;
408
+ letter-spacing: 0.04em;
409
+ text-transform: uppercase;
410
+ padding: 12px !important;
411
+ margin-top: 8px;
412
+ border: none !important;
413
+ }
414
+
415
+ /* ── Output image ────────────────────────────────────────────── */
416
+ #output-image {
417
+ border: 1px solid #d0d0d0 !important;
418
+ }
419
+
420
+ /* ── Examples table ──────────────────────────────────────────── */
421
+ .examples-holder table {
422
+ border-collapse: collapse !important;
423
+ }
424
+
425
+ .examples-holder td,
426
+ .examples-holder th {
427
+ border: 1px solid #d0d0d0 !important;
428
+ padding: 8px 12px !important;
429
+ font-size: 0.84em !important;
430
+ }
431
+
432
+ /* ── Footer note ─────────────────────────────────────────────── */
433
+ #footer-note p {
434
+ font-size: 0.78em !important;
435
+ opacity: 0.45;
436
+ margin-top: 20px !important;
437
+ }
438
+
439
+ /* ── Dark-mode overrides ─────────────────────────────────────── */
440
+ @media (prefers-color-scheme: dark) {
441
+ #divider { border-top-color: #2e2e2e; }
442
+
443
+ .gallery-upload .wrap {
444
+ border-color: #3a3a3a !important;
445
+ }
446
+
447
+ #output-image {
448
+ border-color: #2e2e2e !important;
449
+ }
450
+
451
+ .examples-holder td,
452
+ .examples-holder th {
453
+ border-color: #2e2e2e !important;
454
+ }
455
  }
456
  """
457
 
458
+ with gr.Blocks(theme=minimal_theme, css=css) as demo:
459
  with gr.Column(elem_id="col-container"):
 
 
460
 
461
+ # ── Header ────────────────────��─────────────────────────────────────
462
+ gr.Markdown(
463
+ "# **FireRed-Image-Edit Β· [v1.1](https://huggingface.co/FireRedTeam/FireRed-Image-Edit-1.1)**",
464
+ elem_id="main-title"
465
+ )
466
+ gr.Markdown(
467
+ "Fast 4-step image editing powered by "
468
+ "[FireRed-Image-Edit-1.0](https://huggingface.co/FireRedTeam/FireRed-Image-Edit-1.0) Β· "
469
+ "[GitHub](https://github.com/PRITHIVSAKTHIUR/FireRed-Image-Edit-1.0-Fast)",
470
+ elem_id="subtitle"
471
+ )
472
+ gr.HTML("<hr id='divider'>")
473
+
474
+ # ── Main row ─────────────────────────────────────────────────────────
475
+ with gr.Row(equal_height=False, variant="panel"):
476
+
477
+ # Left column β€” inputs
478
+ with gr.Column(scale=1, min_width=320):
479
  images = gr.Gallery(
480
+ label="Input Images",
 
481
  type="filepath",
482
  columns=2,
483
  rows=1,
484
+ height=280,
485
+ allow_preview=True,
486
+ elem_classes=["gallery-upload"],
487
  )
488
 
489
+ prompt = gr.Textbox(
490
+ label="Edit Instruction",
491
+ placeholder="e.g. convert to anime style, change background to forest…",
492
+ max_lines=3,
493
+ lines=2,
494
  )
495
 
496
+ run_button = gr.Button(
497
+ "β–Ά Run Edit",
498
+ variant="primary",
499
+ elem_id="run-btn",
500
+ )
501
 
502
+ with gr.Accordion("Advanced Settings", open=False):
503
+ seed = gr.Slider(
504
+ label="Seed",
505
+ minimum=0,
506
+ maximum=MAX_SEED,
507
+ step=1,
508
+ value=0,
509
+ )
510
+ randomize_seed = gr.Checkbox(
511
+ label="Randomize seed",
512
+ value=True,
513
+ )
514
+ guidance_scale = gr.Slider(
515
+ label="Guidance Scale",
516
+ minimum=1.0,
517
+ maximum=10.0,
518
+ step=0.1,
519
+ value=1.0,
520
+ )
521
+ steps = gr.Slider(
522
+ label="Inference Steps",
523
+ minimum=1,
524
+ maximum=50,
525
+ step=1,
526
+ value=4,
527
+ )
528
+
529
+ # Right column β€” output
530
+ with gr.Column(scale=1, min_width=320):
531
+ output_image = gr.Image(
532
+ label="Result",
533
+ interactive=False,
534
+ format="png",
535
+ height=430,
536
+ elem_id="output-image",
537
+ )
538
 
539
+ # ── Examples ─────────────────────────────────────────────────────────
540
  gr.Examples(
541
  examples=[
542
+ [
543
+ ["examples/1.jpg"],
544
+ "cinematic polaroid with soft grain subtle vignette gentle lighting "
545
+ "white frame handwritten photographed 'Fire-Edit' preserving realistic "
546
+ "texture and details.",
547
+ ],
548
+ [
549
+ ["examples/2.jpg"],
550
+ "Transform the image into a dotted cartoon style.",
551
+ ],
552
+ [
553
+ ["examples/3.jpeg"],
554
+ "Convert it to black and white.",
555
+ ],
556
+ [
557
+ ["examples/4.jpg", "examples/5.jpg"],
558
+ "Replace her glasses with the new glasses from image 1.",
559
+ ],
560
+ [
561
+ ["examples/8.jpg", "examples/9.png"],
562
+ "Replace the current clothing with the clothing from the reference "
563
+ "image 2. Keep the person's face, hairstyle, body pose, background, "
564
+ "lighting, and camera angle unchanged. Ensure the new outfit fits "
565
+ "naturally with realistic fabric texture, proper shadows, folds, and "
566
+ "accurate proportions. Match the lighting, color tone, and overall "
567
+ "style for a seamless and high-quality result.",
568
+ ],
569
+ [
570
+ ["examples/10.jpg", "examples/11.png"],
571
+ "Replace the current clothing with the clothing from the reference "
572
+ "image 2. Keep the person's face, hairstyle, body pose, background, "
573
+ "lighting, and camera angle unchanged. Ensure the new outfit fits "
574
+ "naturally with realistic fabric texture, proper shadows, folds, and "
575
+ "accurate proportions. Match the lighting, color tone, and overall "
576
+ "style for a seamless and high-quality result.",
577
+ ],
578
  ],
579
  inputs=[images, prompt],
580
  outputs=[output_image, seed],
581
  fn=infer_example,
582
  cache_examples=False,
583
+ label="Examples",
584
+ elem_id="examples-holder",
585
  )
586
 
587
+ gr.Markdown(
588
+ "[*](https://huggingface.co/FireRedTeam/FireRed-Image-Edit-1.0) "
589
+ "Experimental space β€” results may vary.",
590
+ elem_id="footer-note",
591
+ )
592
 
593
+ # ── Event binding ─────────────────────────────────────────────────────────
594
  run_button.click(
595
  fn=infer,
596
  inputs=[images, prompt, seed, randomize_seed, guidance_scale, steps],
597
+ outputs=[output_image, seed],
598
  )
599
 
600
  if __name__ == "__main__":
601
+ demo.queue(max_size=30).launch(
602
+ theme=minimal_theme,
603
+ css=css,
604
+ mcp_server=True,
605
+ ssr_mode=False,
606
+ show_error=True,
607
+ )