Skip to main content

TestAtlasVision SDK

Python SDK for AtlasVision (package testatlasvision, client class TestAtlasVision): ask questions about images in English, Igbo, Yoruba and Hausa. It wraps SigLIP2 (vision) + N-ATLaS (language) + the AtlasVision projector/LoRA weights, and is a cleaned-up, standardised version of the test-atlas-vision Colab.

Needs a GPU. It will not run on a normal laptop. Test it in Colab with colab/smoke_test.ipynb. Everything that doesn't need weights (prompts, languages, auth, images, sessions) is covered by pytest and runs anywhere.

Install

pip install testatlasvision            # core (from PyPI)
# or from a source checkout: pip install .
pip install "testatlasvision[4bit]"    # + bitsandbytes (needed on GPUs < 20 GB, e.g. Colab T4)
pip install ".[dev]"     # + pytest (source checkout)

Authentication (N-ATLaS is gated)

  1. Create a Hugging Face account and request access at https://huggingface.co/NCAIR1/N-ATLaS.
  2. Create an access token at https://huggingface.co/settings/tokens (see below for which type).
  3. Give it to the SDK in any one of these ways (checked in this order):
Where How
Code TestAtlasVision(token="hf_...")
Environment export HF_TOKEN=hf_...
Colab Add a Secret named HF_TOKEN (key icon in sidebar, enable Notebook access)
Cached login huggingface-cli login
Prompt TestAtlasVision(interactive_login=True)

Which token type?

Situation Use
Testing in Colab, personal use Read. Simplest. It can read everything your account can, including the gated model.
Production / the shared server Fine-grained, so a leak only exposes what you listed.
Anything else Never Write, Full Access, Inference or CI/CD. The SDK only downloads weights.

For a fine-grained token, tick "Read contents of public gated repos you can access" (this is what lets it download N-ATLaS). If the Modularcomputing/AtlasVision repo is private, also add it under Repositories permissions with read access. Nothing else is needed. Without the gated-repos permission the token is valid but gets a 403 on N-ATLaS, which the SDK reports as GatedModelAccessError.

Notes: the token type can't be changed after creation (make a new one). Use one token per app, and keep it out of git. Your account still has to have been granted access on the N-ATLaS model page, whatever the token type.

The client checks access before the large downloads and raises a clear error: AuthenticationError (no/invalid token) or GatedModelAccessError (token fine, access not granted). The token is never logged (only a masked form) or written to disk by the SDK.

Quick start

from testatlasvision import TestAtlasVision, GenerationConfig

model = TestAtlasVision()                       # load ONCE (takes minutes)

model.ask("cats.jpg", "How many animals are in this image?")        # -> str
model.describe("cats.jpg", lang="yo")                               # caption in Yoruba

r = model.chat("cats.jpg", "Kedu ihe dị na foto a?", lang="ig")     # -> ChatResult
r.answer, r.english_question, r.english_answer

# Follow-up questions
s = model.new_session()
model.ask("cats.jpg", "What is the main object?", session=s)
model.ask("cats.jpg", "What colour is it?", session=s)

# Text-only (LoRA off)
model.text("Explain what a positron is.")
model.translate("Good morning", "ha")

# Decoding settings
model.ask("cats.jpg", "Describe it", config=GenerationConfig(max_new_tokens=100, temperature=0.7))

image can be a PIL image, a file path, raw bytes, a file-like object, or an http(s) URL.

API reference

Method Returns Notes
TestAtlasVision(token, repo, llm, vision, stage, load_in_4bit, device, interactive_login, allow_remote_images, check_access) client stage: "2b" (default, recommended), "2", "1" (captioner)
ask(image, question, *, session=None, config=None) str English only. Pass a Session for follow-ups
chat(image, question, *, lang="en", session=None, translate_question=True, config=None) ChatResult lang in en/ig/yo/ha (or names). Non-English = translate, answer, translate back
describe(image, *, lang="en", detailed=True, config=None) str Caption
text(prompt, *, config=None) str Plain N-ATLaS, no image
translate(text, target, source="en", *, config=None) str Between en/ig/yo/ha
new_session() Session Conversation memory (always stored in English)
info() ModelInfo For health endpoints
close() None Free GPU memory

Errors (all subclass AtlasVisionError): AuthenticationError, GatedModelAccessError, ModelLoadError, ImageLoadError, UnsupportedLanguageError.

How the Colab maps to the SDK

test-atlas-vision SDK
notebook_login() token resolution (auth.py), no notebook widget needed
model.history (one list on the model) Session objects owned by the caller
model.ask(image, q, max_new_tokens=60) model.ask(image, q, config=GenerationConfig(max_new_tokens=60))
chat() returning a dict chat() returning ChatResult
LANGUAGES.get(x, x) accepting anything strict normalize_language
!pip uninstall torchao still needed in Colab; done in the notebook, not the library

Notes for the API layer

  • Load once at startup, keep one client per GPU. Loading takes minutes.
  • Sessions replace model.history. The Colab kept history on the model object, which would mix users together in a server. Store Session.to_dict() in Redis/DB keyed by session_id.
  • Generation is serialised by an internal lock (one GPU; the LoRA toggle in text() is global). Concurrent requests queue. Scale by running more workers/GPUs, not threads.
  • Latency: a non-English chat is up to 3 generations. Set generous timeouts, or consider a job/polling pattern for ig/yo/ha.
  • Public endpoints: build the client with allow_remote_images=False (a server fetching arbitrary URLs is an SSRF risk) and accept uploads instead. load_image also caps downloads at 25 MB.
  • Server token: the server needs its own HF token (env var HF_TOKEN); end users never need one.
  • import testatlasvision doesn't import torch, so request/response schemas can be shared with code that runs without a GPU. Map errors to HTTP codes per the table in exceptions.py.

Testing

pytest                      # offline, no GPU

GPU/model behaviour, in Colab (GPU runtime). Two options:

  • No upload needed: open colab/smoke_test_standalone.ipynb. It writes the SDK files itself, installs them, and runs the checks.
  • With the zip: open colab/smoke_test.ipynb, upload testatlasvision-sdk.zip (or put it in Google Drive), run all cells.

Known gaps

  • Only the offline parts have automated tests. The model-loading and generation paths were ported line-for-line from the Colab but have to be verified in Colab (see the notebook).
  • transformers>=4.56 is pinned because the Colab uses dtype=; align it with the version that notebook actually runs.
  • No streaming and no batching yet.

Metadata

Release files for testatlasvision 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for testatlasvision 0.1.0
File Size Uploaded Provenance
testatlasvision-0.1.0.tar.gz 20.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for testatlasvision 0.1.0
File Interpreter ABI Platform
testatlasvision-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.9 kB

Release files / testatlasvision-0.1.0.tar.gz

Download URL testatlasvision-0.1.0.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ff0e84cfc26e36ad2b399be7d7d72f97c7aa4e05ef26e3e3dd482c0311d0b5bd
BLAKE2b-256 checksum
How to use checksums
80be3cbc8c2aba2b6357cd8ff9303f060e443916421d00c1b0cd6df64c031923
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / testatlasvision-0.1.0-py3-none-any.whl

Download URL testatlasvision-0.1.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92c753daac4bef74b6e5b397d46521162ae5edd60d8091f4be8135a9d0bcc075
BLAKE2b-256 checksum
How to use checksums
82f1be208f377c4209b6b51a3ec89ed6a7b273b7cf74668abc2d335572e428ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for testatlasvision 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page