Back to paper library
arXiv 2021ICCV 2021Retail visionPaper notes

Product1M

What's in the Set?

Original paper

Product1M: Towards Weakly Supervised Instance-Level Product Retrieval via Cross-modal Pretraining

Paper authors

Xunlin Zhan · Yangxin Wu · Xiao Dong …

Show all 8 authors

Xunlin Zhan · Yangxin Wu · Xiao Dong · Yunchao Wei · Minlong Lu · Yichi Zhang · Hang Xu · Xiaodan Liang

Publication
ICCV 2021Conference
First submitted to arXiv
arXiv:2107.14572
Cite this paper · BibTeX

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

@misc{retailproductproduct1m2021,
  title = {{Product1M: Towards Weakly Supervised Instance-Level Product Retrieval via Cross-modal Pretraining}},
  author = {Xunlin Zhan and Yangxin Wu and Xiao Dong and Yunchao Wei and Minlong Lu and Yichi Zhang and Hang Xu and Xiaodan Liang},
  year = {2021},
  eprint = {2107.14572},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.14572}
}
On this page

Anyone who has shopped online has seen this kind of product page. One image lays out a cleanser, a toner, a serum and a cream, and the title reads "SK-II Fairy Water Four-Piece Set."

If you want to compare prices, or find out what the cream in this set costs on its own, you first have to recognize what each product in the image is, then look each one up in the catalog of single items.

Product retrieval at the time mostly didn't work this way. The common setups were using a single-item image to find the identical item, or searching images with text and text with images. One image gets one answer, so when an image holds several products, the results are easily taken over by the most prominent one.

Authors from Sun Yat-sen University, Beijing Jiaotong University, Alibaba and Huawei Noah's Ark Lab defined this problem as multimodal, instance-level product retrieval, and collected a million-scale cosmetics dataset called Product1M.

Defining the problem

Original Figure 1. The top half, (a), is image-level retrieval: the query is a product image of the SK-II four-piece set, and what comes back is another, nearly identical four-piece-set image. The bottom half, (b), is multimodal instance-level retrieval: the query is the same four-piece-set image plus the title "SK-II Fairy Water Facial Cream Cleanser Clear Lotion Four-piece Set," and what comes back is three single items, the Fairy Water, an amino-acid cleanser and a facial cream, each with its own product title.
Original Figure 1, Zhan et al., from PDF page 1, CC BY 4.0.

In this task, each sample pairs product images with a product title. A query is a multi-product sample; the database (the paper calls it the gallery) holds single-product samples. The model has to find every single item that appears in the query from the gallery, and rank them.

The authors stress two things. First, both the queries and the gallery have images and text side by side, and both images and titles can be used. Second, the training data has no annotation, only the images and titles already on the e-commerce site.

Product1M

The data comes from 49 cosmetics brands on an e-commerce site, and the authors first split the samples into single-product and multi-product ones based on the product information.

SplitSamplesContents
Training1,132,830Single and multi-product, no class labels
Validation2,673Multi-product only, labeled
Test6,547Multi-product only, labeled
gallery40,033Single products, 458 classes

Of the gallery's 458 classes, 392 appear in the validation and test sets; the other 66 are distractors, there to see whether a retrieval system gets lured away by irrelevant products.

Original Figure 2. Characteristics and statistics of Product1M. (1a) Multi-product combinations, such as a Lancôme Christmas eight-piece set and a Lancôme "small black bottle" set; (1b) weak supervision and fuzzy correspondence, such as a title reading "skii travel four-piece water + mask," or a title mentioning "fairy water" that isn't in the image; (1c) real-world difficulties, with nearly identical day and night creams and a cluttered background at the top, watermarks and occlusion at the bottom. On the right, (2a) and (2b) are the class distributions of the validation/test sets and of the gallery, with a red line sorted by sample count that shows a long tail.
Original Figure 2, Zhan et al., from PDF page 3, CC BY 4.0.

The dataset is hard in several ways.

The combinations are complex. One set image may hold seven or eight products, and the same product shows up in many different sets.

Titles often don't help. Some just say "eight-piece set" without saying which eight; some mention products that aren't in the image at all, or the other way around.

