aiqcamp commited on
Commit
6251d81
·
verified ·
1 Parent(s): f6c9d00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -3,52 +3,54 @@ import logging
3
  logging.basicConfig(level=logging.INFO)
4
  logger = logging.getLogger(__name__)
5
 
6
- # 2. 나머지 imports
 
 
 
7
  import os
8
  import time
9
  from datetime import datetime
10
  import gradio as gr
11
-
12
- # GPU 초기화 설정
13
  import torch
14
- if torch.cuda.is_available():
15
- torch.cuda.init()
16
- device = torch.device('cuda')
17
- logger.info(f"Using GPU: {torch.cuda.get_device_name(0)}")
18
- else:
19
- device = torch.device('cpu')
20
- logger.warning("GPU not available, using CPU")
21
-
22
  import requests
23
  from pathlib import Path
24
  import cv2
25
  from PIL import Image
26
  import json
27
- import spaces
28
  import torchaudio
29
  import tempfile
30
 
 
 
 
 
 
 
 
 
31
  try:
32
  import mmaudio
33
  except ImportError:
34
  os.system("pip install -e .")
35
  import mmaudio
36
 
 
37
  from mmaudio.eval_utils import (ModelConfig, all_model_cfg, generate, load_video, make_video,
38
  setup_eval_logging)
39
  from mmaudio.model.flow_matching import FlowMatching
40
  from mmaudio.model.networks import MMAudio, get_my_mmaudio
41
  from mmaudio.model.sequence_config import SequenceConfig
42
  from mmaudio.model.utils.features_utils import FeaturesUtils
43
- # 상단에 번역 모델 import 추가
 
44
  from transformers import pipeline
45
  translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
46
- # 3. API 설정
 
47
  CATBOX_USER_HASH = "30f52c895fd9d9cb387eee489"
48
  REPLICATE_API_TOKEN = os.getenv("API_KEY")
49
 
50
-
51
- # 4. 오디오 모델 설정
52
  dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
53
 
54
  # 5. get_model 함수 정의
 
3
  logging.basicConfig(level=logging.INFO)
4
  logger = logging.getLogger(__name__)
5
 
6
+ # 2. spaces를 먼저 import
7
+ import spaces
8
+
9
+ # 3. 나머지 imports
10
  import os
11
  import time
12
  from datetime import datetime
13
  import gradio as gr
 
 
14
  import torch
 
 
 
 
 
 
 
 
15
  import requests
16
  from pathlib import Path
17
  import cv2
18
  from PIL import Image
19
  import json
 
20
  import torchaudio
21
  import tempfile
22
 
23
+ # 4. GPU 초기화 설정
24
+ if torch.cuda.is_available():
25
+ device = torch.device('cuda')
26
+ logger.info(f"Using GPU: {torch.cuda.get_device_name(0)}")
27
+ else:
28
+ device = torch.device('cpu')
29
+ logger.warning("GPU not available, using CPU")
30
+
31
  try:
32
  import mmaudio
33
  except ImportError:
34
  os.system("pip install -e .")
35
  import mmaudio
36
 
37
+ # 나머지 imports
38
  from mmaudio.eval_utils import (ModelConfig, all_model_cfg, generate, load_video, make_video,
39
  setup_eval_logging)
40
  from mmaudio.model.flow_matching import FlowMatching
41
  from mmaudio.model.networks import MMAudio, get_my_mmaudio
42
  from mmaudio.model.sequence_config import SequenceConfig
43
  from mmaudio.model.utils.features_utils import FeaturesUtils
44
+
45
+ # 번역 모델 import
46
  from transformers import pipeline
47
  translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
48
+
49
+ # API 설정
50
  CATBOX_USER_HASH = "30f52c895fd9d9cb387eee489"
51
  REPLICATE_API_TOKEN = os.getenv("API_KEY")
52
 
53
+ # 오디오 모델 설정
 
54
  dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
55
 
56
  # 5. get_model 함수 정의