Blog

Labeling images with vision language models

A detector cannot tell a respirator from a dust mask until someone labels the frames. The frames are confidential. Labeling them by hand is slow.

Date
Outcome
Safety
Gloved hands clip a cap lamp to a scuffed yellow hard hat on a handrail at a mine portal in falling snow.

Can a model write the first label

A custom vision model for a plant needs labeled images, and somebody has to write the labels. Hand labeling is slow. Plant images are confidential, so a public labeling service is often ruled out.

A vision language model (VLM) takes an image and a question in plain words and answers in text. Run on your own machine, it sends no image anywhere. We asked whether one could draft the label for a person to check.

This was an internal test. The images showed people wearing protective equipment on construction sites, in medical rooms and at mines. Every model got the same prompt:

Please describe in particular, the protective equipment being worn, if present.

Finding the equipment was half the test. The other half was telling close variants apart: one kind of vest, mask or safety glasses from another.

The notebook and scripts are in the VLM protective-equipment analysis toolkit on GitHub.

185images in the test set

From image to draft label

The path has six parts. The model never sees a label; it sees a picture and a question. Its answer is free text with no confidence score, so a person reads each one before it becomes a label.

Isometric diagram of the annotation path: images and a prompt enter a vision language model, and a person checks its description before it becomes a label.213456
  1. Image set, kept on your own machine
  2. One prompt in plain words
  3. Vision language model, run locally
  4. Text description of the equipment
  5. A person checks the description
  6. Labeled set for training a detector

Four models, two ways to run them

Three models ran through Ollama: LLaVA 13B, LLaVA 7B and Llama 3.2 Vision. Ollama is an open-source tool that downloads a model and serves it with one command. Its default builds are quantized: the weights are stored at lower precision, so the model is smaller and faster and loses some fine detail.

One model, Ovis1.6-Gemma2-9B, ran through Hugging Face Transformers. Transformers loads the model in Python. It takes more setup and gives more control over how the model is loaded and called.

The repository also holds a script for Qwen2-VL. We left that model out of the comparison.

One image, three descriptions

The image shows a person in profile. They wear a full-face mask with a small fan unit fitted on top. Under it are a surgical mask and a cloth cap. A thin cable runs down from the fan.

The person in the image is wearing personal protective equipment (PPE), which typically includes items such as a surgical mask and face shield to cover the face and prevent respiratory particles from spreading. In this case, the individual is also wearing what appears to be an air hood or clear plastic visor that goes around the head, providing additional protection by enveloping the head and neck area. This type of equipment can help reduce the spread of aerosols during medical procedures where respiratory precautions are necessary. The person is also wearing a surgical cap, which helps to keep hair from falling into the face or sterile field during surgery.
LLaVA 13B, through Ollama
In the image you've provided, we can see a person wearing medical protective equipment which includes a head-mounted visor with a clear visor attached to it, likely for eye protection or to shield the face from respiratory particles during certain procedures. The person is also wearing a surgical mask, blue scrubs, and a cap that is not fully visible but appears to be a standard white cap used in medical settings. Additionally, there are some cables connected to the head visor that could suggest the equipment is attached for a specific purpose or procedure, such as a ventilator or oxygen delivery system. The person seems to be engaged in a task related to healthcare, possibly monitoring or administering medical care.
LLaVA 7B, through Ollama
The individual is wearing a protective face mask with a clear visor, which is likely used for medical or laboratory purposes. This mask provides a barrier against airborne particles and contaminants. Additionally, a surgical cap is worn, which helps maintain a sterile environment by preventing hair from contaminating the area. The setup includes a device attached to the mask, possibly for ventilation or air filtration, indicating a controlled environment where protection from airborne contaminants is necessary.
Ovis1.6-Gemma2-9B, through Transformers

All three found the face covering and the cap. LLaVA 13B called the mask an air hood. LLaVA 7B saw the cable and guessed at a ventilator. Only Ovis1.6-Gemma2-9B tied the unit on top to air filtration.

At a mine that is the gap between "mask" and "powered air-purifying respirator". A detector needs the second label.

How the answers were judged

The images came with no labels to score against. That is the usual case on a new plant problem. So each description was read and judged by hand.

  • Three levels of image complexitySimple, moderate and complex.
  • Three levels of accuracyHigh, moderate and low.

The model gives text, not a score, so the accuracy level is a reader's judgment. The image list and the evaluation sheet are in the repository.

What the counts showed

  • Every model did best on simple images.
  • LLaVA 13B was strongest there.
  • Complex images drew fewer high-accuracy descriptions from every model.
  • Low accuracy was the smallest group for every model.
  • Ovis1.6-Gemma2-9B handled moderate images better than the others.
  • LLaVA 7B was the most even across the three complexity levels.

A high-accuracy description could go straight in as a draft label. A moderate one needed a small correction. A low one needed a person to write the label from the image.

134simple images described at high accuracy by LLaVA 13B

Speed against detail

The two routes differed most in time. The table gives the rest of what we saw.

AspectTransformersOllama
ModelsA wide choice, each loaded from its own repository: Ovis1.6-Gemma2-9B, Qwen2-VLModels packaged for Ollama: LLaVA 13B, LLaVA 7B, Llama 3.2 Vision
DetailHigher accuracy on close variantsLower accuracy on close variants
ControlMore to adjust; fits inside a larger data pipelineLittle to adjust
SetupMore steps before the first answerOne command for each model

15–20minutes to process 185 images with Ollama

900–1,200minutes to process 185 images with Transformers

What we took from it

  • A prompt is enough to startA safety or process engineer can run the test without training in computer vision.
  • The first answer comes fastWith Ollama the answers come back in minutes, so you learn early whether the idea fits your images.
  • Descriptions were mostly consistentSimilar equipment drew similar words, which matters when several people label one set.
  • Quantized models miss fine detailCheck them on your own equipment before you trust them.
  • No model was right on every imageUse the model for the first pass and a person for the check.

The method is not tied to protective equipment. The same first pass works for product on a belt, a flare tip or the state of a filter cloth.

A detector built on labeled frames

A gold producer needed four items found on camera: hard hat, glasses, mask and vest. We built the detector as a proof of concept on one camera system.