Skip to content

Vision and Image Generation

Glossary

134 terms from Vision and Image Generation, in plain words, each with the chapter that teaches it.

#

*args and **kwargs
Python syntax where `*paths` collects any number of arguments into a tuple, and `**request` passes a dict's keys as keyword arguments.

A

Alpha
A pixel's opacity, from 0 (fully transparent) to 255 (solid). In a mask, transparent pixels mark where the image may be changed.
Alt text
A short description of an image, stored in the HTML `alt` attribute, that screen readers read aloud. Priya writes it for every Kettle & Crane product photo.
Anthropic Files API
An Anthropic service where you upload a file once and refer to it by `file_id`. You don't have to re-send the same bytes on every request.
Apache 2.0
A permissive open-source license that lets you use a model commercially with few conditions.
Arithmetic check
Code that verifies extracted numbers agree with each other (quantity × price = amount, lines add to subtotal). It catches misreads and supplier errors, but not a consistently invented invoice.
assert
A Python statement that checks a condition is true. In a pytest test, a failed `assert` marks the test as failed.
Attention
The transformer mechanism that lets each part of the input weigh up every other part. In diffusion models it lets the denoiser look at the encoded prompt at each step.
attention slicing (enable_attention_slicing)
A diffusers option that computes attention in smaller pieces to use less memory, at a small cost in speed.

B

Base64
A way of writing any bytes as plain text using letters, digits, `+` and `/`. It's how you put an image file inside a JSON request.
Batch processing
Submitting work that can wait, such as overnight invoices, at half price.
bfloat16 (bf16)
A 16-bit number format for storing model weights, which halves memory compared with 32-bit floats.
Bounding box
The smallest rectangle around something in an image, given as the pixel coordinates of two corners. You can ask a model for one, then crop to it.

C

C2PA (Coalition for Content Provenance and Authenticity)
A standard for signed provenance records stored inside media files, saying which tool made the file and how it was edited. Re-saving with Pillow strips them.
Cache (cached)
Saving a reply on disk, keyed by a hash of the exact request, so an identical request costs nothing the second time. Delete `cache/` for fresh answers.
Callback
A function you hand to a library so it calls it at set moments, such as after every denoising step of an image generator. It can be used to inspect or save intermediate values, like the latents, as the work progresses.
CCPA (California Consumer Privacy Act)
A California privacy law that gives residents rights over their personal data and places duties on businesses that collect it. It is an example of the rules to check before sending images containing personal data to an API.
Classifier-free guidance
A way to steer a diffusion model toward your prompt. Each step makes one prediction with the prompt and one without, and pushes the result toward the prompted one.
Content block, content blocks
One typed part of a message, such as text, an image or a document. A message's `content` can be a list of them.
Content Credentials
C2PA's name for its signed records of how a file was made. They live as a manifest inside the file.
Context window
The maximum amount of input and output tokens a model can handle in one request. An image uses a lot of that space.
Counter
A Python dict-like class that counts items and starts every count at zero. `local_eval.py` uses it to tally results.
Crop
Cutting out a rectangle of an image by pixel coordinates (left, top, right, bottom). Cropping to a label keeps small text at full size and costs fewer tokens.
csv module
Python's standard library for reading and writing comma-separated files. The inbox uses `csv.writer` to write the approved invoices.

D

