# Grid View for Labeling Many Items at Once

Source: https://www.potatoannotator.com/docs/features/grid-view

*New in v2.12.0*

Grid view is a second annotation page at `/annotate/grid` that shows a page of items as tiles and labels many tiles with one click. An annotator selects a run of tiles, presses a label, and saves the page. The grid answers one radio, multiselect, or triage scheme, and Potato keeps the page off until the config enables the `grid_view` block. Grid view suits short texts and images that take a second each to judge. On the normal page, each short item takes a screen of its own and a separate move to the next item. The grid takes items from the annotator's own assignment and saves through the same route as the normal annotation page. Grid labels therefore count toward agreement and quality control like labels given on the normal page.

## Configuration options

The `grid_view` block takes three options. Add the block below to a config whose `annotation_schemes` list has a radio scheme named `sentiment`:

```yaml
grid_view:
  enabled: true
  scheme: sentiment
  page_size: 24
```

Each option and its default are listed below:

| Option | Default | What the option controls |
|---|---|---|
| `enabled` | `false` | Serves the grid at `/annotate/grid` and adds a **Grid** button to the top bar of the annotation page. While `enabled` is false, `/annotate/grid` redirects to `/annotate`. |
| `scheme` | none | The `name` of the scheme the grid labels. The option is required once `enabled` is true. |
| `page_size` | `24` | How many unanswered items one grid page shows, a whole number from 1 to 200. |

With `enabled: true`, Potato rejects the config in four cases:

- `scheme` names no scheme in the top-level `annotation_schemes` list.
- The named scheme has an `annotation_type` other than `radio`, `multiselect`, or `triage`. A span, image-region, or text scheme fails the check.
- `page_size` is not a whole number from 1 to 200.
- Another scheme in the study is required, through `required: true` or `label_requirement: {required: true}`. A `pure_display` scheme does not count, and the grid's own scheme may be required.

The last check exists because Potato counts an item labeled in the grid as done and never sends the annotator back to the item. A second required scheme would go unanswered on every grid item, and the study would still finish. Other schemes can stay in the study as optional schemes, and annotators answer the optional schemes only on items opened through the normal page.

## Labeling on the grid

An annotator opens `/annotate/grid` after logging in, or clicks **Grid** in the top bar of the annotation page. The grid page links back to the normal page through **One at a time** and shows how many items the annotator has answered so far. Above the tiles sit the scheme's `description` and one button per label. Selection and labeling work through the mouse and the keyboard:

| Action | Mouse | Keyboard |
|---|---|---|
| Select one tile | Click | Arrow keys move between tiles, and Space selects or deselects the focused tile |
| Select a range | Shift-click, from the anchor tile | Shift with an arrow key moves the focus one tile or one row and adds the destination tile |
| Add or remove one tile | Ctrl-click or Cmd-click | Space |
| Select every tile | | A |
| Apply a label | Click the label's button | The key shown on the label's button |
| Remove every label from the selected tiles (multiselect only) | Click **Clear** | |

The anchor of a Shift-click range starts at the first tile. The anchor moves to the last tile clicked without Shift, Ctrl-clicked or Cmd-clicked, or toggled with Space. A Shift-click leaves the anchor in place and replaces the current selection with the range.

The label keys depend on the scheme type. For radio and multiselect schemes, the grid numbers the first nine labels 1 to 9 in the scheme's order and ignores any keys the normal page binds. A tenth label and every later label get no key. For a triage scheme, the buttons are the scheme's own `accept_label`, `reject_label`, and `skip_label` (Keep, Discard, and Unsure by default) on the scheme's `accept_key`, `reject_key`, and `skip_key` (1, 2, and 3 by default). A label key takes precedence over A, so a triage scheme that binds `a` to accept loses the select-all shortcut. Keys pressed with Ctrl, Cmd, or Alt never apply a label, and browser shortcuts such as copy and reload keep working.

A label behaves according to the scheme type. On a radio or triage scheme, a label replaces whatever label the selected tiles had. On a multiselect scheme, a label goes onto every selected tile, or comes off every selected tile when all of the selected tiles already have the label.

## Saving and storage

