Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,41 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import uuid
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
+
def generate_video(prompt, style, duration):
|
| 7 |
+
# Δημιουργία μοναδικού ονόματος αρχείου
|
| 8 |
+
video_id = str(uuid.uuid4())[:8]
|
| 9 |
+
output_path = f"{video_id}.mp4"
|
| 10 |
|
| 11 |
+
# Ορισμός ανάλυσης και παραμέτρων
|
| 12 |
+
resolution = "1280*720" if style == "Cinematic" else "640*480"
|
| 13 |
+
seconds = int(duration)
|
| 14 |
+
|
| 15 |
+
# Δημιουργία εντολής για το Wan2.2
|
| 16 |
+
command = [
|
| 17 |
+
"python", "generate.py",
|
| 18 |
+
"--task", "t2v-A14B",
|
| 19 |
+
"--size", resolution,
|
| 20 |
+
"--ckpt_dir", "./Wan2.2-T2V-A14B",
|
| 21 |
+
"--prompt", prompt,
|
| 22 |
+
"--output", output_path,
|
| 23 |
+
"--duration", str(seconds)
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
try:
|
| 27 |
+
subprocess.run(command, check=True)
|
| 28 |
+
return output_path
|
| 29 |
+
except Exception as e:
|
| 30 |
+
return f"Σφάλμα: {e}"
|
| 31 |
+
|
| 32 |
+
# Gradio UI
|
| 33 |
+
gr.Interface(
|
| 34 |
+
fn=generate_video,
|
| 35 |
+
inputs=[
|
| 36 |
+
gr.Textbox(label="Περιγραφή βίντεο"),
|
| 37 |
+
gr.Radio(["Cinematic", "Simple"], label="Στυλ"),
|
| 38 |
+
gr.Slider(1, 10, value=5, label="Διάρκεια (δευτερόλεπτα)")
|
| 39 |
+
],
|
| 40 |
+
outputs=gr.Video(label="Το βίντεό σου")
|
| 41 |
+
).launch()
|