Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'PyanNet' object has no attribute 'example_output' when loading speaker diarization pipeline #1620

Open
pweglik opened this issue Jan 16, 2024 · 7 comments

Comments

@pweglik
Copy link

pweglik commented Jan 16, 2024

Tested versions

pyannote.audio==3.1.1

System information

Ubuntu 20.04

Issue description

My code:

from pyannote.audio import Pipeline
from pyannote.audio.pipelines import SpeakerDiarization
from pyannote.core import Annotation
import torch

pipeline: SpeakerDiarization = Pipeline.from_pretrained(
  "pyannote/speaker-diarization-3.1",
  use_auth_token="TOKEN").to(torch.device("cuda"))

results in:


 "name": "AttributeError",
 "message": "'PyanNet' object has no attribute 'example_output'",
 "stack": "---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 6
   3 from pyannote.core import Annotation
   4 import torch
----> 6 pipeline: SpeakerDiarization = Pipeline.from_pretrained(
   7   \"pyannote/speaker-diarization-3.1\",
   8   use_auth_token=\"TOKEN\").to(torch.device(\"cuda\"))

File ~/przemek/miniconda3/envs/meeting_summarizer/lib/python3.11/site-packages/pyannote/audio/core/pipeline.py:137, in Pipeline.from_pretrained(cls, checkpoint_path, hparams_file, use_auth_token, cache_dir)
 135 params.setdefault(\"use_auth_token\", use_auth_token)
 136 print(config)
--> 137 pipeline = Klass(**params)
 139 # freeze  parameters
 140 if \"freeze\" in config:

File ~/przemek/miniconda3/envs/meeting_summarizer/lib/python3.11/site-packages/pyannote/audio/pipelines/speaker_diarization.py:152, in SpeakerDiarization.__init__(self, segmentation, segmentation_step, embedding, embedding_exclude_overlap, clustering, embedding_batch_size, segmentation_batch_size, der_variant, use_auth_token)
 144 self._segmentation = Inference(
 145     model,
 146     duration=segmentation_duration,
(...)
 149     batch_size=segmentation_batch_size,
 150 )
 151 print(model)
--> 152 self._frames: SlidingWindow = self._segmentation.model.example_output.frames
 154 if self._segmentation.model.specifications.powerset:
 155     self.segmentation = ParamDict(
 156         min_duration_off=Uniform(0.0, 1.0),
 157     )

File ~/przemek/miniconda3/envs/meeting_summarizer/lib/python3.11/site-packages/torch/nn/modules/module.py:1614, in Module.__getattr__(self, name)
1612     if name in modules:
1613         return modules[name]
-> 1614 raise AttributeError(\"'{}' object has no attribute '{}'\".format(
1615     type(self).__name__, name))

AttributeError: 'PyanNet' object has no attribute 'example_output'"

Minimal reproduction example (MRE)

@pweglik
Copy link
Author

pweglik commented Jan 16, 2024

I've dived down into the implementation and foudn out the problematic line was rearrange function in forward method of PyanNet. It crashed without leaving any trace. When I swapped :

rearrange(outputs, "batch feature frame -> batch frame feature")

to

torch.permute(outputs, (0, 2, 1))

model loaded correctly. Not sure what caused it, but might be something worth looking at. In einops repo I found similar issue: pytorch/pytorch#94598

@hbredin
Copy link
Member

hbredin commented Jan 18, 2024

Would you mind sharing a link to a Google Colab that one can just click and run to reproduce the issue?

@pweglik
Copy link
Author

pweglik commented Jan 23, 2024

Sorry, I don't have time now and I'm not sure if you're allowed to install your own versions of everything on google collab. But for anyone looking working setup for me is:

python 3.10.13
torch==2.0.0+cu117
pyannote.pipeline==3.0.1

The bug was caused by python 3.11 and it occurred in einops library, so the bug is on their side. This may be an incentive to use torch.permute instead of einops.rearrange (it would remove unnecessary dependency)

@hbredin
Copy link
Member

hbredin commented Jan 23, 2024

Adding cannot_reproduce label because, well, I cannot reproduce it.

@KickItLikeShika
Copy link

i'm getting the same error while trying to load the model

@palvinderbhatia
Copy link

I am getting the same issue.

@yoesak
Copy link

yoesak commented May 9, 2024

I also have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants