awsaf49 commited on
Commit
2536f16
Β·
1 Parent(s): 42c0e39
Files changed (1) hide show
  1. app.py +63 -133
app.py CHANGED
@@ -76,142 +76,75 @@ def predict(audio_file, model_name):
76
  return process_audio(audio_file, model_name)
77
 
78
 
79
- # Custom CSS for styling - Dark theme with black background
80
  css = """
81
- :root {
82
- --primary-bg: #000000;
83
- --secondary-bg: #111111;
84
- --panel-bg: #1e1e1e;
85
- --text-color: #ffffff;
86
- --text-secondary: #bbbbbb;
87
- --border-color: #333333;
88
- --analyze-button-color: #ffa500;
89
- --analyze-button-hover: #ff8c00;
90
- --accent-color: #4a78e5;
91
  }
92
 
93
- body, .gradio-container {
94
- background-color: var(--primary-bg) !important;
95
- color: var(--text-color) !important;
 
96
  }
97
 
98
- .footer, .header-container, .accordion-content {
99
- background-color: var(--secondary-bg) !important;
100
- color: var(--text-color) !important;
101
  }
102
 
103
- /* Headers and text */
104
- h1, h2, h3 {
105
- color: var(--text-color) !important;
106
  }
107
 
108
- p {
109
- color: var(--text-secondary) !important;
 
110
  }
111
 
112
- /* Button styling */
113
- button#submit_btn {
114
- background-color: var(--analyze-button-color) !important;
115
- color: white !important;
116
- border: none !important;
117
- font-weight: bold !important;
118
- padding: 10px 20px !important;
119
- font-size: 16px !important;
120
- border-radius: 8px !important;
121
  }
122
 
123
- button#submit_btn:hover {
124
- background-color: var(--analyze-button-hover) !important;
125
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5) !important;
126
- transform: translateY(-2px) !important;
127
- transition: all 0.2s ease !important;
128
- }
129
-
130
- /* Panel backgrounds */
131
- .gr-panel, .gr-box, .gr-form, .gr-input-label, .gr-input {
132
- background-color: var(--panel-bg) !important;
133
- border: 1px solid var(--border-color) !important;
134
- border-radius: 8px !important;
135
- color: var(--text-color) !important;
136
- }
137
-
138
- /* Results panel */
139
- #output {
140
- background-color: var(--panel-bg) !important;
141
- border-radius: 8px !important;
142
- padding: 10px !important;
143
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3) !important;
144
- border: 1px solid var(--border-color) !important;
145
- }
146
-
147
- /* Resource links */
148
  .resource-link {
149
- background-color: var(--secondary-bg) !important;
150
- color: var(--accent-color) !important;
151
- border: 1px solid var(--border-color) !important;
152
- padding: 8px 16px !important;
153
- border-radius: 20px !important;
154
- margin: 5px !important;
155
- text-decoration: none !important;
156
- display: inline-block !important;
157
- font-weight: 500 !important;
158
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
 
159
  }
160
 
161
  .resource-link:hover {
162
- transform: translateY(-2px) !important;
163
- box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4) !important;
164
- transition: all 0.2s ease !important;
165
- background-color: #222222 !important;
166
- }
167
-
168
- .header-container {
169
- padding: 20px !important;
170
- border-radius: 10px !important;
171
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
172
- margin-bottom: 20px !important;
173
- border: 1px solid var(--border-color) !important;
174
- }
175
-
176
- /* Accordion styling */
177
- .gr-accordion {
178
- border: 1px solid var(--border-color) !important;
179
- border-radius: 8px !important;
180
- overflow: hidden !important;
181
- background-color: var(--panel-bg) !important;
182
- }
183
-
184
- .gr-accordion-header {
185
- background-color: var(--secondary-bg) !important;
186
- padding: 10px 15px !important;
187
- font-weight: 600 !important;
188
- color: var(--text-color) !important;
189
- }
190
-
191
- /* Audio player */
192
- .audio-player {
193
- background-color: var(--panel-bg) !important;
194
- border-radius: 8px !important;
195
- overflow: hidden !important;
196
- }
197
-
198
- /* Dropdown & Input fields */
199
- select, input, .gr-dropdown {
200
- background-color: var(--panel-bg) !important;
201
- color: var(--text-color) !important;
202
- border: 1px solid var(--border-color) !important;
203
  }
204
 
205
- /* Labels */
206
- label, .gr-label {
207
- color: var(--text-secondary) !important;
208
  }
209
 
210
  /* Footer styling */
211
- .footer {
212
- border-top: 1px solid var(--border-color) !important;
213
- margin-top: 30px !important;
214
- padding: 15px !important;
215
  }
216
  """
