Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -60,56 +60,7 @@ setup_eval_logging()
|
|
60 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en", device="cpu")
|
61 |
PIXABAY_API_KEY = "33492762-a28a596ec4f286f84cd328b17"
|
62 |
|
63 |
-
# CSS ์คํ์ผ ์ ์
|
64 |
-
custom_css = """
|
65 |
-
.gradio-container {
|
66 |
-
background: linear-gradient(45deg, #1a1a1a, #2a2a2a);
|
67 |
-
border-radius: 15px;
|
68 |
-
box-shadow: 0 8px 32px rgba(0,0,0,0.3);
|
69 |
-
}
|
70 |
|
71 |
-
.input-container, .output-container {
|
72 |
-
background: rgba(255,255,255,0.1);
|
73 |
-
backdrop-filter: blur(10px);
|
74 |
-
border-radius: 10px;
|
75 |
-
padding: 20px;
|
76 |
-
transform-style: preserve-3d;
|
77 |
-
transition: transform 0.3s ease;
|
78 |
-
}
|
79 |
-
|
80 |
-
.input-container:hover {
|
81 |
-
transform: translateZ(20px);
|
82 |
-
}
|
83 |
-
|
84 |
-
.gallery-item {
|
85 |
-
transition: transform 0.3s ease;
|
86 |
-
border-radius: 8px;
|
87 |
-
overflow: hidden;
|
88 |
-
}
|
89 |
-
|
90 |
-
.gallery-item:hover {
|
91 |
-
transform: scale(1.05);
|
92 |
-
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
|
93 |
-
}
|
94 |
-
|
95 |
-
.tabs {
|
96 |
-
background: rgba(255,255,255,0.05);
|
97 |
-
border-radius: 10px;
|
98 |
-
padding: 10px;
|
99 |
-
}
|
100 |
-
|
101 |
-
button {
|
102 |
-
background: linear-gradient(45deg, #4a90e2, #357abd);
|
103 |
-
border: none;
|
104 |
-
border-radius: 5px;
|
105 |
-
transition: all 0.3s ease;
|
106 |
-
}
|
107 |
-
|
108 |
-
button:hover {
|
109 |
-
transform: translateY(-2px);
|
110 |
-
box-shadow: 0 4px 15px rgba(74,144,226,0.3);
|
111 |
-
}
|
112 |
-
"""
|
113 |
|
114 |
def cleanup_temp_files():
|
115 |
temp_dir = tempfile.gettempdir()
|
@@ -266,11 +217,91 @@ def text_to_audio(prompt: str, negative_prompt: str, seed: int, num_steps: int,
|
|
266 |
torchaudio.save(audio_save_path, audio, seq_cfg.sampling_rate)
|
267 |
return audio_save_path
|
268 |
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
video_search_tab = gr.Interface(
|
271 |
fn=search_videos,
|
272 |
-
inputs=gr.Textbox(label="
|
273 |
-
outputs=gr.Gallery(label="
|
274 |
css=custom_css,
|
275 |
api_name=False
|
276 |
)
|
@@ -278,36 +309,37 @@ video_search_tab = gr.Interface(
|
|
278 |
video_to_audio_tab = gr.Interface(
|
279 |
fn=video_to_audio,
|
280 |
inputs=[
|
281 |
-
gr.Video(label="
|
282 |
-
gr.Textbox(label="
|
283 |
-
gr.Textbox(label="
|
284 |
-
gr.Number(label="
|
285 |
-
gr.Number(label="
|
286 |
-
gr.Number(label="
|
287 |
-
gr.Number(label="
|
288 |
],
|
289 |
-
outputs="
|
290 |
css=custom_css
|
291 |
)
|
292 |
|
293 |
text_to_audio_tab = gr.Interface(
|
294 |
fn=text_to_audio,
|
295 |
inputs=[
|
296 |
-
gr.Textbox(label="
|
297 |
-
gr.Textbox(label="
|
298 |
-
gr.Number(label="
|
299 |
-
gr.Number(label="
|
300 |
-
gr.Number(label="
|
301 |
-
gr.Number(label="
|
302 |
],
|
303 |
-
outputs="
|
304 |
css=custom_css
|
305 |
)
|
306 |
|
307 |
-
# ๋ฉ์ธ ์คํ
|
308 |
if __name__ == "__main__":
|
309 |
gr.TabbedInterface(
|
310 |
[video_search_tab, video_to_audio_tab, text_to_audio_tab],
|
311 |
-
["
|
312 |
css=custom_css
|
313 |
-
).launch(allowed_paths=[output_dir])
|
|
|
|
60 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en", device="cpu")
|
61 |
PIXABAY_API_KEY = "33492762-a28a596ec4f286f84cd328b17"
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
def cleanup_temp_files():
|
66 |
temp_dir = tempfile.gettempdir()
|
|
|
217 |
torchaudio.save(audio_save_path, audio, seq_cfg.sampling_rate)
|
218 |
return audio_save_path
|
219 |
|
220 |
+
|
221 |
+
|
222 |
+
# CSS ์คํ์ผ ์์
|
223 |
+
custom_css = """
|
224 |
+
.gradio-container {
|
225 |
+
background: linear-gradient(45deg, #1a1a1a, #2a2a2a);
|
226 |
+
border-radius: 15px;
|
227 |
+
box-shadow: 0 8px 32px rgba(0,0,0,0.3);
|
228 |
+
color: #e0e0e0;
|
229 |
+
}
|
230 |
+
|
231 |
+
.input-container, .output-container {
|
232 |
+
background: rgba(40, 40, 40, 0.95);
|
233 |
+
backdrop-filter: blur(10px);
|
234 |
+
border-radius: 10px;
|
235 |
+
padding: 20px;
|
236 |
+
transform-style: preserve-3d;
|
237 |
+
transition: transform 0.3s ease;
|
238 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
239 |
+
}
|
240 |
+
|
241 |
+
.input-container:hover {
|
242 |
+
transform: translateZ(20px);
|
243 |
+
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
|
244 |
+
}
|
245 |
+
|
246 |
+
.gallery-item {
|
247 |
+
transition: transform 0.3s ease;
|
248 |
+
border-radius: 8px;
|
249 |
+
overflow: hidden;
|
250 |
+
background: #2a2a2a;
|
251 |
+
}
|
252 |
+
|
253 |
+
.gallery-item:hover {
|
254 |
+
transform: scale(1.05);
|
255 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.4);
|
256 |
+
}
|
257 |
+
|
258 |
+
.tabs {
|
259 |
+
background: rgba(30, 30, 30, 0.95);
|
260 |
+
border-radius: 10px;
|
261 |
+
padding: 10px;
|
262 |
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
263 |
+
}
|
264 |
+
|
265 |
+
button {
|
266 |
+
background: linear-gradient(45deg, #2196F3, #1976D2);
|
267 |
+
border: none;
|
268 |
+
border-radius: 5px;
|
269 |
+
transition: all 0.3s ease;
|
270 |
+
color: white;
|
271 |
+
}
|
272 |
+
|
273 |
+
button:hover {
|
274 |
+
transform: translateY(-2px);
|
275 |
+
box-shadow: 0 4px 15px rgba(33,150,243,0.3);
|
276 |
+
}
|
277 |
+
|
278 |
+
/* ํ
์คํธ ์
๋ ฅ ํ๋ ์คํ์ผ */
|
279 |
+
textarea, input[type="text"], input[type="number"] {
|
280 |
+
background: rgba(30, 30, 30, 0.95) !important;
|
281 |
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
282 |
+
color: #e0e0e0 !important;
|
283 |
+
border-radius: 5px !important;
|
284 |
+
}
|
285 |
+
|
286 |
+
/* ๋ ์ด๋ธ ์คํ์ผ */
|
287 |
+
label {
|
288 |
+
color: #e0e0e0 !important;
|
289 |
+
}
|
290 |
+
|
291 |
+
/* ๊ฐค๋ฌ๋ฆฌ ๊ทธ๋ฆฌ๋ ์คํ์ผ */
|
292 |
+
.gallery {
|
293 |
+
background: rgba(30, 30, 30, 0.95);
|
294 |
+
padding: 15px;
|
295 |
+
border-radius: 10px;
|
296 |
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
297 |
+
}
|
298 |
+
"""
|
299 |
+
|
300 |
+
# ์ธํฐํ์ด์ค ์ ์ ์์ (์๋ฌธ์ผ๋ก ๋ณ๊ฒฝ)
|
301 |
video_search_tab = gr.Interface(
|
302 |
fn=search_videos,
|
303 |
+
inputs=gr.Textbox(label="Search Query(ํ๊ธ์ง์)"),
|
304 |
+
outputs=gr.Gallery(label="Search Results", columns=4, rows=20),
|
305 |
css=custom_css,
|
306 |
api_name=False
|
307 |
)
|
|
|
309 |
video_to_audio_tab = gr.Interface(
|
310 |
fn=video_to_audio,
|
311 |
inputs=[
|
312 |
+
gr.Video(label="Input Video"),
|
313 |
+
gr.Textbox(label="Prompt(ํ๊ธ์ง์)"),
|
314 |
+
gr.Textbox(label="Negative Prompt", value="music"),
|
315 |
+
gr.Number(label="Seed", value=0),
|
316 |
+
gr.Number(label="Steps", value=25),
|
317 |
+
gr.Number(label="Guidance Scale", value=4.5),
|
318 |
+
gr.Number(label="Duration (sec)", value=8),
|
319 |
],
|
320 |
+
outputs=gr.Video(label="Generated Result"),
|
321 |
css=custom_css
|
322 |
)
|
323 |
|
324 |
text_to_audio_tab = gr.Interface(
|
325 |
fn=text_to_audio,
|
326 |
inputs=[
|
327 |
+
gr.Textbox(label="Prompt(ํ๊ธ์ง์)"),
|
328 |
+
gr.Textbox(label="Negative Prompt"),
|
329 |
+
gr.Number(label="Seed", value=0),
|
330 |
+
gr.Number(label="Steps", value=25),
|
331 |
+
gr.Number(label="Guidance Scale", value=4.5),
|
332 |
+
gr.Number(label="Duration (sec)", value=8),
|
333 |
],
|
334 |
+
outputs=gr.Audio(label="Generated Audio"),
|
335 |
css=custom_css
|
336 |
)
|
337 |
|
338 |
+
# ๋ฉ์ธ ์คํ ๋ถ๋ถ ์์
|
339 |
if __name__ == "__main__":
|
340 |
gr.TabbedInterface(
|
341 |
[video_search_tab, video_to_audio_tab, text_to_audio_tab],
|
342 |
+
["Video Search", "Video-to-Audio", "Text-to-Audio"],
|
343 |
css=custom_css
|
344 |
+
).launch(allowed_paths=[output_dir])
|
345 |
+
|