**Save and load more** saves every labeled tile and then loads the next page. Potato posts each tile to `/updateinstance`, one request per item, in the same form the normal annotation page sends. The grid therefore has no storage of its own. Each annotation lands in the annotator's `user_state.json` under `output_annotation_dir`, the item's annotation count rises as on the normal page, and an item labeled in the grid shows as answered when the annotator opens the item on the normal page. A radio or multiselect label is stored under the scheme and label names, and a triage decision is stored as `accept`, `reject`, or `skip`, the same values the triage scheme stores on the normal page.

Tiles left unlabeled are not saved and come back on the next page. When a save fails, the grid outlines each failed tile in red and shows the reason when the pointer rests on the tile. The other tiles stay saved, and pressing **Save and load more** again resends every labeled tile not yet saved. A tile labeled after the failure goes out in the same retry.

The grid shows only items the annotator has not answered. To revise an answer, the annotator opens the item on the normal annotation page.

## Tile content

Each tile shows the value of the item's `item_properties.text_key` field. Text is clamped to six lines, and Potato escapes the text, so HTML in an item appears as written rather than rendered. A value that ends in an image extension (`.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`, `.svg`, `.tif`, `.tiff`, or `.avif`, ignoring any query string) or starts with `data:image/` shows as an image instead. A URL without one of those extensions, such as `https://example.org/img?id=3`, shows as text. The browser uses the value unchanged as the image's address, so a path or URL has to be reachable from the annotator's browser. Images fit a 4:3 box inside the tile.

The grid page shows the task name, the scheme's description, the label buttons, and the tiles, and nothing else from the normal annotation page. A study that needs `instance_display` fields, several schemes per item, or `ai_support` hints labels the items on the normal page.

## Assignment and phases

The grid fills each page from the annotator's existing assignment and asks for more items the same way the normal page's **Next** button does. The `assignment_strategy`, the per-item annotator cap, and `max_annotations_per_user` therefore hold on the grid as on the normal page, and an item that reached its cap through other annotators is not added to the annotator's queue. An item already in the queue still appears until the annotator answers the item, even when other annotators have since filled the cap.

Only annotators in the annotation phase reach the grid. An annotator on a consent, instructions, training, or other phase page who opens `/annotate/grid` is sent to `/annotate`, and the normal page then shows the annotator's current phase. A [training phase](/docs/features/training-phase) therefore runs on the normal pages first, and the grid opens once the annotator passes training. An annotator blocked by failed attention checks is sent to `/annotate` as well, and the normal page then ends the annotator's session on the done page. The done page shows the study's `attention_block_message`, or the crowd platform's failure code.

## Attention checks and gold items

