zea.models.taesd¶
Tiny Autoencoder (TAESD) model.
>>> from zea.models.taesd import TinyAutoencoder
>>> model = TinyAutoencoder.from_preset("taesdxl")
Important
This is a zea implementation of the model.
For the original code, see here.
See also
A tutorial notebook where this model is used: Autoencoder for ultrasound images.
Functions
|
Convert the original PyTorch TAESD weights to TensorFlow / Keras v3 models. |
Classes
|
Tiny Autoencoder model. |
|
Base class for TAESD encoder and decoder. |
|
Decoder from TAESD model. |
|
Encoder from TAESD model. |
- class zea.models.taesd.TinyAutoencoder(*args, **kwargs)[source]¶
Bases:
BaseModelTiny Autoencoder model.
Note
This model currently only supports TensorFlow and Jax backends.
Initializes the TAESD model with the given parameters.
- Parameters:
**kwargs – Additional keyword arguments to pass to the superclass initializer.
- class zea.models.taesd.TinyBase(*args, **kwargs)[source]¶
Bases:
BaseModelBase class for TAESD encoder and decoder.
- class zea.models.taesd.TinyDecoder(*args, **kwargs)[source]¶
Bases:
TinyBaseDecoder from TAESD model.
Initializes the TAESD decoder.
- Parameters:
**kwargs – Additional keyword arguments passed to the superclass initializer.
- class zea.models.taesd.TinyEncoder(*args, **kwargs)[source]¶
Bases:
TinyBaseEncoder from TAESD model.
Initializes the TAESD encoder.
- Parameters:
**kwargs – Additional keyword arguments passed to the superclass initializer.
- zea.models.taesd.convert_original_weights(model_name='madebyollin/taesdxl', output_dir=None, revision=None)[source]¶
Convert the original PyTorch TAESD weights to TensorFlow / Keras v3 models.
This is how the
taesdxlpresets on the Hugging Face Hub were created; it is kept here for reproducibility and is not needed to use the model.The conversion goes PyTorch -> ONNX -> TensorFlow and therefore needs a few extra packages that are not part of the
zeadependencies:pip install torch diffusers[torch] onnx==1.16.1 onnxruntime==1.18.1 onnx2tf \ onnx-graphsurgeon onnxsim==0.4.33 sne4onnx sng4onnx tf-keras
Note
torch and TensorFlow have to coexist in one process here, which not every combination of wheels survives. Prefer the
zeahub/allcontainer, and import torch before this module if you hit a crash while building the torch model.- Parameters:
model_name (str, optional) – Hugging Face model id of the original PyTorch autoencoder. Defaults to
"madebyollin/taesdxl".revision (str, optional) – Git revision of model_name to convert. Defaults to None, i.e. whatever upstream currently has on its default branch; pass a commit or tag to reproduce one specific set of weights.
output_dir (str | Path, optional) – Folder to write the converted models to. Defaults to a timestamped folder under
./temp/zea.
- Returns:
Folder containing the converted
encoderanddecodermodels.- Return type:
Path