logasanjeev commited on
Commit
cb99758
·
verified ·
1 Parent(s): 1a19984

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -12,6 +12,11 @@ from nltk.stem import WordNetLemmatizer
12
  import re
13
  import string
14
  from huggingface_hub import hf_hub_download
 
 
 
 
 
15
 
16
  # Download NLTK resources
17
  nltk.download('punkt', quiet=True)
@@ -21,7 +26,7 @@ nltk.download('omw-1.4', quiet=True)
21
  # Initialize lemmatizer
22
  lemmatizer = WordNetLemmatizer()
23
 
24
- # Define LuongAttention (placeholder for loading)
25
  class LuongAttention(tf.keras.layers.Layer):
26
  def __init__(self, **kwargs):
27
  super(LuongAttention, self).__init__(**kwargs)
@@ -122,9 +127,6 @@ h1 { color: #1a73e8; text-align: center; }
122
  .footer { text-align: center; color: #666; }
123
  .prob-bar { margin-top: 10px; }
124
  button { border-radius: 6px; }
125
- .dark { background: #1e1e1e; color: #ffffff; }
126
- .dark h1 { color: #4a90e2; }
127
- .dark .footer { color: #aaa; }
128
  """
129
 
130
  # Gradio interface
@@ -164,7 +166,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
164
 
165
  # Theme toggle logic
166
  def toggle_theme():
167
- return gr.themes.Dark() if demo.theme.name == "soft" else gr.themes.Soft()
168
 
169
  # Bind functions
170
  predict_btn.click(
@@ -174,8 +176,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
174
  )
175
  theme_toggle.click(
176
  fn=toggle_theme,
177
- outputs=None,
178
- _js="() => { document.body.classList.toggle('dark'); }"
179
  )
180
 
181
  gr.Markdown(
 
12
  import re
13
  import string
14
  from huggingface_hub import hf_hub_download
15
+ import warnings
16
+ from sklearn.exceptions import InconsistentVersionWarning
17
+
18
+ # Suppress scikit-learn warning
19
+ warnings.filterwarnings("ignore", category=InconsistentVersionWarning)
20
 
21
  # Download NLTK resources
22
  nltk.download('punkt', quiet=True)
 
26
  # Initialize lemmatizer
27
  lemmatizer = WordNetLemmatizer()
28
 
29
+ # Define LuongAttention
30
  class LuongAttention(tf.keras.layers.Layer):
31
  def __init__(self, **kwargs):
32
  super(LuongAttention, self).__init__(**kwargs)
 
127
  .footer { text-align: center; color: #666; }
128
  .prob-bar { margin-top: 10px; }
129
  button { border-radius: 6px; }
 
 
 
130
  """
131
 
132
  # Gradio interface
 
166
 
167
  # Theme toggle logic
168
  def toggle_theme():
169
+ return {"theme": gr.themes.Dark()} if demo.theme.name == "soft" else {"theme": gr.themes.Soft()}
170
 
171
  # Bind functions
172
  predict_btn.click(
 
176
  )
177
  theme_toggle.click(
178
  fn=toggle_theme,
179
+ inputs=None,
180
+ outputs=[demo]
181
  )
182
 
183
  gr.Markdown(