Update app.py
Browse files5 unmodified lines678910113 unmodified lines15161718192021222324252616 unmodified lines434445464748495 unmodified linesfrom omegaconf import OmegaConffrom nemo.collections.asr.models import ASRModelMODEL_NAME = "trysem/stt_ml_fastconformer_ctc_med_punct"print("1. Downloading unzipped model files from Hugging Face...")3 unmodified linesconfig_path = os.path.join(model_dir, "model_config.yaml")config = OmegaConf.load(config_path)# Allow modifications to the config object and remove PyTorch 2.0 SDPA keysOmegaConf.set_struct(config, False)if 'encoder' in config:config.encoder.pop('use_pytorch_sdpa', None)config.encoder.pop('use_pytorch_sdpa_backends', None)print("3. Packaging files into a standard .nemo archive...")patched_dir = "patched_nemo_env"os.makedirs(patched_dir, exist_ok=True)16 unmodified linestar.add(os.path.join(patched_dir, item), arcname=item)print("4. Restoring model from patched .nemo file (this may take a moment)...")# NeMo will be happy because it is receiving a proper file archive!model = ASRModel.restore_from(restore_path=nemo_filepath)model.eval()print("Model loaded successfully!")5 unmodified lines67891011123 unmodified lines161718192021222324252627282930313233343516 unmodified lines5253545556575 unmodified linesfrom omegaconf import OmegaConffrom nemo.collections.asr.models import ASRModel# Use the correct repository nameMODEL_NAME = "trysem/stt_ml_fastconformer_ctc_med_punct"print("1. Downloading unzipped model files from Hugging Face...")3 unmodified linesconfig_path = os.path.join(model_dir, "model_config.yaml")config = OmegaConf.load(config_path)# Allow modifications to the config objectOmegaConf.set_struct(config, False)# Patch 1: Remove PyTorch 2.0 SDPA keys for NeMo 1.23 compatibilityif 'encoder' in config:config.encoder.pop('use_pytorch_sdpa', None)config.encoder.pop('use_pytorch_sdpa_backends', None)# Patch 2: Downgrade 'greedy_batch' strategy to 'greedy'if 'decoding' in config:if config.decoding.get('strategy') == 'greedy_batch':print(" -> Downgrading decoding strategy from 'greedy_batch' to 'greedy'")config.decoding.strategy = 'greedy'print("3. Packaging files into a standard .nemo archive...")patched_dir = "patched_nemo_env"os.makedirs(patched_dir, exist_ok=True)16 unmodified linestar.add(os.path.join(patched_dir, item), arcname=item)print("4. Restoring model from patched .nemo file (this may take a moment)...")model = ASRModel.restore_from(restore_path=nemo_filepath)model.eval()print("Model loaded successfully!")
app.py+10-2