Data URL
A media type plus base64 data in one string, like `data:image/png;base64,...`. OpenAI accepts it as `image_url`.
Decimal (and float rounding)
Python floats can't store most cents exactly (`0.1 + 0.2` gives `0.30000000000000004`), so money checks should allow a small tolerance such as half a cent. `decimal.Decimal` stores decimal numbers exactly and is the better choice for real accounting code.
Declined answer
A reply where the model says it can't tell, such as "none" or "unclear". It is scored separately from wrong, because a refusal to guess is far safer than a confident error.
Deepfake, deepfakes
Realistic AI-generated or manipulated content that resembles real people, objects, places or events and could pass as genuine. In the EU, a realistic image of a real product can count.
defaultdict
A Python dict that creates a default value, such as an empty list, the first time you use a new key. `eval.py` uses it to group case ids by result.
Denoising
Removing predicted noise from an image, one step at a time. Early steps set layout and color, and later steps add detail.
Detail
OpenAI's per-image setting for how much resolution the model gets: low, high, original or auto. Higher detail means more tokens.
diffusers
Hugging Face's Python library for running diffusion models locally.
Diffusion model, diffusion models
An image generator trained to predict the noise added to images. To generate, it starts from pure noise and removes noise step by step, steered by the prompt.
Digital Omnibus on AI
An EU regulation that gives systems already on the market before August 2, 2026 until December 2, 2026 to add machine-readable AI marking.
Distilled, distilled model
A smaller model trained to imitate the outputs of a larger one. `segmind/tiny-sd` is a distilled Stable Diffusion 1.5.
document block
The request item for sending a PDF: `document` for Claude and `input_file` for OpenAI. Claude reads both the page images and the extracted text.
dtype
The setting for what number format a model's weights are stored in, such as `torch.float32` or `torch.bfloat16`.
Duplicate detection
Spotting the same invoice entered twice by comparing supplier, date and total together, rather than the invoice number, which a model may misread.

E

Edit, edits
Changing an existing image with an image model, optionally with a mask or reference images. In OpenAI's SDK this is `images.edit`.
EU AI Act Article 50
An EU rule requiring disclosure of deepfakes and machine-readable marking of AI content. It has applied since August 2, 2026 and matters if you sell in Europe.
EXIF
Metadata a camera stores in a photo: device, time and often GPS location. Saving with Pillow drops it unless you pass it along.

F

Failure modes (vision)
The typical ways vision models go wrong: hallucinated or guessed details, lost small text, miscounting, spatial errors and poor inputs such as blur or glare.
float32
The 32-bit floating-point number format. It's the safe choice for model weights on a CPU.
FLUX (Black Forest Labs)
A company and image-model family that sells image generation APIs, mentioned as an alternative to OpenAI.

G

Gaussian blur
A Pillow filter that softens an image by averaging each pixel with its neighbors. It can be used to fake a blurry phone scan when making test images.
Gemini
Google's family of models. Gemini models read images, and its Gemini image models generate and edit them.
GPU
A graphics processor that runs large models much faster than a CPU. Small models can still run acceptably on a CPU alone, so a GPU is optional for them.
Gradient, gradients
The numbers training uses to work out how to adjust each weight. `torch.no_grad()` skips tracking them when you're only running the model.
Greedy decoding
Always choosing the most likely next token, so the same question gives the same answer every time.
Guidance scale
How strongly classifier-free guidance pushes toward the prompt. 1 means no extra push, about 7 is typical, and very high values look harsh.

H

Hallucination, hallucinated details
Output that sounds right but isn't supported by the input. For example, `gpt-6-luna` invented a whole invoice from a blurry scan.
Hash
A short fingerprint of data that changes completely if the data changes. `kc.cached` hashes the whole request to name its cache file.
High-resolution tier
Claude 4.7 and later's limit of a 2,576-pixel long edge and 4,784 tokens. Older models stop at 1,568 pixels and 1,568 tokens.
HTTP error codes (400, 413)
Status codes the API returns on failure: 400 means a bad request, such as a media type that doesn't match the bytes; 413 means the request is too large (over 32 MB on Claude).
Hugging Face
A company and platform hosting open models. Its Transformers library loads them by name, for example `AutoModelForImageTextToText` for vision-language models.
Human review queue
Items a program sets aside for a person to check. At Kettle & Crane, invoices with problems go to Jo.

I

if __name__ == "__main__"
A Python block that runs only when you run the file itself, not when another script imports it.
Image brief
An image prompt written as a checklist of subject, setting, composition, light and style, text and what to avoid, like instructions to a photographer.
Image generation model
A model that makes new images from text and optionally other images. Claude has no image generator, so examples use OpenAI's API or an open model instead.
Inpainting
Regenerating only part of an image, marked by a mask. Masks are guidance, so check that the kept area is really unchanged.
Instruct model
A model trained to follow instructions in a chat format, like `SmolVLM-256M-Instruct`.

J

JPEG
A lossy image format that discards detail the eye barely notices. It suits photos but blurs letter edges.
JSON Lines
A file with one JSON object per line. `labels.jsonl` and `review.jsonl` use this format.

L

