nirmanpatel commited on
Commit
0d57d94
ยท
verified ยท
1 Parent(s): 48d73ff

Update gradio_dashboard.py

Browse files
Files changed (1) hide show
  1. gradio_dashboard.py +170 -11
gradio_dashboard.py CHANGED
@@ -173,29 +173,134 @@ def get_thumbnails(category: str) -> list[str]:
173
  categories = ["All"] + sorted(books["simple_categories"].unique())
174
  tones = ["All", "Happy", "Surprising", "Angry", "Suspenseful", "Sad"]
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  with gr.Blocks() as dashboard:
177
  with gr.Tab("๐Ÿ” Recommender"):
178
  gr.Markdown("""
179
  <style>
180
  #form-section {
181
- padding: 18px;
182
- border: 1px solid #dcdcdc;
183
- border-radius: 15px;
184
- background: #fdfdfd;
185
  margin-bottom: 1.5rem;
186
  }
187
  .title {
188
- font-size: 32px;
189
- font-weight: bold;
 
 
 
 
 
 
 
190
  text-align: center;
191
- margin-bottom: 1em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
  </style>
194
  """)
195
 
196
  gr.Markdown("# ๐Ÿ“š Semantic Book Recommender", elem_classes="title")
197
  gr.Markdown(
198
- "Describe your ideal book and get smart recommendations based on semantics and emotions ๐ŸŽฏ"
 
199
  )
200
 
201
  with gr.Group(elem_id="form-section"):
@@ -231,6 +336,60 @@ with gr.Blocks() as dashboard:
231
  )
232
 
