Files
Hervé BREDIN 0b9be93ee1 chore: replace load_from_checkpoint by Model.from_pretrained (#588)
* chore: import Model from package root
* chore: import Inference from package root
2021-01-20 16:39:08 +01:00

1.9 KiB

In [ ]:
from pyannote.database import get_protocol, FileFinder
protocol = get_protocol('Debug.SpeakerDiarization.Debug', 
                        preprocessors={"audio": FileFinder()})

## Train a model

In [ ]:
from pyannote.audio.tasks import VoiceActivityDetection
from pyannote.audio.models.segmentation.debug import SimpleSegmentationModel
import pytorch_lightning as pl

vad = VoiceActivityDetection(protocol, duration=2., batch_size=32, num_workers=4)
model = SimpleSegmentationModel(task=vad)
trainer = pl.Trainer(max_epochs=1, default_root_dir='sharing/')
_ = trainer.fit(model)

## Load a model without knowing its class

In [ ]:
from pyannote.audio import Model
model = Model.from_pretrained('sharing/lightning_logs/version_0/checkpoints/epoch=0-step=3.ckpt')
assert isinstance(model, SimpleSegmentationModel)

# checkpoint should work with a URL as well (it relies on pl_load)