eusholli commited on
Commit
cceb599
·
verified ·
1 Parent(s): 661f4b3

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. .hfignore +7 -0
  2. gradio_interface.py +140 -125
.hfignore CHANGED
@@ -1 +1,8 @@
 
1
  venv/
 
 
 
 
 
 
 
1
+ # Python Virtual Environment
2
  venv/
3
+
4
+ # Python cache
5
+ __pycache__/
6
+
7
+ # Mac specific
8
+ .DS_Store
gradio_interface.py CHANGED
@@ -5,187 +5,196 @@ import asyncio
5
  from director_bake_off import run_bake_off
6
  import traceback
7
 
8
- # --- Start of Updated CSS ---
9
-
10
- # Professional, theme-adaptive CSS for Gradio on Hugging Face Spaces
11
- SWEDISH_CSS = """
12
- /* Professional & Theme-Adaptive Design */
13
- :root {
14
- /* Define a consistent font stack and custom accent colors */
15
- --font-family-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
16
- --accent-blue: #4A90A4;
17
- --accent-blue-soft: #E8F4F8;
18
- --accent-gold: #D4AF37;
19
- --accent-green: #7FB069;
20
- --warm-beige: #E8DCC6;
21
- --charcoal: #2C2C2C;
22
-
23
- /* Light Mode Custom Colors */
24
- --card-bg-color: var(--accent-blue-soft);
25
- --card-border-color: var(--accent-blue);
26
- --explanation-bg: var(--background-fill-secondary);
27
- --details-bg-color: #f9fafb; /* A slightly off-white for light mode */
28
  }
29
 
30
- /* Define Dark Mode specific overrides */
31
- html[data-theme="dark"] {
32
- --card-bg-color: #1e293b; /* A deep, cool blue for dark mode cards */
33
- --card-border-color: var(--accent-blue);
34
- --explanation-bg: #283647; /* Darker blue for explanation box */
35
- --details-bg-color: #111827; /* Very dark gray for details dropdown */
 
 
 
 
36
  }
37
 
38
- /* Global styling */
39
  .gradio-container {
40
- font-family: var(--font-family-sans) !important;
41
- background-color: var(--body-background-fill) !important;
 
42
  }
43
 
44
  /* Header styling */
45
  .main-header {
46
  text-align: center;
47
- padding: 2rem 1rem;
48
- border-bottom: 1px solid var(--border-color-primary);
 
49
  margin-bottom: 2rem;
50
  }
51
 
52
  .main-title {
53
- font-size: 2.5rem;
54
- font-weight: 600;
55
- color: var(--text-color-primary);
56
  margin-bottom: 0.5rem;
57
- letter-spacing: -0.02em;
58
  }
59
 
60
  .main-subtitle {
61
- font-size: 1.1rem;
62
- color: var(--accent-blue);
63
  font-weight: 400;
64
  }
65
 
66
- /* Input/Results container shared style */
67
- .input-section, .results-container {
68
- background: var(--background-fill-primary);
69
- border-radius: 12px;
70
- padding: 2rem;
71
- border: 1px solid var(--border-color-primary);
72
- margin-bottom: 2rem;
 
 
 
 
 
73
  }
74
 
75
  /* Button styling */
76
  .submit-btn {
77
- background: var(--accent-blue) !important;
 
78
  border: none !important;
79
- border-radius: 8px !important;
80
- padding: 12px 32px !important;
81
  font-weight: 600 !important;
82
- font-size: 1rem !important;
83
- color: white !important;
84
- transition: background 0.2s ease, transform 0.2s ease !important;
85
  }
86
 
87
  .submit-btn:hover {
88
- background: #5BA0B5 !important; /* Slightly lighter blue on hover */
89
- transform: translateY(-2px) !important;
90
  }
91
 
92
- /* Director card styling */
93
- .director-card {
94
- background: var(--card-bg-color);
95
- border-radius: 10px;
 
96
  padding: 1.5rem;
97
- margin-bottom: 1.5rem;
98
- border-left: 4px solid var(--card-border-color);
99
- transition: box-shadow 0.3s ease;
100
  }
101
 
102
- .director-card:hover {
103
- box-shadow: 0 8px 25px rgba(0,0,0,0.1);
 
 
 
 
104
  }
105
 
106
  .rank-badge {
107
  display: inline-block;
108
- color: white;
109
- padding: 4px 12px;
110
- border-radius: 20px;
111
- font-size: 0.85rem;
 
112
  font-weight: 600;
113
  margin-bottom: 0.5rem;
114
  }
115
 
116
- /* Ranking badge colors */
117
- .rank-1 { background: var(--accent-gold); }
118
- .rank-2 { background: #A0A0A0; }
119
- .rank-3 { background: #CD7F32; }
120
 
121
  .director-name {
122
- font-size: 1.3rem;
123
  font-weight: 600;
124
- color: var(--text-color-primary);
125
  margin-bottom: 1rem;
126
  }
127
 
128
  .prompt-text {
129
- font-size: 1rem;
130
- line-height: 1.6;
131
- color: var(--text-color-secondary);
132
- background: var(--background-fill-secondary);
133
  padding: 1rem;
134
- border-radius: 8px;
135
- border: 1px solid var(--border-color-primary);
 
136
  margin-bottom: 1rem;
137
  }
138
 
139
- /* Custom card for the additional director */
140
  .additional-director {
141
- background: var(--warm-beige);
142
- border-radius: 10px;
 
143
  padding: 1.5rem;
144
- margin-bottom: 2rem;
145
- border-left: 4px solid var(--accent-green);
146
- }
147
- .additional-director .section-title, .additional-director div {
148
- color: var(--charcoal) !important; /* Force dark text on light background */
149
  }
150
 
151
- /* Explanation section */
152
  .explanation-section {
153
- background: var(--explanation-bg);
154
- border-radius: 10px;
 
155
  padding: 1.5rem;
156
- margin-top: 2rem;
157
- border-left: 4px solid var(--accent-blue);
158
- }
159
- .explanation-section .section-title, .explanation-section div {
160
- color: var(--text-color-primary);
161
  }
162
 
163
  .section-title {
164
- font-size: 1.2rem;
165
  font-weight: 600;
166
- color: var(--text-color-primary);
167
  margin-bottom: 1rem;
168
  }
169
 
170
- /* Details dropdown styling for director cards */
171
- details > summary {
172
- cursor: pointer;
173
- font-weight: 500;
174
- color: var(--accent-blue);
175
  }
176
- details > div {
177
- margin-top: 1rem;
178
- padding: 1rem;
179
- background: var(--details-bg-color);
180
- border-radius: 6px;
181
- border: 1px solid var(--border-color-primary);
182
  }
183
- """
184
- # --- End of Updated CSS ---
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
  def format_results_html(result):
