AmosHason commited on
Commit
2730132
·
verified ·
1 Parent(s): 05f1747

Catch OSError while trying to load cached model

Browse files

Fixes this:

```
File "/mnt/d/Documents/Workspace/audioEditing/models.py", line 536, in __init__
self.model = StableAudioPipeline.from_pretrained(self.model_id, token=self.token, local_files_only=True

OSError: We couldn't connect to 'https://huggingface.co' to load this model, couldn't find it in the cached files and it looks like *** is not the path to a directory containing a model_index.json file.
```

Files changed (1) hide show
  1. models.py +1 -1
models.py CHANGED
@@ -535,7 +535,7 @@ class StableAudWrapper(PipelineWrapper):
535
  try:
536
  self.model = StableAudioPipeline.from_pretrained(self.model_id, token=self.token, local_files_only=True
537
  ).to(self.device)
538
- except FileNotFoundError:
539
  self.model = StableAudioPipeline.from_pretrained(self.model_id, token=self.token, local_files_only=False
540
  ).to(self.device)
541
  self.model.transformer.eval()
 
535
  try:
536
  self.model = StableAudioPipeline.from_pretrained(self.model_id, token=self.token, local_files_only=True
537
  ).to(self.device)
538
+ except (FileNotFoundError, OSError):
539
  self.model = StableAudioPipeline.from_pretrained(self.model_id, token=self.token, local_files_only=False
540
  ).to(self.device)
541
  self.model.transformer.eval()