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_prompt.py from VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/ref_prompt.py
- Command line
-
hf download hf://VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/code/scripts/ref_prompt.py
-
curl -L -o ref_prompt.py https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit/resolve/main/code/scripts/ref_prompt.py
1.73 kB
| """Reference prompt token ids via the upstream HF tokenizer (transformers + remote code).""" | |
| import json, sys | |
| from pathlib import Path | |
| from transformers import AutoTokenizer | |
| SYSTEM = ("Generate an image matching the requested resolution by detailing the color, quantity, text, shape, size, " | |
| "texture, spatial relationships of the objects and background.") | |
| code = Path(sys.argv[1]); out = Path(sys.argv[2]) | |
| tok = AutoTokenizer.from_pretrained(str(code), trust_remote_code=True) | |
| cases = [("A cinematic photograph of a red fox in a snowy pine forest at dawn.", 1024, 1024), | |
| ("A cinematic photograph of a red fox in a snowy pine forest at dawn.", 1184, 880), | |
| ('Poster with the title "Echoes of Courage" — émigré café 東京 ✓', 880, 1184), | |
| ("x", 1248, 832)] | |
| res = [] | |
| for p, w, h in cases: | |
| msgs = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": f"Generate a {w}x{h} image.\n\n{p}"}] | |
| ids = tok.apply_chat_template(msgs, tokenize=True, add_generation_prompt=True, enable_thinking=False, return_tensors=None) | |
| if isinstance(ids, dict): ids = ids["input_ids"] | |
| text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True, enable_thinking=False) | |
| res.append({"prompt": p, "w": w, "h": h, "ids": list(map(int, ids)), "text": text}) | |
| ids = {k: tok.convert_tokens_to_ids(k) for k in ["<|img_start|>", "<|img_end|>", "<|vis_row|>", "<|im_end|>"]} | |
| hdr = tok.base_tokenizer.encode("height=1024 width=1024", add_special_tokens=False) | |
| out.write_text(json.dumps({"cases": res, "special": ids, "eos": tok.base_tokenizer.eos_token_id, "hdr_example": hdr}, ensure_ascii=False, indent=1)) | |
| print(json.dumps(res[0]["text"])); print(len(res[0]["ids"]), ids) | |