pyannote / pyannote-database

Reproducible experimental protocols for multimedia (audio, video, text) database
MIT License
79 stars 26 forks source link

Training the overlap detection : AttributeError: 'PosixPath' object has no attribute 'format' #71

Closed xinyi1214 closed 2 years ago

xinyi1214 commented 3 years ago
from pyannote.audio.tasks import OverlappedSpeechDetection
ovl = OverlappedSpeechDetection(protocol, duration=2., batch_size=32, num_workers=4)
model = SimpleSegmentationModel(task=ovl)
trainer = pl.Trainer(max_epochs=1)
_ = trainer.fit(model)
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-23-7e3bd77348a4> in <module>
      3 model = SimpleSegmentationModel(task=ovl)
      4 trainer = pl.Trainer(max_epochs=1)
----> 5 _ = trainer.fit(model)

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py in fit(self, model, train_dataloader, val_dataloaders, datamodule)
    456         # SET UP TRAINING
    457         # ----------------------------
--> 458         self.call_setup_hook(model)
    459         self.call_hook("on_before_accelerator_backend_setup", model)
    460         self.accelerator.setup(self, model)  # note: this sets up self.lightning_module

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py in call_setup_hook(self, model)
   1062             called = self.datamodule.has_setup_test if self.testing else self.datamodule.has_setup_fit
   1063             if not called:
-> 1064                 self.datamodule.setup(stage_name)
   1065         self.setup(model, stage_name)
   1066         model.setup(stage_name)

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pytorch_lightning/core/datamodule.py in wrapped_fn(*args, **kwargs)
     90             obj._has_prepared_data = True
     91 
---> 92         return fn(*args, **kwargs)
     93 
     94     return wrapped_fn

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/tasks/segmentation/mixins.py in setup(self, stage)
     51             self._train_metadata = dict()
     52 
---> 53             for f in self.protocol.train():
     54 
     55                 file = dict()

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/database/protocol/protocol.py in subset_helper(self, subset)
    361 
    362         for file in files:
--> 363             yield self.preprocess(file)
    364 
    365     def train(self) -> Iterator[ProtocolFile]:

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/database/protocol/protocol.py in preprocess(self, current_file)
    327 
    328     def preprocess(self, current_file: Union[Dict, ProtocolFile]) -> ProtocolFile:
--> 329         return ProtocolFile(current_file, lazy=self.preprocessors)
    330 
    331     def __str__(self):

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/database/protocol/protocol.py in __init__(self, precomputed, lazy)
     85             # 'precomputed' one (which is probably not the most efficient solution).
     86             for key in set(precomputed.lazy) & set(lazy):
---> 87                 self._store[key] = precomputed[key]
     88 
     89             # we use the union of 'precomputed' lazy keys and provided 'lazy' keys as lazy keys

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/database/protocol/protocol.py in __getitem__(self, key)
    120 
    121                 # apply preprocessor once and remove it
--> 122                 value = self.lazy[key](self)
    123                 del self.lazy[key]
    124 

~/miniconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/database/loader.py in __call__(self, file)
    126         if uri not in self.loaded_:
    127             sub_file = {key: file[key] for key in self.placeholders_}
--> 128             loaded = load_rttm(self.path.format(**sub_file))
    129             if uri not in loaded:
    130                 loaded[uri] = Annotation(uri=uri)

AttributeError: 'PosixPath' object has no attribute 'format'
hbredin commented 3 years ago

This seems related to pyannote.database.

Could you please share:

hbredin commented 2 years ago

Fixed by #78