Labeled test set
A collection of inputs with the correct answers written down by a person, used to measure how well a model performs. Each case can carry a `kind` label so you can see which skills fail.
Latency
How long a call takes from request to reply. For example, a vision question took about 1.1 seconds, while a hosted image took 8 to 16 seconds.
Latent
The small compressed form of an image that a latent diffusion model works on. A 512 × 512 image becomes a 64 × 64 grid of 4 numbers each.
Latent disclosure, latent disclosures
A machine-readable mark, such as C2PA data, saying content is AI-generated. California's AI Transparency Act requires large providers to embed them.
Local model, local models
A model run on your own computer, not through an API. It's private and free per call, but small ones are weak and slow.
Lossless, lossy (PNG, JPEG)
Lossless compression keeps every pixel exactly, as PNG does. Lossy compression discards some detail, as JPEG does.

M

Mask
A PNG the same size as the image that marks which area an edit may change. In OpenAI's edit, fully transparent pixels are the area to change.
math.ceil / round up
Rounding up to the next whole number. Patch counts use it, since a partial patch still counts as one.
Matplotlib
A Python plotting library. `make_chart.py` uses it to draw the orders bar chart.
Media type
The name of a file format, such as `image/png`. The API needs it to match the bytes, and `mimetypes.guess_type` works it out from the file extension.
Median
The middle value of a sorted list of numbers. It is used for typical latency because a few unusually slow calls don't distort it, such as a median of 1.1 seconds on Claude Haiku 5.5.
Mockup, mockups
A realistic preview image of a product that doesn't exist yet, such as Sam's flat mug drawing turned into a photo. Label it as a mockup.
Model names used in the book
`gpt-6-luna` is OpenAI's vision model and `gpt-image-2.5-flare` its image generator, alongside Claude's Haiku, Sonnet and Opus 5.5.
Moderation (image API setting)
An OpenAI image setting that chooses between the default safety filter and a less strict one.
Multimodal
Handling more than one kind of input, such as text and images.

N

Negative prompt
Text describing what a diffusion model should steer away from, used in place of an empty prompt in guidance.

O

OCR (optical character recognition)
Software that turns pictures of text into text. A VLM copes better with messy layouts, but may guess where OCR would give garbage.
Ollama / LM Studio
Tools that run open models locally, including vision models, where you pass an image file with your prompt.
Open model
A model whose weights you can download and run yourself. Check its license first.
Optional field
A schema field allowed to be missing (such as `date | None`). Required fields force the model to invent filler for documents that lack them.
Organization verification
A one-time identity check in OpenAI's API settings that may be required before its image models work.

P

Parameters (model size)
The numbers inside a model, used as a size measure. 256M means 256 million and 2B means 2 billion.
parse (messages.parse, responses.parse)
SDK calls that send a request and return the reply already validated as a Pydantic object. Claude uses `output_format=`, OpenAI `text_format=`.
Patch, patches
A small square of an image that becomes one visual token: 28 × 28 pixels for Claude, 32 × 32 for current OpenAI models.
Pillow
Python's standard image library, imported as `PIL`. It is used to draw, resize, crop, filter and save images.
pip
Python's package installer, used to install libraries such as Pillow or Pydantic.
Pipeline
In diffusers, the bundle of text encoder, denoising network, VAE and scheduler that turns a prompt into an image.
PNG
A lossless image format that stores every pixel exactly. It's efficient for flat color such as documents, charts and screenshots.
Processor
A model's bundled tokenizer and image preprocessing, which together turn your inputs into the tensors the model expects.
Projector
The small layer that converts the vision encoder's lists of numbers into the language model's token form, producing visual tokens.
Prompt caching
A provider feature that reuses a long unchanged system prompt or schema across calls to cut cost.
Prompt injection
Text in the input, including text inside an image, that tries to give the model orders. The defense: let the model read, and let your code decide.
Provenance
A record of where content came from and how it was made. Kettle & Crane saves a provenance JSON file next to each generated image.
Pydantic
A Python library that defines data shapes as classes and validates values against them. It is used for models like `Invoice` and `Line`, and as the schema for structured model output.
pytest
A Python test runner. It runs every function named `test_...` and reports failing `assert`s. `tmp_path` gives a test its own temporary folder.
PyTorch
A Python library for running neural networks, used with Transformers and diffusers. Its arrays are called tensors.

