Spaces:
Build error
Build error
calculating commited on
Commit ·
4f90f1b
1
Parent(s): 896572e
committing...
Browse filesFiles changed (3)
- app.py+1-1
- sample.wavAdded
- utils/dist.py+11-12
13 unmodified lines1415161718192013 unmodified lines# Global variables for model and tokenizerglobal_generator = Noneglobal_tokenizer = Nonedefault_audio_path = "testingtesting.wav" # Your default audio filedef init_model(use_pure_audio_ablation: bool = False) -> Tuple[nn.Module, object]:"""Initialize the model and tokenizer"""13 unmodified lines1415161718192013 unmodified lines# Global variables for model and tokenizerglobal_generator = Noneglobal_tokenizer = Nonedefault_audio_path = "sample.wav" # Changed from "testingtesting.wav"def init_model(use_pure_audio_ablation: bool = False) -> Tuple[nn.Module, object]:"""Initialize the model and tokenizer"""
7 unmodified lines891011121361 unmodified lines75767778798081828384858687888990912 unmodified lines9495969798997 unmodified linesimport hashlibfrom io import BytesIOdef rank0():rank = os.environ.get('RANK')61 unmodified linesreturn rank, local_rank, world_sizedef load_ckpt(load_from_location, expected_hash=None):if local0():os.makedirs('ckpt', exist_ok=True)url = f"https://ckpt.si.inc/hertz-dev/{load_from_location}.pt"save_path = f"ckpt/{load_from_location}.pt"if not os.path.exists(save_path):response = requests.get(url, stream=True)total_size = int(response.headers.get('content-length', 0))with open(save_path, 'wb') as f, tqdm(total=total_size, desc=f'Downloading {load_from_location}.pt', unit='GB', unit_scale=1/(1024*1024*1024)) as pbar:for chunk in response.iter_content(chunk_size=8192):f.write(chunk)pbar.update(len(chunk))if expected_hash is not None:with open(save_path, 'rb') as f:file_hash = hashlib.md5(f.read()).hexdigest()2 unmodified linesos.remove(save_path)return load_ckpt(load_from_location, expected_hash)if T.distributed.is_initialized():T.distributed.barrier() # so that ranks don't try to load checkpoint before it's finished downloadingloaded = T.load(f"ckpt/{load_from_location}.pt", weights_only=False, map_location='cpu')return loaded7 unmodified lines89101112131461 unmodified lines7677787980818283848586872 unmodified lines9091929394959697987 unmodified linesimport hashlibfrom io import BytesIOfrom huggingface_hub import hf_hub_downloaddef rank0():rank = os.environ.get('RANK')61 unmodified linesreturn rank, local_rank, world_sizedef load_ckpt(load_from_location, expected_hash=None):os.environ['HF_HUB_ENABLE_HF_TRANSFER'] = '1' #Disable this to speed up debugging errors with downloading from the hubif local0():repo_id = "si-pbc/hertz-dev"print0(f'Loading checkpoint from repo_id {repo_id} and filename {load_from_location}.pt. This may take a while...')save_path = hf_hub_download(repo_id=repo_id, filename=f"{load_from_location}.pt")print0(f'Downloaded checkpoint to {save_path}')if expected_hash is not None:with open(save_path, 'rb') as f:file_hash = hashlib.md5(f.read()).hexdigest()2 unmodified linesos.remove(save_path)return load_ckpt(load_from_location, expected_hash)if T.distributed.is_initialized():save_path = [save_path]T.distributed.broadcast_object_list(save_path, src=0)save_path = save_path[0]loaded = T.load(save_path, weights_only=False, map_location='cpu')print0(f'Loaded checkpoint from {save_path}')return loaded
app.py+1-1
sample.wavAdded
utils/dist.py+11-12