Instructions to use shuttleai/shuttle-3-diffusion-fp8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use shuttleai/shuttle-3-diffusion-fp8 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("shuttleai/shuttle-3-diffusion-fp8", 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
- Local Apps Settings
- Draw Things
- DiffusionBee
File size: 713 Bytes
8605d91 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import torch
from safetensors.torch import load_file, save_file
def lazy_load_and_convert(input_file_path, output_file_path):
# Load the safetensors file lazily
lazy_tensors = load_file(input_file_path, device="cuda:0")
# Convert each tensor to torch.float8_e4m3fn
converted_tensors = {key: value.to(torch.float8_e4m3fn) for key, value in lazy_tensors.items()}
# Save the converted tensors to a new safetensors file
save_file(converted_tensors, output_file_path)
if __name__ == "__main__":
input_file_path = "path/to/your/input_file.safetensors"
output_file_path = "path/to/your/output_file.safetensors"
lazy_load_and_convert(input_file_path, output_file_path) |