When a study uses `attention_checks` or `gold_standards`, the grid places attention-check and gold items among the tiles at the configured rate. With `frequency: 3`, a check follows every three regular items, counted from the annotator's last check, and a `probability` setting works per item as on the normal page. Potato assigns and scores each check the same way as on the normal page, so failed checks in the grid count toward the same warning and block thresholds. In 2.14.0 the grid never shows the warning. Only the block shows, as a red tile reading "Not saved". Potato stores each answer before the check runs, so the answer that crossed the threshold is saved despite the tile's message. Gold items in `mode: training` are not placed in the grid. A page holds up to `page_size` regular items plus any checks placed among the regular items, and a page can open with a check, because handing out a check resets the count. See [quality control](/docs/features/quality-control#attention-checks) for the check settings.

## Per-group schemes

The grid reads only the top-level `annotation_schemes` list and ignores [per-group schemes](/docs/deployment/per-group-schemes). Every annotator who opens the grid labels the scheme that `grid_view.scheme` names. An annotator whose group's `schemes` binding leaves out the grid's scheme still gets the grid's scheme on the grid. A scheme written inline in a group's `schemes` list cannot be the grid's scheme, and the required-scheme check does not look at group bindings. In a study with per-group schemes, keep the grid's scheme in every group's binding, or leave `grid_view` off.

## Timing

Items on the grid record no clicks or keystrokes of their own, so the grid page measures the page's active time instead. Active time is the sum of the gaps between the annotator's clicks, key presses, and scrolls, with each gap capped at five minutes, as on the normal page. Each save divides the page's active time equally among the items the save stores. The admin dashboard's Throughput tab counts the per-item shares, so an annotator's items per hour on the grid compare directly with the normal page. A single grid item's time is an average over the item's page. Grid view is a poor fit for a study that analyzes per-item response times.

## Interface language and theme

The grid page is in English apart from the light and dark toggle. The page sets `lang="en"`, and the header, help text, status and save messages, and the **Grid** button on the annotation page are fixed English text. A `ui_language` setting translates the normal annotation page and, on the grid, only the toggle's tooltip and screen-reader label. The scheme's description and labels come from the config, so the description and labels appear in whatever language the config uses. For a study run in another language, an annotator on the grid sees English controls beside questions in the study's language.

The grid page follows `ui.theme` like the annotation page. When the theme follows the browser, the grid page carries the same light and dark toggle as the annotation page.

## Phones and touch screens

On a phone, the tiles reflow into as many columns of at least 11rem as the screen holds. A tap selects one tile and clears the rest of the selection. Range and add-one selection need Shift or Ctrl, so on a touch screen without a keyboard, labeling goes one tile at a time. The grid route does no device routing of its own. For annotators on phones, [Pocket Mode](/docs/features/pocket-mode) serves a touch interface to tasks built from touch-friendly schemes such as radio and multiselect.

## When grid view fits a study

Grid view helps when each judgment takes about a second and one question covers the item. Typical cases are screening a folder of photos for usable shots with a triage scheme, sorting headlines or short posts by sentiment with a radio scheme, and tagging thumbnails with a multiselect scheme. In each case the annotator sees 24 items side by side, labels runs of similar items in one key press, and saves once per page.

Grid view fits poorly in five cases:

- **Long items.** A tile clamps text to six lines, so a paragraph-length item is cut off.
- **Span, region, and free-text schemes.** Potato rejects the config when the grid's scheme is a span, image-region, or text scheme.
- **Studies with several required schemes.** Potato rejects grid view beside a second required scheme.
- **Items that need context.** The grid shows one field per item and none of the `instance_display` fields or `ai_support` hints the normal page can show.
- **Per-item timing.** The grid records time per page and averages the page's time over the page's items.

## Example project

Potato ships a runnable example in [`examples/classification/grid-view`](https://github.com/davidjurgens/potato/tree/master/examples/classification/grid-view), which labels 16 headlines for sentiment, 12 tiles per page:

```yaml
task_dir: .
port: 8000
annotation_task_name: Headline sentiment (grid)
output_annotation_dir: annotation_output/grid-view/

data_files:
  - data/headlines.jsonl

item_properties:
  id_key: id
  text_key: text

user_config:
  allow_all_users: true
  users: []

grid_view:
  enabled: true
  scheme: sentiment
  page_size: 12

annotation_schemes:
  - annotation_type: radio
    name: sentiment
    description: What is the sentiment of this headline?
    labels: [positive, neutral, negative]
    sequential_key_binding: true
```

From the example's folder, start the server:

```bash
potato start config.yaml -p 8000
```

Log in at `http://localhost:8000`, then open `http://localhost:8000/annotate/grid`, or click **Grid** in the top bar.

To screen photos instead, point `text_key` at the field that holds each photo's URL and swap the scheme for a triage scheme. Replace the `item_properties`, `grid_view`, and `annotation_schemes` blocks of the config above with the blocks below, which keep an optional notes field for the normal page:

```yaml
item_properties:
  id_key: id
  text_key: image

grid_view:
  enabled: true
  scheme: usable
  page_size: 48

annotation_schemes:
  - annotation_type: triage
    name: usable
    description: Is this photo usable for the dataset?
    accept_label: Usable
    reject_label: Unusable
    skip_label: Not sure
  - annotation_type: text
    name: notes
    description: Anything wrong with this photo?
```

## Further reading

- [Triage](/docs/annotation-types/triage), for the accept, reject, and skip scheme
- [Radio and multiselect](/docs/annotation-types/radio-multiselect), for the other two scheme types the grid takes
- [Task assignment](/docs/features/task-assignment), for assignment strategies and per-annotator limits
- [Quality control](/docs/features/quality-control), for attention checks and gold-standard items
- [Pocket Mode](/docs/features/pocket-mode), for annotating on phones and tablets

For implementation details, see the [source documentation](https://github.com/davidjurgens/potato/blob/master/docs/advanced/grid_view.md).