188
- """Format the results into beautiful HTML with Swedish design."""
189
  if not result:
190
  return "<div class='loading'>No results to display.</div>"
191
 
@@ -195,7 +204,7 @@ def format_results_html(result):
195
  <div class="results-container">
196
  <div class="additional-director">
197
  <div class="section-title">🎬 AI Suggested Director</div>
198
- <div style="font-size: 1.1rem;">
199
  <strong>{result.additional_director}</strong> - A perfect match for your vision!
200
  </div>
201
  </div>
@@ -222,10 +231,10 @@ def format_results_html(result):
222
  <div class="prompt-text">{director_cut.assemble_prompt()}</div>
223
 
224
  <details style="margin-top: 1rem;">
225
- <summary>
226
  View Detailed Breakdown
227
  </summary>
228
- <div>
229
  <div style="margin-bottom: 0.8rem;"><strong>Subject:</strong> {director_cut.subject_description}</div>
230
  <div style="margin-bottom: 0.8rem;"><strong>Action:</strong> {director_cut.action_description}</div>
231
  <div style="margin-bottom: 0.8rem;"><strong>Setting:</strong> {director_cut.setting_description}</div>
@@ -242,7 +251,7 @@ def format_results_html(result):
242
  html += f"""
243
  <div class="explanation-section">
244
  <div class="section-title">🤔 Judge's Reasoning</div>
245
- <div style="line-height: 1.8; font-size: 1rem;">
246
  {result.director_ranks.explanation}
247
  </div>
248
  </div>
@@ -254,7 +263,7 @@ def format_results_html(result):
254
  except Exception as e:
255
  return f"""
256
  <div class="results-container">
257
- <div style="color: #e74c3c; padding: 1rem; background: #fdf2f2; border-radius: 8px;">
258
  <strong>Error formatting results:</strong> {str(e)}
259
  </div>
260
  </div>
@@ -268,18 +277,18 @@ def run_director_bakeoff(video_idea, directors):
268
  try:
269
  # Initial loading message with expectations
270
  yield """
271
- <div class='loading' style='background: var(--background-fill-secondary); padding: 2rem; border-radius: 12px; border-left: 4px solid var(--accent-blue);'>
272
- <div style='font-size: 1.3rem; font-weight: 600; color: var(--text-color-primary); margin-bottom: 1rem;'>
273
  🎬 Director Bake-Off in Progress...
274
  </div>
275
- <div style='font-size: 1rem; color: var(--text-color-secondary); margin-bottom: 1.5rem; line-height: 1.6;'>
276
  Please be patient, this may take some minutes...<br>
277
  We're consulting with legendary directors to bring your vision to life!<br>
278
  <strong>This process typically takes 30-60 seconds.</strong><br>
279
 
280
  </div>
281
- <div style='background: var(--background-fill-primary); padding: 1rem; border-radius: 8px; border-left: 3px solid var(--accent-gold);'>
282
- <div style='font-size: 0.9rem; color: var(--text-color-primary);'>
283
  <strong>What's happening:</strong><br>
284
  • Finding the perfect additional director for your concept<br>
285
  • Generating unique interpretations from each director<br>
@@ -315,7 +324,14 @@ def run_director_bakeoff(video_idea, directors):
315
 
316
  # Create the Gradio interface
317
  def create_interface():
318
- with gr.Blocks(css=SWEDISH_CSS, title="Director Bake-Off Studio") as interface:
 
 
 
 
 
 
 
319
  # Header
320
  gr.HTML("""
321
  <div class="main-header">
@@ -326,9 +342,9 @@ def create_interface():
326
 
327
  # How it Works section - moved to top