233
  with gr.Tab("๐Ÿ“Š Dataset Statistics"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  gr.Markdown("## ๐Ÿงฎ Dataset Summary Table")
235
  gr.Dataframe(value=get_summary_df(), interactive=False)
236
 
@@ -239,7 +398,7 @@ with gr.Blocks() as dashboard:
239
 
240
  gr.Markdown("## ๐Ÿง Pie Chart Visualization")
241
  categorical_cols = books.select_dtypes(
242
- include=["object", "category"]
243
  ).columns.tolist()
244
  col_dropdown = gr.Dropdown(
245
  choices=categorical_cols,
@@ -258,7 +417,7 @@ with gr.Blocks() as dashboard:
258
  fn=filter_by_rating, inputs=rating_slider, outputs=rating_table
259
  )
260
 
261
- gr.Markdown("## ๐Ÿ“ฆ Boxplot: Authors per Category")
262
  box_img = gr.Image(
263
  type="pil", value=plot_author_boxplot(), label="Author Count Boxplot"
264
  )
@@ -272,4 +431,4 @@ with gr.Blocks() as dashboard:
272
  cat_dropdown.change(fn=get_thumbnails, inputs=cat_dropdown, outputs=gallery)
273
 
274
  if __name__ == "__main__":
275
- dashboard.launch()
 
173
  categories = ["All"] + sorted(books["simple_categories"].unique())
174
  tones = ["All", "Happy", "Surprising", "Angry", "Suspenseful", "Sad"]
175
 
176
+ # Obsidian Dark Theme - Modern Minimalism
177
+ obsidian_theme = gr.themes.Base( # type: ignore
178
+ primary_hue="purple",
179
+ secondary_hue="slate",
180
+ neutral_hue="slate",
181
+ ).set(
182
+ # Dark surfaces
183
+ body_background_fill="#13111C",
184
+ body_background_fill_dark="#13111C",
185
+ body_text_color="#E9E6F2",
186
+ body_text_color_dark="#E9E6F2",
187
+ body_text_color_subdued="#8B8699",
188
+ body_text_color_subdued_dark="#8B8699",
189
+ # Backgrounds
190
+ background_fill_primary="#1C1829",
191
+ background_fill_primary_dark="#1C1829",
192
+ background_fill_secondary="#13111C",
193
+ background_fill_secondary_dark="#13111C",
194
+ # Button styling
195
+ button_primary_background_fill="#A78BFA",
196
+ button_primary_background_fill_dark="#A78BFA",
197
+ button_primary_background_fill_hover="#C4B5FD",
198
+ button_primary_background_fill_hover_dark="#C4B5FD",
199
+ button_primary_text_color="#13111C",
200
+ button_primary_text_color_dark="#13111C",
201
+ button_secondary_background_fill="#1C1829",
202
+ button_secondary_background_fill_dark="#1C1829",
203
+ button_secondary_background_fill_hover="#2D2A3D",
204
+ button_secondary_background_fill_hover_dark="#2D2A3D",
205
+ button_secondary_text_color="#E9E6F2",
206
+ button_secondary_text_color_dark="#E9E6F2",
207
+ # Borders
208
+ border_color_primary="#8B8699",
209
+ border_color_primary_dark="#8B8699",
210
+ border_color_accent="#A78BFA",
211
+ border_color_accent_dark="#A78BFA",
212
+ # Accent
213
+ color_accent="#A78BFA",
214
+ color_accent_soft="#2D2A3D",
215
+ color_accent_soft_dark="#2D2A3D",
216
+ # Input fields
217
+ input_background_fill="#1C1829",
218
+ input_background_fill_dark="#1C1829",
219
+ input_background_fill_hover="#2D2A3D",
220
+ input_background_fill_hover_dark="#2D2A3D",
221
+ input_background_fill_focus="#1C1829",
222
+ input_background_fill_focus_dark="#1C1829",
223
+ input_border_color="#8B8699",
224
+ input_border_color_dark="#8B8699",
225
+ input_border_color_hover="#A78BFA",
226
+ input_border_color_hover_dark="#A78BFA",
227
+ input_border_color_focus="#A78BFA",
228
+ input_border_color_focus_dark="#A78BFA",
229
+ input_placeholder_color="#8B8699",
230
+ input_placeholder_color_dark="#8B8699",
231
+ input_text_size="0.95rem",
232
+ # Block/card styling
233
+ block_background_fill="#1C1829",
234
+ block_background_fill_dark="#1C1829",
235
+ block_border_color="#2D2A3D",
236
+ block_border_color_dark="#2D2A3D",
237
+ block_info_text_color="#8B8699",
238
+ block_info_text_color_dark="#8B8699",
239
+ block_label_background_fill="#13111C",
240
+ block_label_background_fill_dark="#13111C",
241
+ block_label_text_color="#A78BFA",
242
+ block_label_text_color_dark="#A78BFA",
243
+ block_title_background_fill="#1C1829",
244
+ block_title_background_fill_dark="#1C1829",
245
+ block_title_text_color="#E9E6F2",
246
+ block_title_text_color_dark="#E9E6F2",
247
+ # Border radius
248
+ block_radius="10px",
249
+ container_radius="10px",
250
+ button_small_radius="6px",
251
+ button_medium_radius="10px",
252
+ button_large_radius="14px",
253
+ )
254
+
255
  with gr.Blocks() as dashboard:
256
  with gr.Tab("๐Ÿ” Recommender"):
257
  gr.Markdown("""
258
  <style>
259
  #form-section {
260
+ padding: 20px;
261
+ border: 1px solid #2D2A3D;
262
+ border-radius: 10px;
263
+ background: #1C1829;
264
  margin-bottom: 1.5rem;
265
  }
266
  .title {
267
+ font-size: 2.25rem;
268
+ font-weight: 700;
269
+ text-align: center;
270
+ margin-bottom: 0.5em;
271
+ color: #E9E6F2;
272
+ letter-spacing: -0.02em;
273
+ }
274
+ .subtitle {
275
+ font-size: 0.95rem;
276
  text-align: center;
277
+ color: #8B8699;
278
+ margin-bottom: 2em;
279
+ line-height: 1.55;
280
+ }
281
+ /* Dropdown styling */
282
+ .dropdown-container select,
283
+ .select-options {
284
+ border: 1px solid #8B8699 !important;
285
+ border-radius: 6px !important;
286
+ }
287
+ select {
288
+ border: 1px solid #8B8699 !important;
289
+ border-radius: 6px !important;
290
+ }
291
+ /* Horizontal separator styling */
292
+ hr {
293
+ border: none !important;
294
+ border-top: 1px solid #2D2A3D !important;
295
+ margin: 1.5rem 0 !important;
296
  }
297
  </style>
298
  """)
299
 
300
  gr.Markdown("# ๐Ÿ“š Semantic Book Recommender", elem_classes="title")
301
  gr.Markdown(
302
+ "Describe your ideal book and get smart recommendations based on semantics and emotions ๐ŸŽฏ",
303
+ elem_classes="subtitle",
304
  )
305
 
306
  with gr.Group(elem_id="form-section"):
 
336
  )