Fine-grained classification is hard. A brand's day cream and night cream come in nearly identical jars, differing only by a few words on the packaging. E-commerce images also carry watermarks, promotional text and cluttered backgrounds.

The class distribution is long-tailed too, with a few popular products taking up a large share of the samples.

Solving the problem

Original Figure 3. The overall pipeline. (a) Single-product images first get a foreground mask from GrabCut and are pasted onto real backgrounds such as bathrooms, synthesizing multi-product images with pseudo boxes that are used to train a ResNet-50-FPN RPN. (b) CAPTURE, from bottom to top: embedding layers for text and image, a separate Text Transformer and Visual Transformer (repeated L times, with a cross-modal contrastive loss attached), Text and Visual Cross-Transformers that exchange keys and values (repeated K times), a Text-Visual Co-Transformer over the concatenated modalities (repeated H times), and at the very top masked language modeling and masked region prediction. (c) The positive pairs for contrastive learning are the image and title of the same sample.
Original Figure 3, Zhan et al., from PDF page 4, CC BY 4.0.

Box the products first

Instance-level retrieval first needs to know how many products are in the image and where each one is. Off-the-shelf detectors are trained on natural images and do poorly on product images, and this dataset has no box annotations.

The authors' solution is to synthesize their own training data. Single-product images have plain backgrounds, so GrabCut cuts the product out, and it's pasted at random onto scene photos from Places365, with every pasted product carrying its own box. A ResNet-50-FPN RPN trained on these synthetic images can then produce product proposals on real multi-product images, and RoIAlign extracts the features of each box.

CAPTURE

The multimodal model that follows is called CAPTURE. The authors mix together the two mainstream architectures of the time.

One is the two-stream architecture, like ViLBERT and LXMERT, where image and text each go through their own encoder and then exchange information. The other is the single-stream architecture, like VisualBERT and UNITER, where image and text tokens are concatenated from the start and fed into a single Transformer.

CAPTURE stacks three kinds of layers from the bottom up, 4 of each, 12 in total:

  1. Text Transformer and Visual Transformer: each processes text or image regions on its own, looking only at its own modality.
  2. Cross-Transformer: the two sides hand their keys and values to each other, so text looks at the image and the image looks at the text.
  3. Co-Transformer: the features of both modalities are concatenated and go through self-attention together.

The authors call this a hybrid-stream architecture. The text side is initialized from BERT, with a hidden size of 768.

No ITM, contrastive learning instead

The pretraining tasks follow the masked modeling of BERT and VisualBERT. About 15% of the words and regions are masked; for text the model predicts the masked words, and for regions it directly regresses the original features extracted by the RPN.

Multimodal pretraining at the time almost always added an image-text matching task (ITM), which randomly swaps out the image or the title and has the model judge whether the two are a pair. The authors consider this harmful for instance-level tasks. Once images and titles are paired at random, the detected boxes no longer match the text, which only gets in the way of the model learning "which box is which product."

The authors switch to a cross-modal contrastive loss instead. Within a batch, the image and title of the same sample form a positive pair and every other pairing is a negative, using InfoNCE:

L(xi,xj)=−log⁡esij∑k≠iesik\mathcal{L}(x_i, x_j) = -\log \frac{e^{s_{ij}}}{\sum_{k \neq i} e^{s_{ik}}}

sijs_{ij} is the cosine similarity of the two representations divided by the temperature τ\tau, the denominator sums over all of the 2N2N data points in the batch except the sample itself, and the temperature τ\tau is set to 0.07. The loss is attached to the bottom Text/Visual Transformer; the authors say attaching it to deeper layers doesn't help much.

At retrieval time, the image and text representations output by the Co-Transformer are multiplied, so are the image and text representations from the Text/Visual Transformer, and the two are concatenated into a 1024-dimensional feature that is ranked by cosine similarity against every single item in the gallery.

Discussion

Evaluation uses mAP@N, mAR@N and Prec@N, with NN set to 10, 50 and 100. All baselines use the same RPN trained on synthetic data, and their hidden sizes are all set to 768 too.

