Text-to-Image
Diffusers
Safetensors
Cosmos
Cosmos3OmniDiffusersPipeline
cosmos3_omni
cosmos3
quantization
fp8
8-bit precision
modelopt
image-to-video
Instructions to use Reza2kn/Cosmos3-Nano-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Reza2kn/Cosmos3-Nano-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("Reza2kn/Cosmos3-Nano-FP8", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Cosmos
How to use Reza2kn/Cosmos3-Nano-FP8 with Cosmos:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
| """Load this quantized Cosmos3-Nano. Requires: diffusers (git main / >=0.39), nvidia-modelopt, torch (cu128). | |
| from load_quantized import load | |
| pipe = load() # uses this repo, or pass a repo id / local dir | |
| import torch | |
| with torch.autocast("cuda", torch.bfloat16): | |
| img = pipe("a corgi astronaut", num_frames=1, height=480, width=480).video[0][0] | |
| """ | |
| import os, torch | |
| from diffusers import Cosmos3OmniPipeline, Cosmos3OmniTransformer | |
| import modelopt.torch.opt as mto | |
| def load(repo_or_dir=".", device="cuda"): | |
| if os.path.isdir(repo_or_dir): | |
| local = repo_or_dir | |
| else: | |
| from huggingface_hub import snapshot_download | |
| local = snapshot_download(repo_or_dir) | |
| tf = Cosmos3OmniTransformer.from_config( | |
| Cosmos3OmniTransformer.load_config(f"{local}/transformer/config.json")).to(torch.bfloat16) | |
| mto.restore(tf, f"{local}/transformer/modelopt_quantized.pt") # restores 4-bit weights | |
| pipe = Cosmos3OmniPipeline.from_pretrained( | |
| local, transformer=tf, torch_dtype=torch.bfloat16, enable_safety_checker=False) | |
| return pipe.to(device) | |
| if __name__ == "__main__": | |
| pipe = load() | |
| with torch.autocast("cuda", dtype=torch.bfloat16): # required: float32 rotary tensors -> bf16 linears | |
| img = pipe("A red panda astronaut floating in a nebula, highly detailed", | |
| num_frames=1, height=480, width=480).video[0][0] | |
| img.save("out.png"); print("saved out.png") | |