Spaces:
Runtime error
Runtime 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 lines5152535455565758596050 unmodified lines if 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 lines89909192929394959394959697989988 unmodified lines return 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())}" ) 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