337
 
338
  with gr.Tab("๐Ÿ“Š Dataset Statistics"):
339
+ gr.Markdown("""
340
+ <style>
341
+ /* Override all text colors in tables */
342
+ table * {
343
+ color: #000000 !important;
344
+ }
345
+ table {
346
+ color: #000000 !important;
347
+ background-color: #1C1829 !important;
348
+ border: 1px solid #2D2A3D !important;
349
+ }
350
+ thead {
351
+ background-color: #2D2A3D !important;
352
+ }
353
+ thead th {
354
+ color: #000000 !important;
355
+ background-color: #2D2A3D !important;
356
+ border: 1px solid #8B8699 !important;
357
+ font-weight: 700 !important;
358
+ }
359
+ tbody tr {
360
+ background-color: #1C1829 !important;
361
+ }
362
+ tbody td {
363
+ color: #000000 !important;
364
+ background-color: #1C1829 !important;
365
+ border: 1px solid #2D2A3D !important;
366
+ }
367
+ tbody tr:nth-child(odd) td {
368
+ background-color: #1C1829 !important;
369
+ }
370
+ tbody tr:nth-child(even) td {
371
+ background-color: #13111C !important;
372
+ }
373
+ /* Ensure strong contrast */
374
+ table td, table th {
375
+ color: #000000 !important;
376
+ opacity: 1 !important;
377
+ }
378
+ /* Dropdown styling for statistics tab */
379
+ select {
380
+ border: 1px solid #8B8699 !important;
381
+ border-radius: 6px !important;
382
+ background-color: #1C1829 !important;
383
+ color: #E9E6F2 !important;
384
+ }
385
+ /* Horizontal separator */
386
+ hr {
387
+ border: none !important;
388
+ border-top: 1px solid #2D2A3D !important;
389
+ margin: 1.5rem 0 !important;
390
+ }
391
+ </style>
392
+ """)
393
  gr.Markdown("## ๐Ÿงฎ Dataset Summary Table")
394
  gr.Dataframe(value=get_summary_df(), interactive=False)
395
 
 
398
 
399
  gr.Markdown("## ๐Ÿง Pie Chart Visualization")
400
  categorical_cols = books.select_dtypes(
401
+ include=["object", "string"]
402
  ).columns.tolist()
403
  col_dropdown = gr.Dropdown(
404
  choices=categorical_cols,
 
417
  fn=filter_by_rating, inputs=rating_slider, outputs=rating_table
418
  )
419
 
420
+ gr.Markdown("## ๐Ÿ“‹ Boxplot: Authors per Category")
421
  box_img = gr.Image(
422
  type="pil", value=plot_author_boxplot(), label="Author Count Boxplot"
423
  )
 
431
  cat_dropdown.change(fn=get_thumbnails, inputs=cat_dropdown, outputs=gallery)
432
 
433
  if __name__ == "__main__":
434
+ dashboard.launch(theme=obsidian_theme)