model-insights · YOLOv8s · COCO

Inside YOLOv8

A classifier answers "what is this photo of?". A detector answers "what is where?": it draws a box around every object it knows and names it. YOLOv8 does this in a single pass over the image, fast enough for video. It learned from COCO, 118,000 photos of everyday scenes with about 860,000 hand-drawn boxes in 80 categories. Nearly a third of those boxes are people.

Loading model weights…

1 One pass, three grids

The image is padded to 640×640. A backbone of convolutions and C2f blocks (stacks of small residual blocks whose outputs are all concatenated) shrinks it to 20×20. An SPPF block then max-pools that map at several sizes, so each cell sees a wider surrounding. A neck carries the coarse, semantic map back up and merges it with the finer maps from earlier in the backbone. The result is three grids: 80×80 cells of 8 pixels for small objects, 40×40 for medium ones and 20×20 for large ones, 8,400 cells in all.

Every cell makes a prediction: 80 class scores and a box. There are no predefined "anchor" box shapes. Each cell predicts how far the object's left, top, right and bottom edges are from its centre. Each distance is not a single number but a probability distribution over 16 steps (distribution focal loss), so the model can say "the edge is around here, but I'm not sure". Finally, overlapping boxes for the same class are thinned out (non-maximum suppression). Everything after the network runs in this page's JavaScript, so every step is visible. 11.2 million parameters.

Layer by layer

2 Detect and dissect

Pick, drop, paste or upload an image. Box colours show which grid produced each detection: 80×80, 40×40 or 20×20. Click a detection to see the four edge distributions behind its box, and the score maps of its class on all three grids.

drop / paste an image

Detections

    Where its edges might be (16-bin distance distributions, in grid cells)

    Class score on each grid

    Feature maps

    3 Residues of COCO

    A detector only knows its 80 categories, and it only knows them the way COCO's photographers and annotators saw them. Three ways to see that.

    What it dreams a class looks like

    Each image below was optimised to make one class score as high as possible in the middle of the image, on the 40×40 and 20×20 grids, starting from noise. Only the centre was asked for; everything around it is what the model added on its own.

    It finds people in another network's dreams

    The class visualisations of VGG16 (an ImageNet classifier, trained on different photos and never shown a box) are a good test of what YOLOv8 considers a person. At confidence ≥ 0.25, YOLOv8s finds people in four of them:

    Click one to run it through the detector above. The tench result supports the reading on the VGG page: ImageNet's tench photos are mostly anglers holding up their catch, so VGG16's tench comes with people attached, and YOLOv8 finds them.

    Plant an object

    Pick a class, then click anywhere on the photo in §2. Gradient ascent then changes the pixels around that point to raise the class score there, on all three grids. What appears is the model's idea of that object in this context. When it finishes, the result is run through the detector in §2 again.

    Two things to look for. First, what gets planted is mostly a bright, noisy texture, not a recognisable object: a detector can be convinced by patterns no person would accept. Second, what else it finds. We planted a cell phone on the coffee photo's saucer (100 steps). The detector then found the phones at 1.00, and also found people next to them at 0.65, 0.59, 0.50 and 0.42, though nobody asked for a person. In COCO, phones come with the hands that hold them.

    Click on the image in §2 to start.