prithivMLmods commited on
Commit
df70221
·
verified ·
1 Parent(s): 62eda38

update app

Browse files
Files changed (1) hide show
  1. app.py +97 -32
app.py CHANGED
@@ -30,30 +30,37 @@ from transformers import (
30
  from gradio.themes import Soft
31
  from gradio.themes.utils import colors, fonts, sizes
32
 
33
- # --- Theme Definition ---
34
-
35
- # Define a new color palette for Blue
36
- colors.blue_theme_color = colors.Color(
37
- name="blue_theme_color",
38
- c50="#E6E6FF",
39
- c100="#CCCCFF",
40
- c200="#9999FF",
41
- c300="#6666FF",
42
- c400="#3333FF",
43
- c500="#0000FF", # Base Blue color
44
- c600="#0000D9",
45
- c700="#0000B3",
46
- c800="#000080",
47
- c900="#000066",
48
- c950="#000033",
49
  )
50
 
51
- class BlueTheme(Soft):
 
 
 
 
 
 
 
52
  def __init__(
53
  self,
54
  *,
55
  primary_hue: colors.Color | str = colors.gray,
56
- secondary_hue: colors.Color | str = colors.blue_theme_color,
57
  neutral_hue: colors.Color | str = colors.slate,
58
  text_size: sizes.Size | str = sizes.text_lg,
59
  font: fonts.Font | str | Iterable[fonts.Font | str] = (
@@ -76,24 +83,85 @@ class BlueTheme(Soft):
76
  background_fill_primary_dark="*primary_900",
77
  body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
78
  body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
79
- button_primary_text_color="white",
80
  button_primary_text_color_hover="white",
81
- button_primary_background_fill="linear-gradient(90deg, *secondary_500, *secondary_600)",
82
- button_primary_background_fill_hover="linear-gradient(90deg, *secondary_600, *secondary_700)",
83
  button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_700)",
84
  button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_600)",
85
- slider_color="*secondary_500",
 
 
 
 
 
 
86
  slider_color_dark="*secondary_600",
87
  block_title_text_weight="600",
88
- block_border_width="2px",
89
  block_shadow="*shadow_drop_lg",
90
  button_primary_shadow="*shadow_drop_lg",
91
- button_large_padding="12px",
 
92
  block_label_background_fill="*primary_200",
93
  )
94
 
95
- # Instantiate the theme
96
- blue_theme = BlueTheme()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  # --- Constants and Model Setup ---
99
  MAX_INPUT_TOKEN_LENGTH = 4096
@@ -335,11 +403,8 @@ def process_document_stream(
335
 
336
  def create_gradio_interface():
337
  """Builds and returns the Gradio web interface."""
338
- css = """
339
- .main-container { max-width: 1400px; margin: 0 auto; }
340
- #main-title h1 {font-size: 2.2em !important;}
341
- """
342
- with gr.Blocks(theme=blue_theme, css=css) as demo:
343
  gr.Markdown("# **Multimodal VLM v1.0**", elem_id="main-title")
344
  gr.Markdown("Explore the capabilities of various Vision Language Models for tasks like OCR, VQA, and Object Detection.")
345
 
@@ -367,7 +432,7 @@ def create_gradio_interface():
367
  clear_btn = gr.Button("Clear", variant="secondary")
368
 
369
  with gr.Column(scale=2):
370
- #gr.Markdown("### 2. View Output")
371
  with gr.Tab("Output Stream"):
372
  output_stream = gr.Textbox(label="Model Output", interactive=False, lines=24, show_copy_button=True)
373
 
 
30
  from gradio.themes import Soft
31
  from gradio.themes.utils import colors, fonts, sizes
32
 
33
+ # --- Theme and CSS Definition ---
34
+
35
+ # Define the Thistle color palette
36
+ colors.thistle = colors.Color(
37
+ name="thistle",
38
+ c50="#F9F5F9",
39
+ c100="#F0E8F1",
40
+ c200="#E7DBE8",
41
+ c300="#DECEE0",
42
+ c400="#D2BFD8",
43
+ c500="#D8BFD8", # Thistle base color
44
+ c600="#B59CB7",
45
+ c700="#927996",
46
+ c800="#6F5675",
47
+ c900="#4C3454",
48
+ c950="#291233",
49
  )
50
 
51
+ colors.red_gray = colors.Color(
52
+ name="red_gray",
53
+ c50="#f7eded", c100="#f5dcdc", c200="#efb4b4", c300="#e78f8f",
54
+ c400="#d96a6a", c500="#c65353", c600="#b24444", c700="#8f3434",
55
+ c800="#732d2d", c900="#5f2626", c950="#4d2020",
56
+ )
57
+
58
+ class ThistleTheme(Soft):
59
  def __init__(
60
  self,
61
  *,
62
  primary_hue: colors.Color | str = colors.gray,
63
+ secondary_hue: colors.Color | str = colors.thistle, # Use the new color
64
  neutral_hue: colors.Color | str = colors.slate,
65
  text_size: sizes.Size | str = sizes.text_lg,
66
  font: fonts.Font | str | Iterable[fonts.Font | str] = (
 
83
  background_fill_primary_dark="*primary_900",
84
  body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
85
  body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
86
+ button_primary_text_color="black",
87
  button_primary_text_color_hover="white",
88
+ button_primary_background_fill="linear-gradient(90deg, *secondary_400, *secondary_500)",
89
+ button_primary_background_fill_hover="linear-gradient(90deg, *secondary_500, *secondary_600)",
90
  button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_700)",
91
  button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_600)",
92
+ button_secondary_text_color="black",
93
+ button_secondary_text_color_hover="white",
94
+ button_secondary_background_fill="linear-gradient(90deg, *primary_300, *primary_300)",
95
+ button_secondary_background_fill_hover="linear-gradient(90deg, *primary_400, *primary_400)",
96
+ button_secondary_background_fill_dark="linear-gradient(90deg, *primary_500, *primary_600)",
97
+ button_secondary_background_fill_hover_dark="linear-gradient(90deg, *primary_500, *primary_500)",
98
+ slider_color="*secondary_400",
99
  slider_color_dark="*secondary_600",
100
  block_title_text_weight="600",
101
+ block_border_width="3px",
102
  block_shadow="*shadow_drop_lg",
103
  button_primary_shadow="*shadow_drop_lg",
104
+ button_large_padding="11px",
105
+ color_accent_soft="*primary_100",
106
  block_label_background_fill="*primary_200",
107
  )
