Choose objects, label boxes, and split scenes
Prepare labels that describe what you want a detector to find, and keep evaluation images separate.
Label a scene and choose a split
This image is 320 pixels wide and 200 pixels high. The block spans x = 40 to 110 and y = 50 to 120. Use the questions below to check its label and decide how to split a capture session.
Opening the Python editor…
Requirements and learning goals
Before you start
- A browser with JavaScript
- No model, installation, or images required for this first lesson
You will be able to
- Convert pixel boxes to YOLO labels
- Distinguish training, validation, and test data
- Recognize leakage between capture sessions
Define what counts as an object
A detector learns from images paired with class labels and . Before training, decide what the classes mean. In our supplied project, a block is a filled square and a disk is a filled circle. Both vary in position, size, and color. An empty scene has no target object and therefore an empty label file. Allow about 15 minutes for this browser lesson.
For your own project, choose two visually distinguishable objects, such as a washer and a bolt. Write a rule for partly visible objects and apply it consistently. Do not label a shadow as an object or silently leave a visible target unmarked. A missing label can teach the model that a real object is background.
Work through a box
The example image is 320 pixels wide and 200 pixels high. The block extends from (40, 50) to (110, 120), measured from the image's top-left corner. Its center is (75, 85) and its width and height are both 70 pixels.
A label stores class_id center_x center_y width height. Divide horizontal values by image width and vertical values by image height. The resulting label is 0 0.234375 0.425 0.21875 0.35. These coordinates describe the full box; they are not confidence scores. A class ID starts at zero and must match the class list used for training.
Keep different jobs separate
Training images update the model. Validation images help you choose the model, threshold, and other settings. Test images are reserved for a final assessment after those choices are fixed.
Neighboring frames from one recording often have almost the same object, background, and lighting. Keep the whole capture session in one split. Also group near-duplicate shots together. Renaming or resizing a file does not make it an independent test example.
Try it
- Calculate the block's center and normalized width before selecting its label in the lab.
- Answer the capture-session question. Explain why alternating neighboring frames between training and test is misleading.
- Work out the disk's box yourself. Its center is
(220, 100)and its diameter is 50 pixels. Class 1 represents the disk.
Check the expected result
The block label is the one calculated above. The disk label is 1 0.6875 0.5 0.15625 0.25. Its width differs from its height after normalization because the image is not square.
You are done when you can explain why a model could score well on leaked test frames yet fail in a new room. The supplied training project generates separate images for each split, but they still share one simple rendering process. That is enough to practice the workflow, not to establish performance on real objects.
Troubleshooting
If the normalized center equals the top-left corner, calculate the midpoint before dividing. If a coordinate exceeds one, check that you used the right image dimension and did not mix pixels with normalized values. The following lesson supplies a runnable dataset and training script, so you do not need to gather photos before trying the workflow.
Reference: Ultralytics detection dataset format.
Before you move on
Can you do each of these?
- Convert pixel boxes to YOLO labels
- Distinguish training, validation, and test data
- Recognize leakage between capture sessions
0 of 2 checkpoints solved. Try checkpoint 1