Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import time
|
| 3 |
from datetime import datetime
|
| 4 |
import gradio as gr
|
| 5 |
import torch
|
| 6 |
-
import logging
|
| 7 |
import requests
|
| 8 |
from pathlib import Path
|
| 9 |
import cv2
|
|
@@ -26,9 +31,15 @@ from mmaudio.model.networks import MMAudio, get_my_mmaudio
|
|
| 26 |
from mmaudio.model.sequence_config import SequenceConfig
|
| 27 |
from mmaudio.model.utils.features_utils import FeaturesUtils
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
#
|
| 32 |
def get_model() -> tuple[MMAudio, FeaturesUtils, SequenceConfig]:
|
| 33 |
seq_cfg = model.seq_cfg
|
| 34 |
|
|
@@ -46,10 +57,7 @@ def get_model() -> tuple[MMAudio, FeaturesUtils, SequenceConfig]:
|
|
| 46 |
|
| 47 |
return net, feature_utils, seq_cfg
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
device = 'cuda'
|
| 51 |
-
dtype = torch.bfloat16
|
| 52 |
-
|
| 53 |
model: ModelConfig = all_model_cfg['large_44k_v2']
|
| 54 |
model.download_if_needed()
|
| 55 |
output_dir = Path('./output/gradio')
|
|
@@ -58,15 +66,6 @@ setup_eval_logging()
|
|
| 58 |
net, feature_utils, seq_cfg = get_model()
|
| 59 |
|
| 60 |
|
| 61 |
-
# ๋ก๊น
์ค์
|
| 62 |
-
logging.basicConfig(level=logging.INFO)
|
| 63 |
-
logger = logging.getLogger(__name__)
|
| 64 |
-
|
| 65 |
-
# API ์ค์
|
| 66 |
-
CATBOX_USER_HASH = "30f52c895fd9d9cb387eee489"
|
| 67 |
-
REPLICATE_API_TOKEN = os.getenv("API_KEY")
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
@spaces.GPU(duration=120)
|
| 72 |
@torch.inference_mode()
|
|
|
|
| 1 |
+
# 1. ๋จผ์ ๋ก๊น
์ค์
|
| 2 |
+
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 |
import torch
|
|
|
|
| 12 |
import requests
|
| 13 |
from pathlib import Path
|
| 14 |
import cv2
|
|
|
|
| 31 |
from mmaudio.model.sequence_config import SequenceConfig
|
| 32 |
from mmaudio.model.utils.features_utils import FeaturesUtils
|
| 33 |
|
| 34 |
+
# 3. API ์ค์
|
| 35 |
+
CATBOX_USER_HASH = "30f52c895fd9d9cb387eee489"
|
| 36 |
+
REPLICATE_API_TOKEN = os.getenv("API_KEY")
|
| 37 |
|
| 38 |
+
# 4. ์ค๋์ค ๋ชจ๋ธ ์ค์
|
| 39 |
+
device = 'cuda'
|
| 40 |
+
dtype = torch.bfloat16
|
| 41 |
|
| 42 |
+
# 5. get_model ํจ์ ์ ์
|
| 43 |
def get_model() -> tuple[MMAudio, FeaturesUtils, SequenceConfig]:
|
| 44 |
seq_cfg = model.seq_cfg
|
| 45 |
|
|
|
|
| 57 |
|
| 58 |
return net, feature_utils, seq_cfg
|
| 59 |
|
| 60 |
+
# 6. ๋ชจ๋ธ ์ด๊ธฐํ
|
|
|
|
|
|
|
|
|
|
| 61 |
model: ModelConfig = all_model_cfg['large_44k_v2']
|
| 62 |
model.download_if_needed()
|
| 63 |
output_dir = Path('./output/gradio')
|
|
|
|
| 66 |
net, feature_utils, seq_cfg = get_model()
|
| 67 |
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
@spaces.GPU(duration=120)
|
| 71 |
@torch.inference_mode()
|