108
 
109
+ # Instantiate the new theme
110
+ thistle_theme = ThistleTheme()
111
+
112
+ css = """
113
+ #main-title h1 {
114
+ font-size: 2.3em !important;
115
+ }
116
+ #output-title h2 {
117
+ font-size: 2.1em !important;
118
+ }
119
+ :root {
120
+ --color-grey-50: #f9fafb;
121
+ --banner-background: var(--secondary-400);
122
+ --banner-text-color: var(--primary-100);
123
+ --banner-background-dark: var(--secondary-800);
124
+ --banner-text-color-dark: var(--primary-100);
125
+ --banner-chrome-height: calc(16px + 43px);
126
+ --chat-chrome-height-wide-no-banner: 320px;
127
+ --chat-chrome-height-narrow-no-banner: 450px;
128
+ --chat-chrome-height-wide: calc(var(--chat-chrome-height-wide-no-banner) + var(--banner-chrome-height));
129
+ --chat-chrome-height-narrow: calc(var(--chat-chrome-height-narrow-no-banner) + var(--banner-chrome-height));
130
+ }
131
+ .banner-message { background-color: var(--banner-background); padding: 5px; margin: 0; border-radius: 5px; border: none; }
132
+ .banner-message-text { font-size: 13px; font-weight: bolder; color: var(--banner-text-color) !important; }
133
+ body.dark .banner-message { background-color: var(--banner-background-dark) !important; }
134
+ body.dark .gradio-container .contain .banner-message .banner-message-text { color: var(--banner-text-color-dark) !important; }
135
+ .toast-body { background-color: var(--color-grey-50); }
136
+ .html-container:has(.css-styles) { padding: 0; margin: 0; }
137
+ .css-styles { height: 0; }
138
+ .model-message { text-align: end; }
139
+ .model-dropdown-container { display: flex; align-items: center; gap: 10px; padding: 0; }
140
+ .user-input-container .multimodal-textbox{ border: none !important; }
141
+ .control-button { height: 51px; }
142
+ button.cancel { border: var(--button-border-width) solid var(--button-cancel-border-color); background: var(--button-cancel-background-fill); color: var(--button-cancel-text-color); box-shadow: var(--button-cancel-shadow); }
143
+ button.cancel:hover, .cancel[disabled] { background: var(--button-cancel-background-fill-hover); color: var(--button-cancel-text-color-hover); }
144
+ .opt-out-message { top: 8px; }
145
+ .opt-out-message .html-container, .opt-out-checkbox label { font-size: 14px !important; padding: 0 !important; margin: 0 !important; color: var(--neutral-400) !important; }
146
+ div.block.chatbot { height: calc(100svh - var(--chat-chrome-height-wide)) !important; max-height: 900px !important; }
147
+ div.no-padding { padding: 0 !important; }
148
+ @media (max-width: 1280px) { div.block.chatbot { height: calc(100svh - var(--chat-chrome-height-wide)) !important; } }
149
+ @media (max-width: 1024px) {
150
+ .responsive-row { flex-direction: column; }
151
+ .model-message { text-align: start; font-size: 10px !important; }
152
+ .model-dropdown-container { flex-direction: column; align-items: flex-start; }
153
+ div.block.chatbot { height: calc(100svh - var(--chat-chrome-height-narrow)) !important; }
154
+ }
155
+ @media (max-width: 400px) {
156
+ .responsive-row { flex-direction: column; }
157
+ .model-message { text-align: start; font-size: 10px !important; }
158
+ .model-dropdown-container { flex-direction: column; align-items: flex-start; }
159
+ div.block.chatbot { max-height: 360px !important; }
160
+ }
161
+ @media (max-height: 932px) { .chatbot { max-height: 500px !important; } }
162
+ @media (max-height: 1280px) { div.block.chatbot { max-height: 800px !important; } }
163
+ """
164
+
165
 
166
  # --- Constants and Model Setup ---
167
  MAX_INPUT_TOKEN_LENGTH = 4096
 
403
 
404
  def create_gradio_interface():
405
  """Builds and returns the Gradio web interface."""
406
+
407
+ with gr.Blocks(theme=thistle_theme, css=css) as demo:
 
 
 
408
  gr.Markdown("# **Multimodal VLM v1.0**", elem_id="main-title")
409
  gr.Markdown("Explore the capabilities of various Vision Language Models for tasks like OCR, VQA, and Object Detection.")
410
 
 
432
  clear_btn = gr.Button("Clear", variant="secondary")
433
 
434
  with gr.Column(scale=2):
435
+ gr.Markdown("## Output", elem_id="output-title")
436
  with gr.Tab("Output Stream"):
437
  output_stream = gr.Textbox(label="Model Output", interactive=False, lines=24, show_copy_button=True)
438