Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,17 @@ from gradio_toggle import Toggle
|
|
3 |
import torch
|
4 |
from huggingface_hub import snapshot_download
|
5 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
from xora.models.autoencoders.causal_video_autoencoder import CausalVideoAutoencoder
|
8 |
from xora.models.transformers.transformer3d import Transformer3DModel
|
@@ -55,8 +66,14 @@ hf_token = os.getenv("HF_TOKEN")
|
|
55 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
56 |
client = OpenAI(api_key=openai_api_key)
|
57 |
|
58 |
-
# Initialize translation pipeline
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
# Korean text detection function
|
62 |
def contains_korean(text):
|
@@ -196,14 +213,14 @@ pipeline = XoraVideoPipeline(
|
|
196 |
).to(device)
|
197 |
|
198 |
|
199 |
-
#
|
200 |
-
txt2vid_current_height = gr.State(value=320)
|
201 |
-
txt2vid_current_width = gr.State(value=512)
|
202 |
-
txt2vid_current_num_frames = gr.State(value=257)
|
203 |
|
204 |
-
img2vid_current_height = gr.State(value=320)
|
205 |
-
img2vid_current_width = gr.State(value=512)
|
206 |
-
img2vid_current_num_frames = gr.State(value=257)
|
207 |
|
208 |
# Preset options for resolution and frame configuration
|
209 |
# Convert frames to seconds assuming 25 FPS
|
@@ -521,10 +538,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
521 |
|
522 |
txt2vid_preset = gr.Dropdown(
|
523 |
choices=[p["label"] for p in preset_options],
|
524 |
-
value="512x320, 10.3μ΄",
|
525 |
label="Step 2: ν΄μλ ν리μ
μ ν",
|
526 |
)
|
527 |
|
|
|
528 |
txt2vid_frame_rate = gr.Slider(
|
529 |
label="Step 3: νλ μ λ μ΄νΈ",
|
530 |
minimum=21,
|
@@ -579,9 +597,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
579 |
|
580 |
img2vid_preset = gr.Dropdown(
|
581 |
choices=[p["label"] for p in preset_options],
|
582 |
-
value="512x320, 10.3μ΄",
|
583 |
label="Step 3: ν΄μλ ν리μ
μ ν",
|
584 |
-
)
|
|
|
|
|
585 |
|
586 |
img2vid_frame_rate = gr.Slider(
|
587 |
label="Step 4: νλ μ λ μ΄νΈ",
|
|
|
3 |
import torch
|
4 |
from huggingface_hub import snapshot_download
|
5 |
from transformers import pipeline
|
6 |
+
import warnings
|
7 |
+
warnings.filterwarnings('ignore', category=FutureWarning)
|
8 |
+
warnings.filterwarnings('ignore', category=UserWarning)
|
9 |
+
|
10 |
+
# sacremoses μ€μΉ νμΈ
|
11 |
+
try:
|
12 |
+
import sacremoses
|
13 |
+
except ImportError:
|
14 |
+
print("Installing sacremoses...")
|
15 |
+
import subprocess
|
16 |
+
subprocess.check_call(["pip", "install", "sacremoses"])
|
17 |
|
18 |
from xora.models.autoencoders.causal_video_autoencoder import CausalVideoAutoencoder
|
19 |
from xora.models.transformers.transformer3d import Transformer3DModel
|
|
|
66 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
67 |
client = OpenAI(api_key=openai_api_key)
|
68 |
|
69 |
+
# Initialize translation pipeline with device and clean_up settings
|
70 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
71 |
+
translator = pipeline(
|
72 |
+
"translation",
|
73 |
+
model="Helsinki-NLP/opus-mt-ko-en",
|
74 |
+
device=device,
|
75 |
+
clean_up_tokenization_spaces=True
|
76 |
+
)
|
77 |
|
78 |
# Korean text detection function
|
79 |
def contains_korean(text):
|
|
|
213 |
).to(device)
|
214 |
|
215 |
|
216 |
+
# νμ¬ μ νλ κ°λ€μ μ μ₯ν μν λ³μλ€
|
217 |
+
txt2vid_current_height = gr.State(value=320) # μμ λ¨
|
218 |
+
txt2vid_current_width = gr.State(value=512) # μμ λ¨
|
219 |
+
txt2vid_current_num_frames = gr.State(value=257) # 10.3μ΄
|
220 |
|
221 |
+
img2vid_current_height = gr.State(value=320) # μμ λ¨
|
222 |
+
img2vid_current_width = gr.State(value=512) # μμ λ¨
|
223 |
+
img2vid_current_num_frames = gr.State(value=257) # 10.3μ΄
|
224 |
|
225 |
# Preset options for resolution and frame configuration
|
226 |
# Convert frames to seconds assuming 25 FPS
|
|
|
538 |
|
539 |
txt2vid_preset = gr.Dropdown(
|
540 |
choices=[p["label"] for p in preset_options],
|
541 |
+
value="[16:9] 512x320, 10.3μ΄", # μ νν λΌλ²¨λ‘ μμ
|
542 |
label="Step 2: ν΄μλ ν리μ
μ ν",
|
543 |
)
|
544 |
|
545 |
+
|
546 |
txt2vid_frame_rate = gr.Slider(
|
547 |
label="Step 3: νλ μ λ μ΄νΈ",
|
548 |
minimum=21,
|
|
|
597 |
|
598 |
img2vid_preset = gr.Dropdown(
|
599 |
choices=[p["label"] for p in preset_options],
|
600 |
+
value="[16:9] 512x320, 10.3μ΄", # μ νν λΌλ²¨λ‘ μμ
|
601 |
label="Step 3: ν΄μλ ν리μ
μ ν",
|
602 |
+
)
|
603 |
+
|
604 |
+
|
605 |
|
606 |
img2vid_frame_rate = gr.Slider(
|
607 |
label="Step 4: νλ μ λ μ΄νΈ",
|