Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .hfignore +7 -0
- 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 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
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 |
-
/*
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
-
/*
|
39 |
.gradio-container {
|
40 |
-
font-family:
|
41 |
-
background
|
|
|
42 |
}
|
43 |
|
44 |
/* Header styling */
|
45 |
.main-header {
|
46 |
text-align: center;
|
47 |
-
padding: 2rem
|
48 |
-
|
|
|
49 |
margin-bottom: 2rem;
|
50 |
}
|
51 |
|
52 |
.main-title {
|
53 |
-
font-size: 2.
|
54 |
-
font-weight:
|
55 |
-
color:
|
56 |
margin-bottom: 0.5rem;
|
57 |
-
letter-spacing: -0.02em;
|
58 |
}
|
59 |
|
60 |
.main-subtitle {
|
61 |
-
font-size: 1.
|
62 |
-
color:
|
63 |
font-weight: 400;
|
64 |
}
|
65 |
|
66 |
-
/*
|
67 |
-
.
|
68 |
-
background:
|
69 |
-
|
70 |
-
|
71 |
-
border:
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
|
75 |
/* Button styling */
|
76 |
.submit-btn {
|
77 |
-
background:
|
|
|
78 |
border: none !important;
|
79 |
-
border-radius:
|
80 |
-
padding:
|
81 |
font-weight: 600 !important;
|
82 |
-
|
83 |
-
color: white !important;
|
84 |
-
transition: background 0.2s ease, transform 0.2s ease !important;
|
85 |
}
|
86 |
|
87 |
.submit-btn:hover {
|
88 |
-
background: #
|
89 |
-
transform: translateY(-2px) !important;
|
90 |
}
|
91 |
|
92 |
-
/*
|
93 |
-
.
|
94 |
-
background:
|
95 |
-
border
|
|
|
96 |
padding: 1.5rem;
|
97 |
-
margin-
|
98 |
-
border-left: 4px solid var(--card-border-color);
|
99 |
-
transition: box-shadow 0.3s ease;
|
100 |
}
|
101 |
|
102 |
-
.director-card
|
103 |
-
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
.rank-badge {
|
107 |
display: inline-block;
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
112 |
font-weight: 600;
|
113 |
margin-bottom: 0.5rem;
|
114 |
}
|
115 |
|
116 |
-
|
117 |
-
.rank-
|
118 |
-
.rank-
|
119 |
-
.rank-3 { background: #CD7F32; }
|
120 |
|
121 |
.director-name {
|
122 |
-
font-size: 1.
|
123 |
font-weight: 600;
|
124 |
-
color:
|
125 |
margin-bottom: 1rem;
|
126 |
}
|
127 |
|
128 |
.prompt-text {
|
129 |
-
|
130 |
-
|
131 |
-
color: var(--text-color-secondary);
|
132 |
-
background: var(--background-fill-secondary);
|
133 |
padding: 1rem;
|
134 |
-
border
|
135 |
-
border:
|
|
|
136 |
margin-bottom: 1rem;
|
137 |
}
|
138 |
|
139 |
-
/* Custom card for the additional director */
|
140 |
.additional-director {
|
141 |
-
background:
|
142 |
-
border
|
|
|
143 |
padding: 1.5rem;
|
144 |
-
margin-bottom:
|
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:
|
154 |
-
border
|
|
|
155 |
padding: 1.5rem;
|
156 |
-
margin-top:
|
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.
|
165 |
font-weight: 600;
|
166 |
-
color:
|
167 |
margin-bottom: 1rem;
|
168 |
}
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
color: var(--accent-blue);
|
175 |
}
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
background:
|
180 |
-
|
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
|
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: #
|
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:
|
272 |
-
<div style='font-size: 1.3rem; font-weight: 600; color:
|
273 |
🎬 Director Bake-Off in Progress...
|
274 |
</div>
|
275 |
-
<div style='font-size: 1rem; color:
|
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:
|
282 |
-
<div style='font-size: 0.9rem; color:
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
330 |
-
<h3 style="margin-top: 0; color:
|
331 |
-
<ol style="color:
|
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:
|
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 |
)
|
|