prithivMLmods commited on
Commit
a66793d
·
verified ·
1 Parent(s): d2a6d7f

update app

Browse files
Files changed (1) hide show
  1. app.py +9 -82
app.py CHANGED
@@ -16,78 +16,7 @@ import tempfile
16
  import shutil
17
 
18
  from typing import Iterable
19
- from gradio.themes import Soft
20
- from gradio.themes.utils import colors, fonts, sizes
21
 
22
- colors.orange_red = colors.Color(
23
- name="orange_red",
24
- c50="#FFF0E5",
25
- c100="#FFE0CC",
26
- c200="#FFC299",
27
- c300="#FFA366",
28
- c400="#FF8533",
29
- c500="#FF4500",
30
- c600="#E63E00",
31
- c700="#CC3700",
32
- c800="#B33000",
33
- c900="#992900",
34
- c950="#802200",
35
- )
36
-
37
- class OrangeRedTheme(Soft):
38
- def __init__(
39
- self,
40
- *,
41
- primary_hue: colors.Color | str = colors.gray,
42
- secondary_hue: colors.Color | str = colors.orange_red, # Use the new color
43
- neutral_hue: colors.Color | str = colors.slate,
44
- text_size: sizes.Size | str = sizes.text_lg,
45
- font: fonts.Font | str | Iterable[fonts.Font | str] = (
46
- fonts.GoogleFont("Outfit"), "Arial", "sans-serif",
47
- ),
48
- font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
49
- fonts.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace",
50
- ),
51
- ):
52
- super().__init__(
53
- primary_hue=primary_hue,
54
- secondary_hue=secondary_hue,
55
- neutral_hue=neutral_hue,
56
- text_size=text_size,
57
- font=font,
58
- font_mono=font_mono,
59
- )
60
- super().set(
61
- background_fill_primary="*primary_50",
62
- background_fill_primary_dark="*primary_900",
63
- body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
64
- body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
65
- button_primary_text_color="white",
66
- button_primary_text_color_hover="white",
67
- button_primary_background_fill="linear-gradient(90deg, *secondary_500, *secondary_600)",
68
- button_primary_background_fill_hover="linear-gradient(90deg, *secondary_600, *secondary_700)",
69
- button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_700)",
70
- button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_600)",
71
- button_secondary_text_color="black",
72
- button_secondary_text_color_hover="white",
73
- button_secondary_background_fill="linear-gradient(90deg, *primary_300, *primary_300)",
74
- button_secondary_background_fill_hover="linear-gradient(90deg, *primary_400, *primary_400)",
75
- button_secondary_background_fill_dark="linear-gradient(90deg, *primary_500, *primary_600)",
76
- button_secondary_background_fill_hover_dark="linear-gradient(90deg, *primary_500, *primary_500)",
77
- slider_color="*secondary_500",
78
- slider_color_dark="*secondary_600",
79
- block_title_text_weight="600",
80
- block_border_width="3px",
81
- block_shadow="*shadow_drop_lg",
82
- button_primary_shadow="*shadow_drop_lg",
83
- button_large_padding="11px",
84
- color_accent_soft="*primary_100",
85
- block_label_background_fill="*primary_200",
86
- )
87
-
88
- orange_red_theme = OrangeRedTheme()
89
-
90
- # Helper functions
91
  def save_image(img):
92
  unique_name = str(uuid.uuid4()) + ".png"
93
  img.save(unique_name)
@@ -157,7 +86,7 @@ def load_lora_opt(pipe, lora_input):
157
  shutil.rmtree(tmp_dir, ignore_errors=True)
158
 
159
  # Generation function for Qwen/Qwen-Image
160
- @spaces.GPU(duration=120)
161
  def generate_qwen(
162
  prompt: str,
163
  negative_prompt: str = "",
@@ -223,7 +152,7 @@ def generate_qwen(
223
  return image_paths, seed, f"{duration:.2f}", zip_path
224
 
225
  # Wrapper function to handle UI logic
226
- @spaces.GPU(duration=120)
227
  def generate(
228
  prompt: str,
229
  negative_prompt: str,
@@ -273,16 +202,10 @@ css = '''
273
  margin: 0 auto !important;
274
  }
275
  #main-title h1 { font-size: 2.3em !important; }
276
- h1 {
277
- text-align: center;
278
- }
279
- footer {
280
- visibility: hidden;
281
- }
282
  '''
283
 
284
- # Gradio interface
285
- with gr.Blocks(delete_cache=(240, 240)) as demo:
286
  gr.Markdown("# **Qwen-Image-Diffusion**", elem_id="main-title")
287
  result = gr.Gallery(label="Result", columns=1, show_label=False, preview=True)
288
  with gr.Row():
@@ -424,4 +347,8 @@ with gr.Blocks(delete_cache=(240, 240)) as demo:
424
  )
425
 
426
  if __name__ == "__main__":
427
- demo.queue(max_size=50).launch(css=css, theme=orange_red_theme, mcp_server=True, ssr_mode=False, show_error=True)
 
 
 
 
 
16
  import shutil
17
 
18
  from typing import Iterable
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  def save_image(img):
21
  unique_name = str(uuid.uuid4()) + ".png"
22
  img.save(unique_name)
 
86
  shutil.rmtree(tmp_dir, ignore_errors=True)
87
 
88
  # Generation function for Qwen/Qwen-Image
89
+ @spaces.GPU
90
  def generate_qwen(
91
  prompt: str,
92
  negative_prompt: str = "",
 
152
  return image_paths, seed, f"{duration:.2f}", zip_path
153
 
154
  # Wrapper function to handle UI logic
155
+ @spaces.GPU
156
  def generate(
157
  prompt: str,
158
  negative_prompt: str,
 
202
  margin: 0 auto !important;
203
  }
204
  #main-title h1 { font-size: 2.3em !important; }
205
+
 
 
 
 
 
206
  '''
207
 
208
+ with gr.Blocks() as demo:
 
209
  gr.Markdown("# **Qwen-Image-Diffusion**", elem_id="main-title")
210
  result = gr.Gallery(label="Result", columns=1, show_label=False, preview=True)
211
  with gr.Row():
 
347
  )
348
 
349
  if __name__ == "__main__":
350
+ demo.queue(max_size=50).launch(css=css, theme=gr.themes.Soft(
351
+ primary_hue="blue",
352
+ secondary_hue="indigo",
353
+ neutral_hue="slate",
354
+ ), mcp_server=True, ssr_mode=False, show_error=True)