openfree commited on
Commit
349da64
β€’
1 Parent(s): 92febc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -12
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
- translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
 
 
 
 
 
 
60
 
61
  # Korean text detection function
62
  def contains_korean(text):
@@ -196,14 +213,14 @@ pipeline = XoraVideoPipeline(
196
  ).to(device)
197
 
198
 
199
- # txt2vid와 img2vid의 ν˜„μž¬ μƒνƒœ 값듀을 μˆ˜μ •
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) # 10.3초
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) # 10.3초
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: ν”„λ ˆμž„ 레이트",