MCPcopy
hub / github.com/Zyphra/Zonos / load_model_if_needed

Function load_model_if_needed

gradio_interface.py:17–28  ·  view source on GitHub ↗
(model_choice: str)

Source from the content-addressed store, hash-verified

15
16
17def load_model_if_needed(model_choice: str):
18 global CURRENT_MODEL_TYPE, CURRENT_MODEL
19 if CURRENT_MODEL_TYPE != model_choice:
20 if CURRENT_MODEL is not None:
21 del CURRENT_MODEL
22 torch.cuda.empty_cache()
23 print(f"Loading {model_choice} model...")
24 CURRENT_MODEL = Zonos.from_pretrained(model_choice, device=device)
25 CURRENT_MODEL.requires_grad_(False).eval()
26 CURRENT_MODEL_TYPE = model_choice
27 print(f"{model_choice} model loaded successfully!")
28 return CURRENT_MODEL
29
30
31def update_ui(model_choice):

Callers 2

update_uiFunction · 0.85
generate_audioFunction · 0.85

Calls 1

from_pretrainedMethod · 0.80

Tested by

no test coverage detected