MethodmAP@10mAR@10Prec@10
Image only40.3517.2032.80
Text only61.5623.6556.15
CLIP*70.2529.4567.77
UNITER74.6929.4770.11
CAPTURE79.3634.6973.97

Text alone beats image alone by 21 points in mAP@10. Messy as the titles often are, they still carry far more information than a pile of look-alike bottles and jars. Models that use image and text together are another 9 to 18 points better than text alone.

CLIP* here is a two-tower model the authors built the CLIP way, encoding image and text with one Transformer each and training with a contrastive loss, with the same RPN box features as input. The two-stream ViLBERT and LXMERT, along with CLIP*, do worse overall than the single-stream models, from which the authors conclude that the way the modalities are fused is the key.

Ablations

On pretraining tasks, adding ITM on top of masked modeling drops mAP@100 from 72.1 to 70.2, supporting the authors' judgment. Adding the contrastive loss brings it to 73.3, and concatenating the bottom-layer features into the retrieval feature brings it to 74.6.

On the layer configuration, removing any one kind of layer while keeping the total depth at 12 lowers performance; removing the bottom Text/Visual Transformer hurts the most, leaving only 69.3. A large model with 8 of each, 24 layers in total, scores 74.7, almost the same as 4 of each.

The detector's effect is more direct:

Input boxesmAP@100mAR@100
Whole image as one box60.0320.43
Detector pretrained on Visual Genome70.3626.46
Synthetic-data RPN74.6330.08
Synthetic-data RPN (same subset)73.3630.44
Hand-labeled boxes (1,338-image subset)77.7937.40

Treating the whole image as one product costs nearly 15 points; switching to a detector pretrained on natural images still loses 4. The last two rows count only the 1,338 images on which the authors additionally hand-labeled boxes. On that same subset, the synthetic RPN's mAR is 30.44, and the labeled boxes take it straight to 37.40. A product the detector misses can't be retrieved, and the detector is the bottleneck of this pipeline.

The authors also tested zero-shot settings, removing 5, 10 or 20 brands from the training set and then testing on those brands' products. With 5 brands removed, CAPTURE's mAP@10 is 67.1, 2.6 above UNITER; with 20 brands removed, it falls to 44.4, only 1.1 above UNITER's 43.3.

Reproduction and follow-up

The dataset is public on Google Drive, with each sample carrying two URLs that point to the same image; the Alibaba Cloud one can no longer be accessed, so only the other one works.

As for the code, the evaluation script was added only after someone asked for it in an issue, and on the very day it went up, someone pointed out that the AP calculation was wrong; the authors fixed it the same day. The starting point of the whole pipeline, the RPN trained on synthetic data, drew three issues between 2022 and 2024 asking for its weights or how to train it, and none of them got a response; the same goes for the one asking for CAPTURE's pretrained weights. In other words, to reproduce the paper's numbers, you first have to rebuild the detector yourself, starting from GrabCut.

An issue from April 2022 is more interesting still. Someone took ViT-B/16 plus BERT, trained only with a contrastive loss the CLIP way, fed in whole images without cropping any boxes, and measured an mAP@10 of 87.7 with the official evaluation script, 17 points above the paper's CLIP* and 8 points above CAPTURE's 79.36. The two differ in pretrained backbones and inputs, so they can't be equated directly; yet in the paper's ablation, "whole image as one box" is the worst setting of all. The issue asks the authors where the difference comes from, and it still has no reply.

Conclusion

Product1M turns the gift-set images so common in e-commerce into a clearly defined retrieval task. The query is a multi-product sample with image and text, the answer is the individual items in the gallery, and the training data is over a million real product pages with no annotation and titles all over the place.

CAPTURE is designed around this setup, with a product-box detector trained on synthetic data, a hybrid-stream Transformer that fuses image and text, and contrastive learning in place of ITM, which manufactures mismatches. The ablations support these choices and also honestly point to the detector as the biggest bottleneck.

But that 87.7 issue is still hanging there. A better-pretrained two-tower model, without even cropping boxes, can push the score higher, and how much CAPTURE's carefully designed region features and three-stage Transformer are really worth on this dataset is a question the authors haven't answered.