217
 
@@ -220,14 +153,13 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
220
  # Title and Logo
221
  gr.HTML(
222
  """
223
- <div class="header-container">
224
  <div style="display: flex; justify-content: center; margin-bottom: 20px;">
225
- <img src="https://i.postimg.cc/3Jx3yZ5b/real-vs-fake-sonics-w-logo.jpg"
226
- style="max-width: 150px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.3);">
227
  </div>
228
- <h1 style="text-align: center; font-size: 28px; margin-bottom: 10px; color: #ffffff;">SONICS: Synthetic Or Not - Identifying Counterfeit Songs</h1>
229
- <h3 style="text-align: center; color: #bbbbbb; margin-bottom: 15px;">ICLR 2025 [Poster]</h3>
230
- <p style="text-align: center; font-size: 16px; margin: 0; color: #aaaaaa;">
231
  Detect if a song is real or AI-generated with our state-of-the-art models.
232
  Simply upload an audio file to verify its authenticity!
233
  </p>
@@ -235,24 +167,24 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
235
  """
236
  )
237
 
238
- # Resource Links - Simplified
239
  gr.HTML(
240
  """
241
- <div style="display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 25px;">
242
  <a href="https://openreview.net/forum?id=PY7KSh29Z8" target="_blank" class="resource-link">
243
- πŸ“„ Paper
244
  </a>
245
  <a href="https://huggingface.co/datasets/awsaf49/sonics" target="_blank" class="resource-link">
246
- 🎡 Dataset
247
  </a>
248
  <a href="https://huggingface.co/collections/awsaf49/sonics-spectttra-67bb6517b3920fd18e409013" target="_blank" class="resource-link">
249
- πŸ€– Models
250
  </a>
251
  <a href="https://arxiv.org/abs/2408.14080" target="_blank" class="resource-link">
252
- πŸ”¬ ArXiv
253
  </a>
254
  <a href="https://github.com/awsaf49/sonics" target="_blank" class="resource-link">
255
- πŸ’» GitHub
256
  </a>
257
  </div>
258
  """
@@ -264,8 +196,7 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
264
  audio_input = gr.Audio(
265
  label="Upload Audio File",
266
  type="filepath",
267
- elem_id="audio_input",
268
- elem_classes="audio-player"
269
  )
270
 
271
  model_dropdown = gr.Dropdown(
@@ -320,9 +251,9 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
320
  # Footer
321
  gr.HTML(
322
  """
323
- <div class="footer" style="text-align: center;">
324
- <p style="color: #bbbbbb; font-size: 14px;">SONICS: Synthetic Or Not - Identifying Counterfeit Songs | ICLR 2025</p>
325
- <p style="color: #777777; font-size: 12px;">For research purposes only</p>
326
  </div>
327
  """
328
  )
@@ -331,5 +262,4 @@ with gr.Blocks(css=css, theme=gr.themes.Ocean()) as demo:
331
  submit_btn.click(fn=predict, inputs=[audio_input, model_dropdown], outputs=[output])
332
 
333
  if __name__ == "__main__":
334
- # Use dark theme as base and then apply custom CSS on top
335
  demo.launch()
 
76
  return process_audio(audio_file, model_name)
77
 
78
 
79
+ # Updated CSS with better color scheme for resource links
80
  css = """
81
+ /* Custom CSS that works with Ocean theme */
82
+ .sonics-header {
83
+ text-align: center;
84
+ padding: 20px;
85
+ margin-bottom: 20px;
86
+ border-radius: 10px;
 
 
 
 
87
  }
88
 
89
+ .sonics-logo {
90
+ max-width: 150px;
91
+ border-radius: 10px;
92
+ box-shadow: 0 4px 8px rgba(0,0,0,0.3);
93
  }
94
 
95
+ .sonics-title {
96
+ font-size: 28px;
97
+ margin-bottom: 10px;
98
  }
99
 
100
+ .sonics-subtitle {
101
+ margin-bottom: 15px;
 
102
  }
103
 
104
+ .sonics-description {
105
+ font-size: 16px;
106
+ margin: 0;
107
  }
108
 
109
+ /* Resource links styling */
110
+ .resource-links {
111
+ display: flex;
112
+ justify-content: center;
113
+ flex-wrap: wrap;
114
+ gap: 8px;
115
+ margin-bottom: 25px;
 
 
116
  }
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  .resource-link {
119
+ background-color: #222222;
120
+ color: #4aedd6;
121
+ border: 1px solid #333333;
122
+ padding: 8px 16px;
123
+ border-radius: 20px;
124
+ margin: 5px;
125
+ text-decoration: none;
126
+ display: inline-block;
127
+ font-weight: 500;
128
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
129
+ transition: all 0.2s ease;
130
  }
131
 
132
  .resource-link:hover {
133
+ background-color: #333333;
134
+ transform: translateY(-2px);
135
+ box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
136
+ transition: all 0.2s ease;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
 
139
+ .resource-link-icon {
140
+ margin-right: 5px;
 
141
  }
142
 
143
  /* Footer styling */
144
+ .sonics-footer {
145
+ text-align: center;
146
+ margin-top: 30px;
147
+ padding: 15px;
148
  }
149
  """
150
 
 
153
  # Title and Logo
154
  gr.HTML(
155
  """
156
+ <div class="sonics-header">
157
  <div style="display: flex; justify-content: center; margin-bottom: 20px;">
158
+ <img src="https://i.postimg.cc/3Jx3yZ5b/real-vs-fake-sonics-w-logo.jpg" class="sonics-logo">
 
159
  </div>
160
+ <h1 class="sonics-title">SONICS: Synthetic Or Not - Identifying Counterfeit Songs</h1>
161
+ <h3 class="sonics-subtitle">ICLR 2025 [Poster]</h3>
162
+ <p class="sonics-description">
163
  Detect if a song is real or AI-generated with our state-of-the-art models.
164
  Simply upload an audio file to verify its authenticity!
165
  </p>
 
167
  """
168
  )
169
 
170
+ # Resource Links - Updated with custom styling to match screenshot
171
  gr.HTML(
172
  """
173
+ <div class="resource-links">
174
  <a href="https://openreview.net/forum?id=PY7KSh29Z8" target="_blank" class="resource-link">
175
+ <span class="resource-link-icon">πŸ“„</span>Paper
176
  </a>
177
  <a href="https://huggingface.co/datasets/awsaf49/sonics" target="_blank" class="resource-link">
178
+ <span class="resource-link-icon">🎡</span>Dataset
179
  </a>
180
  <a href="https://huggingface.co/collections/awsaf49/sonics-spectttra-67bb6517b3920fd18e409013" target="_blank" class="resource-link">
181
+ <span class="resource-link-icon">πŸ€–</span>Models
182
  </a>
183
  <a href="https://arxiv.org/abs/2408.14080" target="_blank" class="resource-link">
184
+ <span class="resource-link-icon">πŸ”¬</span>ArXiv
185
  </a>
186
  <a href="https://github.com/awsaf49/sonics" target="_blank" class="resource-link">
187
+ <span class="resource-link-icon">πŸ’»</span>GitHub
188
  </a>
189
  </div>
190
  """
 
196
  audio_input = gr.Audio(
197
  label="Upload Audio File",
198
  type="filepath",
199
+ elem_id="audio_input"
 
200
  )
201
 
202
  model_dropdown = gr.Dropdown(
 
251
  # Footer
252
  gr.HTML(
253
  """
254
+ <div class="sonics-footer">
255
+ <p>SONICS: Synthetic Or Not - Identifying Counterfeit Songs | ICLR 2025</p>
256
+ <p style="font-size: 12px;">For research purposes only</p>
257
  </div>
258
  """
259
  )
 
262
  submit_btn.click(fn=predict, inputs=[audio_input, model_dropdown], outputs=[output])
263
 
264
  if __name__ == "__main__":
 
265
  demo.launch()