Instructions to use Efficient-Large-Model/Sol-H3-VAE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Efficient-Large-Model/Sol-H3-VAE with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Efficient-Large-Model/Sol-H3-VAE", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Download code/spark_decoder.py from Efficient-Large-Model/Sol-H3-VAE: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/Efficient-Large-Model/Sol-H3-VAE/resolve/main/code/spark_decoder.py
- Command line
-
hf download hf://Efficient-Large-Model/Sol-H3-VAE/code/spark_decoder.py
-
curl -L -o spark_decoder.py https://huggingface.co/Efficient-Large-Model/Sol-H3-VAE/resolve/main/code/spark_decoder.py
1.14 kB
| """Build the decoder from the Diffusers H3 VAE config.json alone; decoding is FastH3VAEDecoder's.""" | |
| import json | |
| from collections import OrderedDict | |
| from types import SimpleNamespace | |
| from safetensors.torch import load_file | |
| from fast_h3_vae import FastH3VAEDecoder | |
| from noncausal_vit_decoder import NonCausalViTDecoder | |
| from spark_compat import RGBProcessor, make_template | |
| from spark_fa4 import enable_sm120_guard | |
| class SparkFastH3VAEDecoder(FastH3VAEDecoder): | |
| def __init__(self, vae_config, weights, *, engine='fast', device='cuda', max_engines=1): | |
| enable_sm120_guard() | |
| with open(vae_config) as f: | |
| config = json.load(f) | |
| model = NonCausalViTDecoder(make_template(config), time_norm=5) | |
| model.load_state_dict(load_file(str(weights), device='cpu'), strict=True, assign=True) | |
| assert not any(t.is_meta for t in list(model.parameters()) + list(model.buffers())) | |
| self.model = model.to(device).eval().requires_grad_(False) | |
| self.vae = SimpleNamespace(processor=RGBProcessor()) | |
| self.engine, self.max_engines = engine, max_engines | |
| self._engines = OrderedDict() | |