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
File size: 2,904 Bytes
c001780 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | """Text accuracy of renders: Apple Vision OCR vs the quoted strings in each prompt.
python ocr_score.py --cases a.json b.json --dirs tierA=dirA tierB=dirB --out ocr.json
Scores per image: word recall (fraction of requested words found, case-insensitive) and mean phrase
similarity (best fuzzy match of each quoted phrase in the OCR text, difflib ratio).
"""
import argparse, difflib, json, re
from pathlib import Path
import Quartz
import Vision
from Foundation import NSURL
def ocr(path):
url = NSURL.fileURLWithPath_(str(path))
req = Vision.VNRecognizeTextRequest.alloc().init()
req.setRecognitionLevel_(Vision.VNRequestTextRecognitionLevelAccurate)
req.setUsesLanguageCorrection_(False)
h = Vision.VNImageRequestHandler.alloc().initWithURL_options_(url, None)
h.performRequests_error_([req], None)
return [o.topCandidates_(1)[0].string() for o in (req.results() or [])]
def norm(s):
return re.sub(r"[^a-z0-9 ]", "", s.lower().replace("·", " "))
ap = argparse.ArgumentParser()
ap.add_argument("--cases", nargs="+", required=True)
ap.add_argument("--dirs", nargs="+", required=True)
ap.add_argument("--out", required=True)
args = ap.parse_args()
cases = [c for f in args.cases for c in json.loads(Path(f).read_text())]
res = {}
for spec in args.dirs:
tier, d = spec.split("=", 1)
rows = []
for c in cases:
phrases = re.findall(r'"([^"]+)"', c["prompt"])
if not phrases:
continue
for s in c["seeds"]:
p = Path(d) / f"{c['name']}_s{s}.png"
if not p.exists():
continue
lines = ocr(p)
text = norm(" ".join(lines))
words = [w for ph in phrases for w in norm(ph).split()]
found = sum(1 for w in words if re.search(r"\b" + re.escape(w) + r"\b", text))
sims = []
for ph in phrases:
target = norm(ph)
best = max((difflib.SequenceMatcher(None, target, norm(l)).ratio() for l in lines), default=0.0)
# phrases split across lines: also compare against the full text window
sm = difflib.SequenceMatcher(None, text, target)
m = sm.find_longest_match(0, len(text), 0, len(target))
best = max(best, m.size / max(len(target), 1))
sims.append(best)
rows.append({"image": p.name, "word_recall": found / max(len(words), 1), "phrase_sim": sum(sims) / len(sims),
"n_words": len(words)})
n = len(rows)
res[tier] = {"n_images": n, "word_recall": sum(r["word_recall"] for r in rows) / max(n, 1),
"phrase_sim": sum(r["phrase_sim"] for r in rows) / max(n, 1), "rows": rows}
print(f"{tier}: {n} images, word recall {res[tier]['word_recall']:.3f}, phrase similarity {res[tier]['phrase_sim']:.3f}")
Path(args.out).write_text(json.dumps(res, indent=1))
|