328
  gr.HTML("""
329
- <div style="background: var(--card-bg-color); padding: 1.5rem; border-radius: 10px; margin-bottom: 2rem; border-left: 4px solid var(--accent-blue);">
330
- <h3 style="margin-top: 0; color: var(--text-color-primary);">How it works:</h3>
331
- <ol style="color: var(--text-color-secondary); line-height: 1.6;">
332
  <li>Enter your video idea in the text area below</li>
333
  <li>List your favorite directors (or use our defaults)</li>
334
  <li>Our AI will suggest an additional director perfect for your vision</li>
@@ -384,7 +400,7 @@ def create_interface():
384
 
385
  # Footer
386
  gr.HTML("""
387
- <div style="text-align: center; padding: 2rem; color: var(--text-color-secondary); font-size: 0.9rem;">
388
  <p>Powered by DSPy and the creative genius of legendary directors 🎬</p>
389
  </div>
390
  """)
@@ -401,4 +417,3 @@ if __name__ == "__main__":
401
  show_error=True,
402
  debug=True
403
  )
404
-
 
5
  from director_bake_off import run_bake_off
6
  import traceback
7
 
8
+ # Clean, professional light mode styling
9
+ LIGHT_MODE_CSS = """
10
+ /* Force light mode and override system preferences */
11
+ * {
12
+ color-scheme: light !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
+ /* Override any dark mode media queries */
16
+ @media (prefers-color-scheme: dark) {
17
+ :root {
18
+ color-scheme: light !important;
19
+ }
20
+
21
+ body, .gradio-container {
22
+ background: #ffffff !important;
23
+ color: #1f2937 !important;
24
+ }
25
  }
26
 
27
+ /* Clean, professional styling */
28
  .gradio-container {
29
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
30
+ background: #ffffff !important;
31
+ color: #1f2937 !important;
32
  }
33
 
34
  /* Header styling */
35
  .main-header {
36
  text-align: center;
37
+ padding: 2rem 0;
38
+ background: #ffffff;
39
+ border-bottom: 1px solid #e5e7eb;
40
  margin-bottom: 2rem;
41
  }
42
 
43
  .main-title {
44
+ font-size: 2.25rem;
45
+ font-weight: 700;
46
+ color: #1f2937;
47
  margin-bottom: 0.5rem;
 
48
  }
49
 
50
  .main-subtitle {
51
+ font-size: 1.125rem;
52
+ color: #6b7280;
53
  font-weight: 400;
54
  }
55
 
56
+ /* Ensure all text inputs are visible and readable */
57
+ .gr-textbox, .gr-textarea, input, textarea {
58
+ background: #ffffff !important;
59
+ color: #1f2937 !important;
60
+ border: 1px solid #d1d5db !important;
61
+ border-radius: 6px !important;
62
+ }
63
+
64
+ .gr-textbox:focus, .gr-textarea:focus, input:focus, textarea:focus {
65
+ border-color: #3b82f6 !important;
66
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
67
+ outline: none !important;
68
  }
69
 
70
  /* Button styling */
71
  .submit-btn {
72
+ background: #3b82f6 !important;
73
+ color: #ffffff !important;
74
  border: none !important;
75
+ border-radius: 6px !important;
76
+ padding: 0.75rem 1.5rem !important;
77
  font-weight: 600 !important;
78
+ transition: background-color 0.2s !important;
 
 
79
  }
80
 
81
  .submit-btn:hover {
82
+ background: #2563eb !important;
 
83
  }
84
 
85
+ /* Results styling */
86
+ .results-container {
87
+ background: #ffffff;
88
+ border: 1px solid #e5e7eb;
89
+ border-radius: 8px;
90
  padding: 1.5rem;
91
+ margin-top: 1.5rem;
 
 
92
  }
93
 
94
+ .director-card {
95
+ background: #f9fafb;
96
+ border: 1px solid #e5e7eb;
97
+ border-radius: 8px;
98
+ padding: 1.5rem;
99
+ margin-bottom: 1rem;
100
  }
101
 
102
  .rank-badge {
103
  display: inline-block;
104
+ background: #3b82f6;
105
+ color: #ffffff;
106
+ padding: 0.25rem 0.75rem;
107
+ border-radius: 9999px;
108
+ font-size: 0.875rem;
109
  font-weight: 600;
110
  margin-bottom: 0.5rem;
111
  }
112
 
113
+ .rank-1 { background: #f59e0b; }
114
+ .rank-2 { background: #6b7280; }
115
+ .rank-3 { background: #d97706; }
 
116
 
117
  .director-name {
118
+ font-size: 1.25rem;
119
  font-weight: 600;
120
+ color: #1f2937;
121
  margin-bottom: 1rem;
122
  }
123
 
124
  .prompt-text {
125
+ background: #ffffff;
126
+ color: #1f2937;
 
 
127
  padding: 1rem;
128
+ border: 1px solid #e5e7eb;
129
+ border-radius: 6px;
130
+ line-height: 1.6;
131
  margin-bottom: 1rem;
132
  }
133
 
 
134
  .additional-director {
135
+ background: #ecfdf5;
136
+ border: 1px solid #d1fae5;
137
+ border-radius: 8px;
138
  padding: 1.5rem;
139
+ margin-bottom: 1.5rem;
 
 
 
 
140
  }
141
 
 
142
  .explanation-section {
143
+ background: #f8fafc;
144
+ border: 1px solid #e2e8f0;
145
+ border-radius: 8px;
146
  padding: 1.5rem;
147
+ margin-top: 1.5rem;
 
 
 
 
148
  }
149
 
150
  .section-title {
151
+ font-size: 1.125rem;
152
  font-weight: 600;
153
+ color: #1f2937;
154
  margin-bottom: 1rem;
155
  }
156
 
157
+ .loading {
158
+ text-align: center;
159
+ padding: 2rem;
160
+ color: #6b7280;
 
161
  }
162
+
163
+ /* Ensure all Gradio components use light mode */
164
+ .gr-block, .gr-form, .gr-box {
165
+ background: #ffffff !important;
166
+ color: #1f2937 !important;
 
167
  }
 
 
168
 
169
+ /* Override any remaining dark mode styles */
170
+ .dark, [data-theme="dark"] {
171
+ background: #ffffff !important;
172
+ color: #1f2937 !important;
173
+ }
174
+
175
+ /* Force all text elements to be visible */
176
+ h1, h2, h3, h4, h5, h6, p, div, span, li, ol, ul {
177
+ color: #1f2937 !important;
178
+ }
179
+
180
+ /* Ensure HTML content is visible */
181
+ .gr-html * {
182
+ color: #1f2937 !important;
183
+ }
184
+
185
+ /* Force visibility for all text content */
186
+ * {
187
+ color: #1f2937 !important;
188
+ }
189
+
190
+ /* Override Gradio's default text colors */
191
+ .gradio-container * {
192
+ color: #1f2937 !important;
193
+ }
194
+ """
195
 
196
  def format_results_html(result):
197
+ """Format the results into clean, professional HTML."""
198
  if not result:
199
  return "<div class='loading'>No results to display.</div>"
200
 
 
204
  <div class="results-container">
205
  <div class="additional-director">
206
  <div class="section-title">🎬 AI Suggested Director</div>
207
+ <div style="font-size: 1.1rem; color: #1f2937;">
208
  <strong>{result.additional_director}</strong> - A perfect match for your vision!
209
  </div>
210
  </div>
 
231
  <div class="prompt-text">{director_cut.assemble_prompt()}</div>
232
 
233
  <details style="margin-top: 1rem;">
234
+ <summary style="cursor: pointer; font-weight: 500; color: #3b82f6;">
235
  View Detailed Breakdown
236
  </summary>
237
+ <div style="margin-top: 1rem; padding: 1rem; background: #f8fafc; border-radius: 6px; color: #1f2937;">
238
  <div style="margin-bottom: 0.8rem;"><strong>Subject:</strong> {director_cut.subject_description}</div>
239
  <div style="margin-bottom: 0.8rem;"><strong>Action:</strong> {director_cut.action_description}</div>
240
  <div style="margin-bottom: 0.8rem;"><strong>Setting:</strong> {director_cut.setting_description}</div>
 
251
  html += f"""
252
  <div class="explanation-section">
253
  <div class="section-title">🤔 Judge's Reasoning</div>
254
+ <div style="line-height: 1.8; color: #1f2937; font-size: 1rem;">
255
  {result.director_ranks.explanation}
256
  </div>
257
  </div>
 
263
  except Exception as e:
264
  return f"""
265
  <div class="results-container">
266
+ <div style="color: #dc2626; padding: 1rem; background: #fef2f2; border-radius: 8px;">
267
  <strong>Error formatting results:</strong> {str(e)}
268
  </div>
269
  </div>
 
277
  try:
278
  # Initial loading message with expectations
279
  yield """
280
+ <div class='loading' style='background: #f0f9ff; padding: 2rem; border-radius: 8px; border-left: 4px solid #3b82f6;'>
281
+ <div style='font-size: 1.3rem; font-weight: 600; color: #1f2937; margin-bottom: 1rem;'>
282
  🎬 Director Bake-Off in Progress...
283
  </div>
284
+ <div style='font-size: 1rem; color: #6b7280; margin-bottom: 1.5rem; line-height: 1.6;'>
285
  Please be patient, this may take some minutes...<br>
286
  We're consulting with legendary directors to bring your vision to life!<br>
287
  <strong>This process typically takes 30-60 seconds.</strong><br>
288
 
289
  </div>
290
+ <div style='background: #ffffff; padding: 1rem; border-radius: 8px; border-left: 3px solid #f59e0b;'>
291
+ <div style='font-size: 0.9rem; color: #1f2937;'>
292
  <strong>What's happening:</strong><br>
293
  • Finding the perfect additional director for your concept<br>
294
  • Generating unique interpretations from each director<br>
 
324
 
325
  # Create the Gradio interface
326
  def create_interface():
327
+ # Force light mode theme
328
+ light_theme = gr.themes.Default(
329
+ primary_hue="blue",
330
+ secondary_hue="gray",
331
+ neutral_hue="gray"
332
+ )
333
+
334
+ with gr.Blocks(css=LIGHT_MODE_CSS, theme=light_theme, title="Director Bake-Off Studio") as interface:
335
  # Header
336
  gr.HTML("""
337
  <div class="main-header">
 
342
 
343
  # How it Works section - moved to top
344
  gr.HTML("""
345
+ <div style="background: #f0f9ff; padding: 1.5rem; border-radius: 8px; margin-bottom: 2rem; border-left: 4px solid #3b82f6;">
346
+ <h3 style="margin-top: 0; color: #1f2937;">How it works:</h3>
347
+ <ol style="color: #1f2937; line-height: 1.6;">
348
  <li>Enter your video idea in the text area below</li>
349
  <li>List your favorite directors (or use our defaults)</li>
350
  <li>Our AI will suggest an additional director perfect for your vision</li>
 
400
 
401
  # Footer
402
  gr.HTML("""
403
+ <div style="text-align: center; padding: 2rem; color: #6b7280; font-size: 0.9rem;">
404
  <p>Powered by DSPy and the creative genius of legendary directors 🎬</p>
405
  </div>
406
  """)
 
417
  show_error=True,
418
  debug=True
419
  )