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

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. gradio_interface.py +88 -105
gradio_interface.py CHANGED
@@ -5,115 +5,106 @@ import asyncio
5
  from director_bake_off import run_bake_off
6
  import traceback
7
 
8
- # Swedish-inspired color palette and styling
 
 
9
  SWEDISH_CSS = """
10
- /* Swedish Minimalist Design */
11
  :root {
12
- --primary-white: #FFFFFF;
13
- --soft-gray: #F5F5F5;
14
- --muted-blue: #4A90A4;
 
 
 
15
  --warm-beige: #E8DCC6;
16
  --charcoal: #2C2C2C;
17
- --light-blue: #E8F4F8;
18
- --accent-gold: #D4AF37;
19
- --success-green: #7FB069;
20
- --border-gray: #E0E0E0;
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
  /* Global styling */
24
  .gradio-container {
25
- font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
26
- background: linear-gradient(135deg, var(--soft-gray) 0%, var(--primary-white) 100%) !important;
27
- min-height: 100vh;
28
  }
29
 
30
  /* Header styling */
31
  .main-header {
32
  text-align: center;
33
- padding: 2rem 0;
34
- background: var(--primary-white);
35
- border-bottom: 1px solid var(--border-gray);
36
  margin-bottom: 2rem;
37
  }
38
 
39
  .main-title {
40
  font-size: 2.5rem;
41
- font-weight: 300;
42
- color: var(--charcoal);
43
  margin-bottom: 0.5rem;
44
  letter-spacing: -0.02em;
45
  }
46
 
47
  .main-subtitle {
48
  font-size: 1.1rem;
49
- color: var(--muted-blue);
50
  font-weight: 400;
51
- margin-bottom: 0;
52
  }
53
 
54
- /* Input section styling */
55
- .input-section {
56
- background: var(--primary-white);
57
  border-radius: 12px;
58
  padding: 2rem;
59
- box-shadow: 0 2px 20px rgba(0,0,0,0.05);
60
- border: 1px solid var(--border-gray);
61
  margin-bottom: 2rem;
62
  }
63
 
64
- .input-label {
65
- font-size: 1rem;
66
- font-weight: 500;
67
- color: var(--charcoal);
68
- margin-bottom: 0.5rem;
69
- display: block;
70
- }
71
-
72
  /* Button styling */
73
  .submit-btn {
74
- background: linear-gradient(135deg, var(--muted-blue) 0%, #5BA0B5 100%) !important;
75
  border: none !important;
76
  border-radius: 8px !important;
77
  padding: 12px 32px !important;
78
- font-weight: 500 !important;
79
  font-size: 1rem !important;
80
  color: white !important;
81
- transition: all 0.3s ease !important;
82
- box-shadow: 0 4px 15px rgba(74, 144, 164, 0.3) !important;
83
  }
84
 
85
  .submit-btn:hover {
 
86
  transform: translateY(-2px) !important;
87
- box-shadow: 0 6px 25px rgba(74, 144, 164, 0.4) !important;
88
- }
89
-
90
- /* Results section */
91
- .results-container {
92
- background: var(--primary-white);
93
- border-radius: 12px;
94
- padding: 2rem;
95
- box-shadow: 0 2px 20px rgba(0,0,0,0.05);
96
- border: 1px solid var(--border-gray);
97
- margin-top: 2rem;
98
  }
99
 
 
100
  .director-card {
101
- background: var(--light-blue);
102
  border-radius: 10px;
103
  padding: 1.5rem;
104
  margin-bottom: 1.5rem;
105
- border-left: 4px solid var(--muted-blue);
106
- transition: all 0.3s ease;
107
  }
108
 
109
  .director-card:hover {
110
- transform: translateY(-2px);
111
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
112
  }
113
 
114
  .rank-badge {
115
  display: inline-block;
116
- background: var(--accent-gold);
117
  color: white;
118
  padding: 4px 12px;
119
  border-radius: 20px;
@@ -122,85 +113,76 @@ SWEDISH_CSS = """
122
  margin-bottom: 0.5rem;
123
  }
124
 
 
125
  .rank-1 { background: var(--accent-gold); }
