Phase 4: Review and build a dataset
Of the 50 or so episodes you recorded, you now decide which ones the policy learns from. Watch each one in the capture-control webapp, tag it as a keeper or a discard, then collect the keepers into a sequence dataset named xarm-stacking-v1.
Why review
A few bad episodes cost more than they add, because a dropped block, a long pause, or a camera dropout all become training data. ACT (Action Chunking with Transformers) learns hesitation as readily as skill, so a policy trained on a pause will pause. A smaller clean set beats a larger mixed one.
Review in the webapp
Open the capture-control webapp. Below the camera views are two buttons, Review session and Episodes:

- Review session lists the episodes from the session you just ended, as they sync.
- Episodes opens the same player for this machine’s past episodes. Filter by task, session, and review status.
Each episode plays its camera frames in real time. Press K to tag the episode review:keep or D to tag it review:discard, and the app jumps to the next episode you haven’t reviewed.
Nothing is deleted. An episode with neither tag counts as not reviewed.
A sequence can appear before all its frames have synced. K and D unlock once the frames have caught up, or after 15 seconds with no new frames, when the app marks the episode partial. Discard partial episodes.
| Key | Action |
|---|---|
| K / D | Keep or discard, then go to the next unreviewed episode |
| ← / → | Previous or next episode |
| Space | Play or pause |
| , / . | Step one frame |
| Esc | Close review |

What to discard
Discard an episode if any of these happened:
- The stack failed, or a block was knocked over.
- The arm paused for a long time.
- The gripper re-grasped the block.
- The arm left the camera frame.
- The episode is partial.
When in doubt, discard it. You can always record more.
Create the sequence dataset
Collect every sequence tagged review:keep into a new sequence dataset named xarm-stacking-v1. Dataset names must be unique in your organization.
- On the DATA tab, click DATASETS.
- Click Create dataset.
- In the Dataset Name field, enter
xarm-stacking-v1. - Set Data type to Sequence Data, and click Create dataset again.
- Open the dataset and click Add Data.
- In the All sequences dialog, select the sequences tagged both
review:keepandtask:stack the red block on the green block, and click Add. Check both tags: a shared machine can hold kept sequences from other tasks, and Phase 7’s policy rollouts carry the same task tag. Leave out any sequence taggedsource:policy.

The dataset’s sidebar shows how many sequences it holds.
This path uses the Python SDK, so a script picks the sequences instead of you copying their IDs. It lists every sequence in your organization, keeps this machine’s demonstrations tagged review:keep for this task, skips policy rollouts, creates the dataset, and adds them. Save this as create_dataset.py:
import asyncio
import os
import sys
from viam.app.viam_client import ViamClient
from viam.proto.app.dataset import DatasetType
from viam.rpc.dial import DialOptions
TASK_TAG = "task:stack the red block on the green block"
async def main():
client = await ViamClient.create_from_dial_options(
DialOptions.with_api_key(
os.environ["VIAM_API_KEY"], os.environ["VIAM_API_KEY_ID"]
)
)
data = client.data_client
sequence_ids = []
page_token = None
while True:
sequences, page_token = await data.list_sequences(
organization_id=os.environ["VIAM_ORG_ID"], page_token=page_token
)
for s in sequences:
if s.part_id != os.environ["VIAM_PART_ID"]:
continue
tags = set(s.sequence_tags)
if {"review:keep", TASK_TAG} <= tags and "source:policy" not in tags:
sequence_ids.append(s.id)
if not page_token:
break
if not sequence_ids:
print("No sequences are tagged review:keep. Review some episodes first.")
client.close()
sys.exit(1)
dataset_id = await data.create_dataset(
name="xarm-stacking-v1",
organization_id=os.environ["VIAM_ORG_ID"],
type=DatasetType.DATASET_TYPE_SEQUENCE_DATA,
)
await data.add_sequences_to_dataset(
dataset_id=dataset_id, sequence_ids=sequence_ids
)
print(f"{dataset_id}: {len(sequence_ids)} sequences")
client.close()
asyncio.run(main())
To find your organization ID, your machine’s ID, and the ID of its main part, run:
viam organizations list
viam machines list --organization=<org-id> --all
viam machines part list --machine=<machine-id>
The script needs an organization API key. A key for a machine part isn’t enough. Create one:
viam organizations api-key create --org-id=<org-id> --name=xarm-stacking
Then export the IDs and the key for the script to read:
export VIAM_ORG_ID=<org-id>
export VIAM_PART_ID=<part-id>
export VIAM_API_KEY_ID=<api-key-id>
export VIAM_API_KEY=<api-key>
The script needs the Python SDK. Install it with pip install "viam-sdk>=0.83.1", then run it:
python create_dataset.py
Note the dataset ID it prints. You use it in the next section.
For more on sequence datasets, see Create a dataset.
Checkpoint
xarm-stacking-v1 exists, and its sequence count matches your keep count. Aim for at least 40 sequences.Sanity-check the export (optional)
Export the dataset to a local folder and confirm that it holds one sequence per kept episode. Use the dataset ID from the dataset page or the script:
viam dataset export \
--dataset-id=<dataset-id> \
--destination=./xarm-stacking-v1 \
--only-parquet
--only-parquet skips the images, so the export is small. It writes <dataset-id>.zip to the destination. sequences.parquet has one row per sequence. To count the rows, install pandas and pyarrow (pip install pandas pyarrow), then run:
python -c "import io, zipfile, pandas as pd; z = zipfile.ZipFile('xarm-stacking-v1/<dataset-id>.zip'); print(len(pd.read_parquet(io.BytesIO(z.read('sequences.parquet')))))"
The number should equal your keep count. For every column in the export, see Sequence datasets.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!