xingqiang commited on
Commit
b8c41c5
·
1 Parent(s): 9d4731d

Fix theme customization error

Browse files
Files changed (1) hide show
  1. app.py +8 -24
app.py CHANGED
@@ -24,7 +24,7 @@ from utils import plot_detection
24
  from database import save_report, get_report_history
25
 
26
  # Set theme and styling
27
- LIGHT_THEME = gr.themes.Soft(
28
  primary_hue="blue",
29
  secondary_hue="indigo",
30
  neutral_hue="slate",
@@ -32,20 +32,8 @@ LIGHT_THEME = gr.themes.Soft(
32
  text_size=gr.themes.sizes.text_md,
33
  )
34
 
35
- DARK_THEME = gr.themes.Soft(
36
- primary_hue="blue",
37
- secondary_hue="indigo",
38
- neutral_hue="slate",
39
- radius_size=gr.themes.sizes.radius_sm,
40
- text_size=gr.themes.sizes.text_md,
41
- ).set(
42
- body_background_fill="*neutral_950",
43
- background_fill_primary="*neutral_900",
44
- background_fill_secondary="*neutral_800",
45
- text_color="*neutral_200",
46
- color_accent_soft="*primary_800",
47
- border_color_accent_subdued="*primary_700",
48
- )
49
 
50
  class TechnicalReportGenerator:
51
  def __init__(self):
@@ -457,17 +445,13 @@ def get_gpu_utilization():
457
 
458
  def toggle_dark_mode():
459
  """Toggle between light and dark themes"""
460
- current_theme = getattr(toggle_dark_mode, "current_theme", "light")
461
- if current_theme == "light":
462
- toggle_dark_mode.current_theme = "dark"
463
- return DARK_THEME
464
- else:
465
- toggle_dark_mode.current_theme = "light"
466
- return LIGHT_THEME
467
 
468
  # Create Gradio interface
469
- with gr.Blocks(theme=LIGHT_THEME) as iface:
470
- theme_state = gr.State(LIGHT_THEME)
471
 
472
  with gr.Row():
473
  gr.Markdown("# Radar Image Analysis System")
 
24
  from database import save_report, get_report_history
25
 
26
  # Set theme and styling
27
+ THEME = gr.themes.Soft(
28
  primary_hue="blue",
29
  secondary_hue="indigo",
30
  neutral_hue="slate",
 
32
  text_size=gr.themes.sizes.text_md,
33
  )
34
 
35
+ # Create a simple dark mode flag instead of custom theme
36
+ DARK_MODE = False
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  class TechnicalReportGenerator:
39
  def __init__(self):
 
445
 
446
  def toggle_dark_mode():
447
  """Toggle between light and dark themes"""
448
+ global DARK_MODE
449
+ DARK_MODE = not DARK_MODE
450
+ return gr.Theme.darkmode() if DARK_MODE else THEME
 
 
 
 
451
 
452
  # Create Gradio interface
453
+ with gr.Blocks(theme=THEME) as iface:
454
+ theme_state = gr.State(THEME)
455
 
456
  with gr.Row():
457
  gr.Markdown("# Radar Image Analysis System")