Back to paper library
arXiv 2020Retail visionPaper notes

RP2K

95 Is a Failing Grade

Original paper

RP2K: A Large-Scale Retail Product Dataset for Fine-Grained Image Classification

Paper authors

Jingtian Peng · Chang Xiao · Yifan Li

Publication
Publication venue not yet verified
First submitted to arXiv
arXiv:2006.12634
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{retailproductrp2k2020,
  title = {{RP2K: A Large-Scale Retail Product Dataset for Fine-Grained Image Classification}},
  author = {Jingtian Peng and Chang Xiao and Yifan Li},
  year = {2020},
  eprint = {2006.12634},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.12634}
}
On this page

In an ordinary image classification task, 95% accuracy already looks great.

In supermarket shelf auditing, that number falls short. A shelf holds dozens of products; getting 1 in 20 wrong means several errors on every single shelf. If the mix-up is between a 500 mL and a 1.5 L bottle of cola, the prices differ several times over; if it's between two bottles of shampoo from the same brand, the restocking list goes wrong with it.

That's what the RP2K paper says right at the start. The authors are from Pinlan, a Chinese retail data company, and Columbia University. They collected a dataset of shelf products with far more product classes than any public dataset at the time, hoping to give fine-grained retail product classification a benchmark that is big enough and real enough.

Problem Definition

Original Figure 1: three rows of examples. (a) Different sizes from the same product line, such as Pepsi, Head & Shoulders shampoo, soy sauce or cooking oil in different sizes, which look almost identical, except that the photos don't show their actual size. (b) Different flavors or scents from the same series, such as Liushen shower gel, Syoss shampoo, OMO laundry liquid and bagged pickles, which differ only in a few words on the label or in color. (c) The same product photographed from different angles because of where it sits on the shelf, with its shape sometimes stretched by the lens.
Original Figure 1, Peng et al., from PDF page 1, arXiv license, scholarly quotation.

The authors use this figure to show what makes recognizing products on shelves hard.

The first row is different sizes from the same product line. The photos are cropped from shelves, and how big a crop is has little to do with how big the product is; four bottles of Pepsi just look like four bottles of Pepsi, and the model has to guess the size from proportions and details of the bottle.

The second row is different flavors from the same series. When a manufacturer launches a new flavor, it usually changes only a few words on the label or swaps a color, keeping the overall design the same so shoppers recognize the brand at a glance. Good for shoppers, a nightmare for classifiers.

The third row is the shooting angle. A product on a high or low shelf gets photographed from a different angle, and phone-lens distortion stretches products out as well.

The retail datasets of the time all had limitations. RPC and MVTec D2S are shot in a lab, with clean backgrounds and even lighting; GroZi-120 has only 120 classes; SKU-110K is large, but has only boxes, and every product belongs to the same class. What the authors wanted was a dataset shot in real stores with enough classes.

Dataset

How It Was Collected

Original Figure 3: the RP2K data collection pipeline, four steps from left to right. The first image is a raw shelf photo, a whole shelf of drinks; the second is the result of machine pre-annotation, with a box on every product; the third step is manually deleting unusable crops, such as occluded ones or ones that aren't products; the fourth step is manually labeling the remaining images, such as Spring Water A (500mL), Coke A (1000mL), Coke B (150mL) and Coke B (500mL).
Original Figure 3, Peng et al., from PDF page 3, arXiv license, scholarly quotation.

The collectors covered 10 cities and 500 stores, photographing shelves with phones under the stores' natural lighting. The rules were one shelf per photo, the shelf centered in the frame, and at least 80×80 pixels per product, clear enough for the human eye.

The photos first went through a RetinaNet that recognizes only seven shapes: bottle, can, box, bag, jar, handled bottle and pack. The detector boxed every possible product, then annotators deleted boxes that overlapped, were occluded or covered empty space, added the ones that were missed, and finally labeled each box with an SKU ID and attributes.

The attributes go well beyond the SKU ID, covering brand, category, shape, size and flavor or scent. You can see it in the rightmost column of Figure 3, where even for cola, brand A 1,000 mL, brand B 150 mL and brand B 500 mL are all labeled separately.

Scale

The final numbers are 10,385 shelf photos with an average of 37 products each, cropped into 384,311 single-product images across 2,388 SKUs, about 161 images per SKU on average.

The 2,388 SKUs are grouped two ways. By category, there are 7 groups: dairy, liquor, beer, cosmetics, non-alcoholic drinks, seasoning and tobacco; by shape, there are also 7. The category grouping has practical use, because a single shelf usually holds products of only one category.

The distribution is uneven. Seasoning has 560 SKUs and 150,000 images; cosmetics has only 256 SKUs and 8,325 images, an average of just 32 images per SKU.

There's also an auxiliary detection dataset, with 95,800 boxes annotated on 1,400 shelf photos, split only into the seven shapes. The authors themselves say plenty of datasets already cover detection, so this part comes as an extra.

Discussion

Fine-Grained Methods Didn't Pull Ahead

