Back to paper library
arXiv 2022ECCV 2022Retail visionPaper notes

Unitail

Look Closely Before You Buy

Original paper

Unitail: Detecting, Reading, and Matching in Retail Scene

Paper authors

Fangyi Chen · Han Zhang · Zaiwang Li …

Show all 10 authors

Fangyi Chen · Han Zhang · Zaiwang Li · Jiachen Dou · Shentong Mo · Hao Chen · Yongxin Zhang · Uzair Ahmed · Chenchen Zhu · Marios Savvides

Publication
ECCV 2022Conference
First submitted to arXiv
arXiv:2204.00298
Cite this paper · BibTeX

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

@misc{retailproductunitail2022,
  title = {{Unitail: Detecting, Reading, and Matching in Retail Scene}},
  author = {Fangyi Chen and Han Zhang and Zaiwang Li and Jiachen Dou and Shentong Mo and Hao Chen and Yongxin Zhang and Uzair Ahmed and Chenchen Zhu and Marios Savvides},
  year = {2022},
  eprint = {2204.00298},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.00298}
}
On this page

When you pick a flavor at the ice-cream freezer, you don't decide at a glance.

First you look and recognize the brand; then you lean in to read the words on the package: vanilla, chocolate, matcha, how many calories, how big. Packages from the same brand look almost identical, and what really tells them apart is those few words.

This paper from Carnegie Mellon University starts from exactly this observation. The authors argue that product recognition in retail scenes has overlooked two things. One is the box: products are placed tilted and crowded, and rectangular boxes don't fit them well. The other is text: look-alike products can only be told apart by the words on their packaging, yet no dataset at the time labeled the text on products.

They turned these two things into a benchmark and named it Unitail (United Retail Datasets).

Problem Definition

Original Fig. 1: what makes up Unitail. The top row shows the two sub-datasets: on the left, Unitail-Det is a series of shelf photos with every product enclosed by a green quadrilateral; on the right, Unitail-OCR is a pile of cropped product images, with one pack of Huggies diapers enlarged. The bottom row shows four tasks: product detection, text detection, text recognition and product matching. The text recognition example is two packs of Pull-Ups training pants whose recognized words are both pullups, fun, fast and easy, differing only in 3T4T versus 4T5T and in the barcode digits below.
Original Fig. 1, Chen et al., from PDF page 3, CC BY 4.0.

The two packs of Pull-Ups in the bottom right illustrate the second problem. Both packs share the same design and mostly the same words, differing only in 3T4T versus 4T5T, that is, the size they fit. A classifier that looks only at appearance would struggle to tell these two packs apart; read those four characters and you can.

The authors sum up product recognition in retail scenes (scene product recognition) with four traits: dense placement, few samples per class, subtle differences between classes, and a large number of classes. The last two together mean there are many products that "look alike and differ only in their text".

The first problem has to do with SKU-110K. SKU-110K follows COCO and encloses each product in a horizontal rectangle. But shelf photos are often taken at an angle, with products packed one against the next, so a horizontal box catches a corner of the neighboring product, boxes overlap heavily, and NMS easily deletes the right box. If the box is off, the cropped product image comes out all askew, and the recognition downstream suffers with it.

The Dataset

Unitail-Det: Switching to Quadrilaterals

Original Fig. 2: a bag of snacks lying at an angle on a shelf. The purple horizontal box and the red rotated box both take in plenty of background and neighboring products, while the green quadrilateral hugs the four corners of the product's front face. On the right, the results of rotating the rotated box's contents upright and perspective-rectifying the quadrilateral's contents; the rectified quadrilateral gives a squared-up front view of the product.
Original Fig. 2, Chen et al., from PDF page 6, CC BY 4.0.

Unitail-Det encloses products with arbitrary quadrilaterals: four points, eight degrees of freedom. The rule is to enclose the front face of the product. For box-shaped and cylindrical products, the four points are the four corners of the front face; for spherical, conical or irregular ones, a horizontal box is drawn first and its four corners are then adjusted to the perspective of the shot; the side is boxed only when the front can't be seen.

The benefit shows in the two small images on the right. A rotated box turned upright is still skewed and still carries background; a quadrilateral, rectified with a perspective transform, gives a squared-up front view of the product, so the same product cropped from different photos looks more consistent.