126
- .rank-2 { background: #C0C0C0; }
127
  .rank-3 { background: #CD7F32; }
128
 
129
  .director-name {
130
  font-size: 1.3rem;
131
  font-weight: 600;
132
- color: var(--charcoal);
133
  margin-bottom: 1rem;
134
  }
135
 
136
  .prompt-text {
137
  font-size: 1rem;
138
  line-height: 1.6;
139
- color: var(--charcoal);
140
- background: var(--primary-white);
141
  padding: 1rem;
142
  border-radius: 8px;
143
- border: 1px solid var(--border-gray);
144
  margin-bottom: 1rem;
145
  }
146
 
 
147
  .additional-director {
148
  background: var(--warm-beige);
149
  border-radius: 10px;
150
  padding: 1.5rem;
151
  margin-bottom: 2rem;
152
- border-left: 4px solid var(--success-green);
 
 
 
153
  }
154
 
 
155
  .explanation-section {
156
- background: var(--soft-gray);
157
  border-radius: 10px;
158
  padding: 1.5rem;
159
  margin-top: 2rem;
160
- border-left: 4px solid var(--muted-blue);
 
 
 
161
  }
162
 
163
  .section-title {
164
  font-size: 1.2rem;
165
  font-weight: 600;
166
- color: var(--charcoal);
167
  margin-bottom: 1rem;
168
  }
169
 
170
- /* Loading animation */
171
- .loading {
172
- text-align: center;
173
- padding: 2rem;
174
- color: var(--muted-blue);
175
- }
176
-
177
- /* Responsive design */
178
- @media (max-width: 768px) {
179
- .main-title {
180
- font-size: 2rem;
181
- }
182
-
183
- .input-section, .results-container {
184
- padding: 1.5rem;
185
- margin: 1rem;
186
- }
187
-
188
- .director-card {
189
- padding: 1rem;
190
- }
191
- }
192
-
193
- /* Custom textbox styling */
194
- .gr-textbox {
195
- border-radius: 8px !important;
196
- border: 1px solid var(--border-gray) !important;
197
  }
198
-
199
- .gr-textbox:focus {
200
- border-color: var(--muted-blue) !important;
201
- box-shadow: 0 0 0 3px rgba(74, 144, 164, 0.1) !important;
 
 
202
  }
203
  """
 
 
204
 
205
  def format_results_html(result):
206
  """Format the results into beautiful HTML with Swedish design."""
@@ -213,7 +195,7 @@ def format_results_html(result):
213
  <div class="results-container">
214
  <div class="additional-director">
215
  <div class="section-title">🎬 AI Suggested Director</div>
216
- <div style="font-size: 1.1rem; color: var(--charcoal);">
217
  <strong>{result.additional_director}</strong> - A perfect match for your vision!
218
  </div>
219
  </div>
@@ -240,10 +222,10 @@ def format_results_html(result):
240
  <div class="prompt-text">{director_cut.assemble_prompt()}</div>
241
 
242
  <details style="margin-top: 1rem;">
243
- <summary style="cursor: pointer; font-weight: 500; color: var(--muted-blue);">
244
  View Detailed Breakdown
245
  </summary>
246
- <div style="margin-top: 1rem; padding: 1rem; background: var(--soft-gray); border-radius: 6px;">
247
  <div style="margin-bottom: 0.8rem;"><strong>Subject:</strong> {director_cut.subject_description}</div>
248
  <div style="margin-bottom: 0.8rem;"><strong>Action:</strong> {director_cut.action_description}</div>
249
  <div style="margin-bottom: 0.8rem;"><strong>Setting:</strong> {director_cut.setting_description}</div>
@@ -260,7 +242,7 @@ def format_results_html(result):
260
  html += f"""
261
  <div class="explanation-section">
262
  <div class="section-title">🤔 Judge's Reasoning</div>
263
- <div style="line-height: 1.8; color: var(--charcoal); font-size: 1rem;">
264
  {result.director_ranks.explanation}
265
  </div>
266
  </div>
@@ -286,18 +268,18 @@ def run_director_bakeoff(video_idea, directors):
286
  try:
287
  # Initial loading message with expectations
288
  yield """
289
- <div class='loading' style='background: var(--light-blue); padding: 2rem; border-radius: 12px; border-left: 4px solid var(--muted-blue);'>
290
- <div style='font-size: 1.3rem; font-weight: 600; color: var(--charcoal); margin-bottom: 1rem;'>
291
  🎬 Director Bake-Off in Progress...
292
  </div>
293
- <div style='font-size: 1rem; color: var(--muted-blue); margin-bottom: 1.5rem; line-height: 1.6;'>
294
  Please be patient, this may take some minutes...<br>
295
  We're consulting with legendary directors to bring your vision to life!<br>
296
  <strong>This process typically takes 30-60 seconds.</strong><br>
297
 
298
  </div>
299
- <div style='background: var(--primary-white); padding: 1rem; border-radius: 8px; border-left: 3px solid var(--accent-gold);'>
300
- <div style='font-size: 0.9rem; color: var(--charcoal);'>
301
  <strong>What's happening:</strong><br>
302
  • Finding the perfect additional director for your concept<br>
303
  • Generating unique interpretations from each director<br>
@@ -344,9 +326,9 @@ def create_interface():
344
 
345
  # How it Works section - moved to top
346
  gr.HTML("""
347
- <div style="background: var(--light-blue); padding: 1.5rem; border-radius: 10px; margin-bottom: 2rem; border-left: 4px solid var(--muted-blue);">
348
- <h3 style="margin-top: 0; color: var(--charcoal);">How it works:</h3>
349
- <ol style="color: var(--charcoal); line-height: 1.6;">
350
  <li>Enter your video idea in the text area below</li>
351
  <li>List your favorite directors (or use our defaults)</li>
352
  <li>Our AI will suggest an additional director perfect for your vision</li>
@@ -402,7 +384,7 @@ def create_interface():
402
 
403
  # Footer
404
  gr.HTML("""
405
- <div style="text-align: center; padding: 2rem; color: var(--muted-blue); font-size: 0.9rem;">
406
  <p>Powered by DSPy and the creative genius of legendary directors 🎬</p>
407
  </div>
408
  """)
@@ -419,3 +401,4 @@ if __name__ == "__main__":
419
  show_error=True,
420
  debug=True
421
  )
 
 
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;
 
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."""
 
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
  <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
  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>
 
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>
 
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
 
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
  show_error=True,
402
  debug=True
403
  )
404
+