prithivMLmods commited on
Commit
25b75b1
·
verified ·
1 Parent(s): 9fb1a0f

Update app.py

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