prithivMLmods commited on
Commit
44f6833
·
verified ·
1 Parent(s): c9a7c5d

update app

Browse files
Files changed (1) hide show
  1. app.py +24 -27
app.py CHANGED
@@ -25,28 +25,30 @@ from transformers.image_utils import load_image
25
  from gradio.themes import Soft
26
  from gradio.themes.utils import colors, fonts, sizes
27
 
28
- colors.steel_blue = colors.Color(
29
- name="steel_blue",
30
- c50="#EBF3F8",
31
- c100="#D3E5F0",
32
- c200="#A8CCE1",
33
- c300="#7DB3D2",
34
- c400="#529AC3",
35
- c500="#4682B4",
36
- c600="#3E72A0",
37
- c700="#36638C",
38
- c800="#2E5378",
39
- c900="#264364",
40
- c950="#1E3450",
 
 
41
  )
42
 
43
 
44
- class SteelBlueTheme(Soft):
45
  def __init__(
46
  self,
47
  *,
48
  primary_hue: colors.Color | str = colors.gray,
49
- secondary_hue: colors.Color | str = colors.steel_blue,
50
  neutral_hue: colors.Color | str = colors.slate,
51
  text_size: sizes.Size | str = sizes.text_lg,
52
  font: fonts.Font | str | Iterable[fonts.Font | str] = (
@@ -69,10 +71,10 @@ class SteelBlueTheme(Soft):
69
  background_fill_primary_dark="*primary_900",
70
  body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
71
  body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
72
- button_primary_text_color="white",
73
  button_primary_text_color_hover="white",
74
- button_primary_background_fill="linear-gradient(90deg, *secondary_500, *secondary_600)",
75
- button_primary_background_fill_hover="linear-gradient(90deg, *secondary_600, *secondary_700)",
76
  button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_800)",
77
  button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_500)",
78
  button_secondary_text_color="black",
@@ -92,7 +94,7 @@ class SteelBlueTheme(Soft):
92
  block_label_background_fill="*primary_200",
93
  )
94
 
95
- steel_blue_theme = SteelBlueTheme()
96
 
97
  MAX_MAX_NEW_TOKENS = 4096
98
  DEFAULT_MAX_NEW_TOKENS = 1024
@@ -198,10 +200,7 @@ def generate_image(model_name: str, text: str, image: Image.Image,
198
  messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": text}]}]
199
  prompt_full = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
200
  inputs = processor(
201
- text=[prompt_full], images=[image], return_tensors="pt", padding=True,
202
- truncation=True,
203
- max_length=MAX_INPUT_TOKEN_LENGTH
204
- ).to(device)
205
  streamer = TextIteratorStreamer(processor, skip_prompt=True, skip_special_tokens=True)
206
  generation_kwargs = {**inputs, "streamer": streamer, "max_new_tokens": max_new_tokens}
207
  thread = Thread(target=model.generate, kwargs=generation_kwargs)
@@ -253,9 +252,7 @@ def generate_video(model_name: str, text: str, video_path: str,
253
 
254
  prompt_full = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
255
  inputs = processor(
256
- text=[prompt_full], images=images_for_processor, return_tensors="pt", padding=True,
257
- truncation=True, max_length=MAX_INPUT_TOKEN_LENGTH
258
- ).to(device)
259
  streamer = TextIteratorStreamer(processor, skip_prompt=True, skip_special_tokens=True)
260
  generation_kwargs = {
261
  **inputs, "streamer": streamer, "max_new_tokens": max_new_tokens,
@@ -297,7 +294,7 @@ css = """
297
  """
298
 
299
  # Create the Gradio Interface
300
- with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
301
  gr.Markdown("# **Qwen3-VL-Outpost**", elem_id="main-title")
302
  with gr.Row():
303
  with gr.Column(scale=2):
 
25
  from gradio.themes import Soft
26
  from gradio.themes.utils import colors, fonts, sizes
27
 
28
+ # --- Theme and CSS Definition ---
29
+
30
+ colors.cyan = colors.Color(
31
+ name="cyan",
32
+ c50="#E0FFFF",
33
+ c100="#B3FFFF",
34
+ c200="#80FFFF",
35
+ c300="#4DFFFF",
36
+ c400="#1AFFFF",
37
+ c500="#00FFFF", # Cyan base color
38
+ c600="#00E6E6",
39
+ c700="#00CCCC",
40
+ c800="#00B3B3",
41
+ c900="#009999",
42
+ c950="#008080",
43
  )
44
 
45
 
46
+ class CyanTheme(Soft):
47
  def __init__(
48
  self,
49
  *,
50
  primary_hue: colors.Color | str = colors.gray,
51
+ secondary_hue: colors.Color | str = colors.cyan,
52
  neutral_hue: colors.Color | str = colors.slate,
53
  text_size: sizes.Size | str = sizes.text_lg,
54
  font: fonts.Font | str | Iterable[fonts.Font | str] = (
 
71
  background_fill_primary_dark="*primary_900",
72
  body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
73
  body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
74
+ button_primary_text_color="black",
75
  button_primary_text_color_hover="white",
76
+ button_primary_background_fill="linear-gradient(90deg, *secondary_400, *secondary_500)",
77
+ button_primary_background_fill_hover="linear-gradient(90deg, *secondary_500, *secondary_600)",
78
  button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_800)",
79
  button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_500)",
80
  button_secondary_text_color="black",
 
94
  block_label_background_fill="*primary_200",
95
  )
96
 
97
+ cyan_theme = CyanTheme()
98
 
99
  MAX_MAX_NEW_TOKENS = 4096
100
  DEFAULT_MAX_NEW_TOKENS = 1024
 
200
  messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": text}]}]
201
  prompt_full = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
202
  inputs = processor(
203
+ text=[prompt_full], images=[image], return_tensors="pt", padding=True).to(device)
 
 
 
204
  streamer = TextIteratorStreamer(processor, skip_prompt=True, skip_special_tokens=True)
205
  generation_kwargs = {**inputs, "streamer": streamer, "max_new_tokens": max_new_tokens}
206
  thread = Thread(target=model.generate, kwargs=generation_kwargs)
 
252
 
253
  prompt_full = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
254
  inputs = processor(
255
+ text=[prompt_full], images=images_for_processor, return_tensors="pt", padding=True).to(device)
 
 
256
  streamer = TextIteratorStreamer(processor, skip_prompt=True, skip_special_tokens=True)
257
  generation_kwargs = {
258
  **inputs, "streamer": streamer, "max_new_tokens": max_new_tokens,
 
294
  """
295
 
296
  # Create the Gradio Interface
297
+ with gr.Blocks(css=css, theme=cyan_theme) as demo:
298
  gr.Markdown("# **Qwen3-VL-Outpost**", elem_id="main-title")
299
  with gr.Row():
300
  with gr.Column(scale=2):