Spaces:
Build error
Build error
Model can be loaded from local directory (#69)
Browse files* Model can be loaded from local directory
* applied flake8 linter
Files changed (2)
50 unmodified lines51525354555650 unmodified linesif os.path.isfile(file_or_url_or_id):return torch.load(file_or_url_or_id, map_location=device)elif file_or_url_or_id.startswith('https://'):return torch.hub.load_state_dict_from_url(file_or_url_or_id, map_location=device, check_hash=True)50 unmodified lines5152535455565758596050 unmodified linesif os.path.isfile(file_or_url_or_id):return torch.load(file_or_url_or_id, map_location=device)if os.path.isdir(file_or_url_or_id):file = f"{file_or_url_or_id}/{filename}"return torch.load(file, map_location=device)elif file_or_url_or_id.startswith('https://'):return torch.hub.load_state_dict_from_url(file_or_url_or_id, map_location=device, check_hash=True)
88 unmodified lines8990919293949596979888 unmodified linesreturn MusicGen(name, compression_model, lm)if name not in HF_MODEL_CHECKPOINTS_MAP:raise ValueError(f"{name} is not a valid checkpoint name. "f"Choose one of {', '.join(HF_MODEL_CHECKPOINTS_MAP.keys())}")cache_dir = os.environ.get('MUSICGEN_ROOT', None)compression_model = load_compression_model(name, device=device, cache_dir=cache_dir)88 unmodified lines899091929394959697989988 unmodified linesreturn MusicGen(name, compression_model, lm)if name not in HF_MODEL_CHECKPOINTS_MAP:if not os.path.isfile(name) and not os.path.isdir(name):raise ValueError(f"{name} is not a valid checkpoint name. "f"Choose one of {', '.join(HF_MODEL_CHECKPOINTS_MAP.keys())}")cache_dir = os.environ.get('MUSICGEN_ROOT', None)compression_model = load_compression_model(name, device=device, cache_dir=cache_dir)
audiocraft/models/loaders.py+4
audiocraft/models/musicgen.py+5-4