Skip to content

Commit

Permalink
Use cached instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jhj0517 committed Nov 15, 2024
1 parent b82078a commit 97a43e9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions backend/bgm_separation/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from ..util.config_loader import load_server_config


bgm_separation_router = APIRouter()


@functools.lru_cache
def init_bgm_separation_inferencer() -> 'MusicSeparator':
config = load_server_config()["bgm_separation"]
Expand All @@ -26,15 +29,11 @@ def init_bgm_separation_inferencer() -> 'MusicSeparator':
return inferencer


bgm_separation_router = APIRouter()
bgm_separation_inferencer = init_bgm_separation_inferencer()


async def run_bgm_separation(
audio: np.ndarray,
params: BGMSeparationParams
) -> Tuple[np.ndarray, np.ndarray]:
instrumental, vocal, filepaths = bgm_separation_inferencer.separate(
instrumental, vocal, filepaths = init_bgm_separation_inferencer().separate(
audio=audio,
model_name=params.model_size,
device=params.device,
Expand Down

0 comments on commit 97a43e9

Please sign in to comment.