rooroo79 commited on
Commit
e2f8bfe
·
verified ·
1 Parent(s): f6137ac

Export ModelMixin so encoder from_pretrained can resolve

Browse files
Files changed (1) hide show
  1. spectrogram_diffusion/__init__.py +11 -5
spectrogram_diffusion/__init__.py CHANGED
@@ -1,13 +1,19 @@
1
  """Shim for this checkpoint's model_index.json.
2
 
3
  The Google weights name the note/context encoders as library
4
- `spectrogram_diffusion` (the original Magenta package). Current Diffusers
5
- keeps those classes under `diffusers.pipelines.deprecated`. This module
6
- makes `import spectrogram_diffusion` work inside the Inference Endpoint
7
- snapshot so `from_pretrained()` can load the encoders.
 
 
 
 
8
  """
9
  from __future__ import annotations
10
 
 
 
11
  try:
12
  from diffusers.pipelines.deprecated.spectrogram_diffusion.continuous_encoder import (
13
  SpectrogramContEncoder,
@@ -23,4 +29,4 @@ except ImportError: # older Diffusers still used the non-deprecated path
23
  SpectrogramNotesEncoder,
24
  )
25
 
26
- __all__ = ["SpectrogramContEncoder", "SpectrogramNotesEncoder"]
 
1
  """Shim for this checkpoint's model_index.json.
2
 
3
  The Google weights name the note/context encoders as library
4
+ `spectrogram_diffusion`. Diffusers' from_pretrained() does:
5
+
6
+ library = importlib.import_module("spectrogram_diffusion")
7
+ class_obj = getattr(library, "SpectrogramContEncoder")
8
+ class_candidates = {name: getattr(library, name, None) for name in LOADABLE_CLASSES}
9
+
10
+ so this module must export both the encoder classes *and* ModelMixin
11
+ (otherwise loading raises: no from_pretrained on the component).
12
  """
13
  from __future__ import annotations
14
 
15
+ from diffusers import ModelMixin
16
+
17
  try:
18
  from diffusers.pipelines.deprecated.spectrogram_diffusion.continuous_encoder import (
19
  SpectrogramContEncoder,
 
29
  SpectrogramNotesEncoder,
30
  )
31
 
32
+ __all__ = ["ModelMixin", "SpectrogramContEncoder", "SpectrogramNotesEncoder"]