Q

Quality (image quality setting)
An image API setting that drives output tokens, cost and time. High costs about nine times as much as low and took twice as long.

R

Rate limits
Provider caps on how many requests you can make in a period. Parallel jobs must stay within them.
Redaction
Covering sensitive parts of an image, such as a card line, with a solid box before sending it. Blurring can sometimes be reversed.
Reference image, reference images
An image passed to a generator for it to follow, such as Sam's flat mug drawing. With references, `kc.generate` calls `images.edit`.
Refusal
A provider declining a request on policy grounds. It arrives as an error from OpenAI or a `refusal` stop reason from Claude.
Resizing before the model sees an image
APIs shrink large images to fit size and token limits before encoding. It saves tokens but can shrink small text until it's unreadable.
RGB, RGBA
Color as red, green and blue values from 0 to 255 per pixel. RGBA adds an alpha channel for opacity.
Right of publicity
A person's right to control commercial use of their name and likeness, which many US states grant. It's why Kettle & Crane never generates images of real people.

S

Safetensors / pickle (.bin weights)
Weight file formats. `.bin` files can run code when loaded, so only load them from trusted sources, whereas safetensors can't.
Scheduler
The rule for how much noise to remove at each diffusion step.
Screen reader
Software that reads a web page aloud for blind and low-vision users. It reads alt text for images.
Seed, seeds
A number that fixes a random generator, so results repeat. With the same model, prompt, settings and seed, a local diffusion model gives the same picture.
SmolVLM
A family of small open vision-language models from Hugging Face, with sizes from 256M to 2.2B parameters. The 256M version is small enough to run on an ordinary CPU.
Stable Diffusion
The best-known family of open diffusion image models, from Stability AI. Smaller distilled versions, such as `tiny-sd` (based on Stable Diffusion 1.5), imitate the larger model and can run on a CPU.
Step, steps
How many denoising rounds a diffusion model runs. More steps trade time for detail.
Streaming
Receiving a reply piece by piece as it's produced instead of waiting for the whole thing. It suits text replies for people who are waiting, while image streaming depends on whether the model supports it.
Structured output
Getting a model's reply in a fixed schema, here a Pydantic model. It guarantees the shape of the data, not that the values are true.
Style block
A fixed piece of prompt shared by every image in a set, with only the subject changing. It keeps Sam's newsletter images looking like one shoot.
SynthID
Google's invisible watermark in image pixels. It survives screenshots and resizing far better than metadata.
sys.argv
The list of words typed on the command line after `python3`. Scripts use it to pick a folder, provider or date.

T

Tensor, tensors
PyTorch's array of numbers, with any number of dimensions. Processors turn your inputs into tensors.
Text encoder
The network that turns a prompt into vectors a diffusion model can follow through attention.
thumbnail / resize
Pillow calls for shrinking images. `thumbnail` shrinks in place to fit a box and never enlarges, while `resize` returns a new image of an exact size.
Tiles (image tiling)
Cutting a large image into smaller, overlapping pieces and asking about each. It helps with small text but costs more memory or tokens.
Token
The chunk of text an LLM reads. A VLM turns image patches into visual tokens too, and you pay for them as input.
Trademark
A legally protected brand name or logo. A generated image may show an invented brand that is someone's real trademark.
Transformer
The network design behind today's language models, whose layers let every item in a sequence take every other into account.

V

VAE (variational autoencoder)
The network that squeezes images into latents and decodes them back into pixels.
Virtual environment
An isolated Python setup per project so its libraries don't clash with others. You create and activate one in the `kc-vision` folder.
Vision checker
A vision model asked to check an image against a list of YES/NO criteria. It's a model too, so test it on labeled examples and use it to sort, not to decide.
Vision encoder
The network that turns each patch into a list of numbers (feature vector). It's usually a ViT.
Vision transformer (ViT)
A transformer that reads an image as a sequence of patches the way a text model reads words.
Vision-language model (VLM)
A model that takes images and text in and writes text out, such as Claude, GPT and Gemini.
Visual tokens
The tokens an image becomes inside a VLM. The language model reads them together with your text tokens.

W

Weights
The trained numbers inside a model. Open models let you download them.