The authors tested four classification methods, each picking one answer out of 2,388 classes. Two are standard classification networks, ResNet-34 and InceptionV3; the other two are fine-grained classification methods of the time, class-balanced loss (CBL) and API-Net, both with a ResNet-34 backbone and the original papers' default settings.

CategoryResNet-34InceptionV3CBLAPI-Net
Dairy93.6893.3883.9054.30
Liquor76.9979.5761.8896.47
Beer96.7695.1990.5297.79
Cosmetics87.8786.5850.7593.88
Non-alcoholic drinks94.8693.6580.5296.91
Seasoning97.9697.2893.4498.71
Tobacco91.8991.7378.4193.15
All95.1894.6987.6695.34

Source: Table 2 of the paper, top-1 accuracy (%).

The abstract says that "even state-of-the-art fine-grained classification methods did not outperform a simple ResNet baseline". Checked against the table, CBL does fall well behind, at only 87.66% overall and 50.75% on cosmetics. API-Net is more complicated. Its overall top-1 is 95.34%, actually a little above ResNet-34's 95.18%, and on liquor and cosmetics, the two hardest categories, it leads by a wide margin: 96.47% vs 76.99% on liquor.

Yet API-Net gets only 54.30% on dairy, nearly 40 points below the two standard classification networks and almost 30 below CBL, and dairy has the second-largest number of images of any category. A method that wins big on the hardest categories and loses big on an ordinary one looks more like something went wrong in training, and the paper doesn't explain this number.

The safer conclusion is that on this dataset, switching to fine-grained methods brought no clear overall improvement, and the hardest categories are still liquor and cosmetics, which have few images and look alike.

Data Augmentation Made It Worse

The authors originally expected that, with angles and lighting varying so much across photos, data augmentation would help. They designed four augmentations close to real conditions: a random border of 0 to 30 pixels, random crops of up to 10 pixels, random perspective transforms, and brightness adjustments of ±20%.

TrainingTop-1Top-5
From scratch95.1899.01
ImageNet pretrained95.5499.04
From scratch + aug.90.4194.74
Pretrained + aug.90.8995.01

Source: Table 3 of the paper, ResNet-34.

With augmentation, accuracy drops by nearly 5 points. ImageNet pretraining helps very little too, adding only 0.36 points.

The paper doesn't analyze why. One possible explanation is that the training and test sets were split randomly 9 to 1 from the same batch of shelf photos, and the paper doesn't say whether the split was made per whole shelf photo. If identical products standing side by side in the same photo show up in both training and test, the test images are already very similar to the training images, and the variation from augmentation turns into noise instead. This is our speculation; the paper doesn't give enough information to confirm it.

The Long Tail

Original Figure 7: the horizontal axis is the product class index sorted by instance count from most to fewest; the blue bars are the number of images per class, close to 4,000 at the far left, falling to a few hundred around index 500 and approaching zero after that; the red line is the average top-1 accuracy of every 10 adjacent classes, mostly above 90% in the front part, getting lower and more erratic further right, with a few groups at the far right dropping below 40%.
Original Figure 7, Peng et al., from PDF page 6, arXiv license, scholarly quotation.

The authors sorted the 2,388 products by image count and computed the average accuracy for every group of 10. At the end with many images, accuracy holds steady above 90%; further right, with fewer images, accuracy gets lower and swings up and down more.

The overall 95% is propped up by the mass of popular products. More than a hundred classes have fewer than 30 images, and they're where things go wrong in actual deployment. New products, seasonal editions and items stocked in small quantities at a supermarket all sit right on this tail.

Adversarial Attacks

The paper also includes an adversarial attack experiment. ResNet-34 gets 95.18% on clean test images; with a PGD perturbation of ϵ=4/255\epsilon = 4/255, accuracy drops straight to zero.

After adversarial training, clean accuracy falls to 40.14%, and adversarial accuracy recovers only to 12.35%. Training with ϵ\epsilon raised to 8/255 leaves clean accuracy at 20.90%. The authors' view is that differences between retail product classes are small to begin with, so they're easier to push across the boundary with perturbations than CIFAR-10 or ImageNet, and harder to defend.

Can You Get It?

The body of the paper gives no download link. The dataset archive sits on Huawei Cloud object storage, with the bucket name blob-nips2020-rp2k-dataset in the URL, and it can still be accessed today.

Conclusion

RP2K's contribution is the data itself, 2,388 SKUs and 380,000 single-product images shot in real stores, plus attributes like size, flavor and brand. It moved retail product recognition from the lab turntable to the shelf, and raised the number of classes from the hundreds to the thousands.

The experiments are thinner. On whether fine-grained methods help, the table and the text don't fully agree; why data augmentation costs 5 points of accuracy goes unexplained. The long-tail figure, though, makes it very clear that 95% overall accuracy hides more than a hundred classes with only a few dozen images each.

Before using RP2K as a benchmark, first make sure products cut from the same shelf photo don't land in both training and test. And when you report numbers, list the long-tail part alongside them.