MCPcopy Create free account
hub / github.com/AlayaLab/Hive / load_flowsep

Function load_flowsep

app.py:128–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126
127
128def load_flowsep():
129 global _flowsep_model, _flowsep_preprocessor
130 device = get_runtime_device()
131 if _flowsep_model is not None:
132 _flowsep_model = _flowsep_model.to(device).eval()
133 return _flowsep_model, _flowsep_preprocessor
134
135 seed_everything(0)
136 from latent_diffusion.util import instantiate_from_config
137
138 config_file = hf_hub_download(repo_id="ShandaAI/FlowSep-hive", filename="config.yaml")
139 model_file = hf_hub_download(repo_id="ShandaAI/FlowSep-hive", filename="flowsep_hive.ckpt")
140
141 configs = yaml.load(open(config_file, 'r'), Loader=yaml.FullLoader)
142 configs["model"]["params"]["first_stage_config"]["params"]["reload_from_ckpt"] = None
143
144 preprocessor = FlowSepPreprocessor(configs)
145
146 model = instantiate_from_config(configs["model"]).to(device)
147 try:
148 ckpt = torch.load(model_file, map_location=device, weights_only=False)["state_dict"]
149 except TypeError:
150 ckpt = torch.load(model_file, map_location=device)["state_dict"]
151 model.load_state_dict(ckpt, strict=True)
152 model.eval()
153
154 _flowsep_model = model
155 _flowsep_preprocessor = preprocessor
156 return model, preprocessor
157
158
159AUDIOSEP_SR = 32000

Callers 1

separate_flowsepFunction · 0.85

Calls 5

instantiate_from_configFunction · 0.90
get_runtime_deviceFunction · 0.85
FlowSepPreprocessorClass · 0.70
toMethod · 0.45
load_state_dictMethod · 0.45

Tested by

no test coverage detected