The images come in two parts. The origin domain reuses SKU-110K's 11,744 photos, relabeled with quadrilaterals; the cross domain is 500 extra photos taken in other stores, with different devices and from different angles, containing unseen product categories. There are 1.77 million quadrilaterals in total, checked in three rounds by 13 annotators.

The main evaluation metric is an interesting choice. The authors use the geometric mean of the origin-domain and cross-domain mAPs (g-mAP) rather than the arithmetic mean. The geometric mean is more sensitive when one of the two is especially low: a model that does well on the origin domain and badly on the cross domain gets its g-mAP dragged down, which penalizes models that just memorize the training stores.

Unitail-OCR: The Text on Products

Unitail-OCR's images are cropped from the cross-domain photos and rectified according to their quadrilaterals. There are 4,466 products and 29,681 text boxes in total; the 20,981 that are legible all have their text transcribed, English letters and digits only, case-insensitive, with a number plus unit like 120mg counted as one word. A vocabulary list is also provided, since stores usually know in advance which products they sell and what words appear on the packaging.

It supports three tasks. Text detection and text recognition are standard OCR tasks; the third is product matching. In the matching setup, a gallery holds 1,454 product classes with just one image per class, and the queries are separately photographed products; the task is to find which gallery class each one belongs to. There are 10,000 queries, of which 2.4k are hard cases that look alike even to the human eye.

Solution

The authors build a baseline for each of the two new tasks.

RetailDet, a Quadrilateral Detector

RetailDet is an anchor-free detector with an architecture similar to FCOS: every pixel directly regresses the four corners of a quadrilateral, 8 numbers in all. The authors change two things in training.

The first is centerness. FCOS scores every pixel with centerness: the closer to the center of the box, the higher the score, and pixels too far from the center usually predict inaccurate boxes. But where is the center of a quadrilateral? If it is computed the way it is for a horizontal box, the center may be far from one of the corners, and that corner becomes hard to regress.

The authors use the quadrilateral's centroid as the center instead, and for each pixel compare its distances and the centroid's distances to the left, right, top and bottom edges:

CQUAD(p)=[∏k∈{l,r,t,b}min⁡(dpk,dgk)max⁡(dpk,dgk)]0.5C_{QUAD}(p) = \left[\prod_{k \in \{l, r, t, b\}} \frac{\min(d_p^k, d_g^k)}{\max(d_p^k, d_g^k)}\right]^{0.5}

dpkd_p^k is the pixel's distance to an edge, and dgkd_g^k is the centroid's distance to the same edge. A pixel exactly on the centroid gets 1 for all four ratios; the further it is from the centroid, the lower the score. Applied to a horizontal box, this formula is equivalent to FCOS's original centerness.

The second is which level of the feature pyramid an object is assigned to. Assigning by size is fast, but each object goes to only one level; Soft Selection assigns an object to several levels and reweights them, which works better, but needs an auxiliary network and is 5 times slower on shelves with hundreds of products per image.

The authors observe that the weights Soft Selection learns essentially still follow object size, so they imitate it directly with a formula called Soft Scale. Let the object's area be AA and s=log⁡2(A/224)s = \log_2(\sqrt{A} / 224); the object is assigned to two adjacent levels:

li=⌈5+s⌉,Fli=s−⌊s⌋lj=⌊5+s⌋,Flj=1−Fli\begin{aligned} l_i &= \lceil 5 + s \rceil, & F_{l_i} &= s - \lfloor s \rfloor \\ l_j &= \lfloor 5 + s \rfloor, & F_{l_j} &= 1 - F_{l_i} \end{aligned}

224 is the ImageNet pretraining input size, and an object exactly 224 on a side goes to level 5 only. For a product 160 pixels on a side, s=log⁡2(160/224)≈−0.485s = \log_2(160/224) \approx -0.485, so li=⌈4.515⌉=5l_i = \lceil 4.515 \rceil = 5 and lj=4l_j = 4; the weights are F5=−0.485+1=0.515F_5 = -0.485 + 1 = 0.515 and F4=0.485F_4 = 0.485. This product trains on both level 5 and level 4, with each level's loss multiplied by roughly half the weight.

Matching with the Help of Text

