Files
pyannote-audio/notebook/sharing.ipynb
T
Hervé BREDINandHarry 95cb72b5c1 feat: add generic load_from_checkpoint and initial version checking (#12) + versioning fixes
* feat: add generic load_from_checkpoint and initial version checking

Addresses #8

* fix: remove FIXME as torch.hub takes care of caching downloads

* setup: switch to pytorch-lightning 1.0.0

* feat: check pytorch-lightning version

* feat: add version compatibility check

* test: add basic "sharing" notebook

* fix: remove references to local files

* fix: fix versioning until setuptools_scm really supports semver

* Revert "fix: fix versioning until setuptools_scm really supports semver"

This reverts commit a16ec7721aae4d1da42d86da6da908570d88b951.

* Using package after setup

* fix: make setuptools_scm version semver-compliant

* fix: remove setuptools_scm_git_semver hack

* fix: skip pyannote.audio version checking

* Copying torchaudio version

* Stripping whitespace from version

Co-authored-by: Harry <himion0@gmail.com>
2020-10-16 12:40:42 +01:00

2.0 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.voice_activity_detection.task import VoiceActivityDetection
from pyannote.audio.models.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, vad)

## Load a model without knowing its class

In [ ]:
from pyannote.audio.core.model import load_from_checkpoint
model = load_from_checkpoint('sharing/lightning_logs/version_0/checkpoints/epoch=0.ckpt')
assert isinstance(model, SimpleSegmentationModel)

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