Text-to-Image
MLX
Safetensors
English
nemotron_h
apple-silicon
mac
autoregressive
mamba
Mixture of Experts
nemotron
nemotron-labs-image
q5
custom_code
Instructions to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit --local-dir Nemotron-Labs-Image-30B-A3B-MLX-5bit
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download code/scripts/ref_vq.py from VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/ref_vq.py
- Command line
-
hf download hf://VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/code/scripts/ref_vq.py
-
curl -L -o ref_vq.py https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/ref_vq.py
1.27 kB
| """Reference L24SQ decode/encode with the upstream torch module (CPU), fp32 and bf16.""" | |
| import sys, json, numpy as np, torch | |
| from pathlib import Path | |
| from transformers import AutoModel | |
| from PIL import Image | |
| tokdir, out = Path(sys.argv[1]), Path(sys.argv[2]) | |
| gallery = Path(sys.argv[3]) if len(sys.argv) > 3 else None | |
| rng = np.random.default_rng(0) | |
| grid = (24, 32) # 384x512 test grid (non-square) | |
| idx = rng.integers(0, 196560, size=grid[0] * grid[1]) | |
| res = {"idx": idx} | |
| for name, dt in (("fp32", torch.float32), ("bf16", torch.bfloat16)): | |
| m = AutoModel.from_pretrained(str(tokdir), trust_remote_code=True, dtype=dt).eval() | |
| with torch.inference_mode(): | |
| img = m.pack_decode(indices_list=[torch.tensor(idx)], grid_sizes=[grid])[0] | |
| res[f"dec_{name}"] = img.float().numpy() | |
| if gallery is not None: | |
| im = Image.open(gallery).convert("RGB") | |
| x = torch.from_numpy(np.asarray(im)).permute(2, 0, 1).float() / 255 | |
| x = m.preprocess_image(x).to(dt) | |
| enc = m.encode(x[None]) | |
| res[f"enc_{name}"] = enc["indices"][0].numpy() | |
| res["enc_grid"] = np.array(enc["grid_size"]) | |
| del m | |
| np.savez(out, **res) | |
| print({k: v.shape for k, v in res.items()}) | |