Original Fig. 6: two pipelines for matching products with text, both using a tub of Häagen-Dazs chocolate ice cream as the example. (a) A text detector finds the text boxes and a text recognizer reads five words, haagen, d, chocolate, ice and cre4w; haagen, d and cre4w are marked with crosses, the brand name split in two and cream misread as well; these words go into BERT to get a vector, whose cosine similarity is computed with the vector of the gallery image. (b) The text recognizer's intermediate features are used instead, each with a 2D positional encoding computed from its text box's position added; the Hungarian algorithm finds the best pairing between the query's 5 features and the gallery's 4, and the summed similarity of the pairs is the text similarity.
Original Fig. 6, Chen et al., from PDF page 11, CC BY 4.0.

The matching baseline imitates what people do: look at the appearance first, and read the text if the appearance doesn't settle it. An image classifier computes the appearance similarity between the query and every gallery product; if the first and second place are too close, the text similarity is also computed, and the two are added with weights to decide the answer.

How do you compute text similarity? The intuitive way is (a): string together the words OCR reads out and feed them to BERT to get a vector. But OCR makes mistakes. In the figure, cream is read as cre4w, and once a typo goes into BERT it becomes a completely different vector; the position of the words on the package is lost as well.

The authors' approach is (b). Instead of the words read out, they use the feature vectors inside the text recognizer, because the features of cre4w should still retain some of the information about the A and the M; each feature also gets a 2D positional encoding computed from its text box's position. Since two products may yield different numbers of words, the Hungarian algorithm finds the best one-to-one pairing, and the cosine similarities of the paired features are summed.

Discussion

Quadrilateral Detection

Methodg-mAPOrigin mAPCross mAP
DBNet45.351.040.3
Gliding Vertex46.052.340.5
Mask R-CNN52.457.348.0
RetailDet (ResNet-50)54.758.750.9
RetailDet (ResNet-101)57.160.354.1

Source: Table 1 of the paper, excerpt.

Most of the comparison methods come from text detection and aerial detection, because those two fields have long dealt with quadrilaterals. Every method drops 6 to 12 points on the cross-domain test set, so the differences between stores are real. RetailDet is the best on both the origin and the cross domain.

The authors also added a box refinement module to RetailDet and compared it on the original SKU-110K, where it reaches an mAP of 59.0, higher than every other method at the time. With the same training images, trained on quadrilateral annotations and tested on the Unitail-Det origin domain, the mAP is 61.3; the authors argue that quadrilaterals simply fit products better than horizontal boxes, so regression goes more smoothly, boxes overlap less, and NMS has an easier job.

The Text on Products

Ordinary OCR models don't do well on products. The text on product packaging is often stylized lettering, with distorted shapes and flashy colors.

DBNet trained on synthetic data and ICDAR2015 gets a text detection hmean of 0.666 on Unitail; trained on Unitail, 0.819. Text recognition is the same: the best, ABINet, improves from 69.2% to 77.2%. Every model does better after training on Unitail, which shows a clear domain gap between product text and general scene text.

How Much Can Text Alone Recognize?

SettingHard setGeneral set
Text only (BERT)—30.37
Text only (pos. enc. + Hungarian)31.7147.81
ResNet-10158.3785.03
ResNet-101 + text60.5286.19

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

Using text alone, without looking at appearance at all, already recognizes nearly half the products in the general set. The authors' method beats using BERT directly by 17 points, so keeping the recognizer's intermediate features and the text positions really does help.

Adding text to the visual classifier gains 2.15 points on the hard set and 1.16 on the general set. The larger gain on the hard set fits the intuition that "text only comes into play when appearance can't tell them apart".

The gains are small, though. As the authors point out, the pipeline is staged, and each stage's errors pass on to the next. Text detection recall is only 0.773 and text recognition accuracy 0.772; multiplied together, only about sixty percent of the words get read correctly (our estimate). On top of that, 2% of products have no text at all.

Conclusion

Unitail turns two things peculiar to retail scenes into measurable benchmarks. Quadrilateral detection annotations make boxes fit products more closely and crops more consistent, and the geometric mean of origin and cross domain forces models to face the reality that they get worse in a different store. The text on products gets hand annotations for the first time, usable both for training OCR and for matching.

Both baselines are still simple. RetailDet changes the centerness and level assignment of FCOS; text matching is a staged pipeline whose gains are only a point or two. The paper's more important contribution is defining the problem. Look-alike products can only be told apart by reading their text, and in 2022 almost nobody had worked on that.

On the shelves of a pharmacy, a cosmetics store or a baby-goods aisle, where products from the same line stand side by side, what you run into every day is probably exactly the kind of case in Unitail's hard set that differs by just four characters.