Improving filling level classification with adversarial training

Apostolos Modas, Alessio Xompero, Ricardo Sanchez-Matilla, Pascal Frossard, Andrea CavallaroICIP 2021

Abstract

We investigate the problem of classifying—from a single image—the level of content in a cup or a drinking glass. This problem is made challenging by several ambiguities caused by transparencies, shape variations and partial occlusions, and by the availability of only small training datasets. In this paper, we tackle this problem with an appropriate strategy for transfer learning. Specifically, we use adversarial training in a generic source dataset and then refine the training with a task-specific dataset. We also discuss and experimentally evaluate several training strategies and their combination on a range of container types of the CORSMAL Containers Manipulation dataset. We show that transfer learning with adversarial training in the source domain consistently improves the classification accuracy on the test set and limits the overfitting of the classifier to specific features of the training data.

Introduction

For a robotic assistant to successfully perform tasks like pouring a beverage or handing a beverage to a human, it must accurately estimate the filling level of a container. However, estimating this level from a single RGB image is a significant computer vision challenge. Containers are frequently transparent or translucent, liquids can range from clear water to opaque grains like rice, and the container itself is often partially occluded by the hand holding it.

Because task-specific datasets for this problem are typically small, researchers often rely on transfer learning—pre-training a Convolutional Neural Network (CNN) on a massive dataset like ImageNet before fine-tuning it on container images. Despite this, standard transfer learning often fails to generalize; the network tends to memorize the specific shapes or textures of the few containers in the training set, leading to poor performance when encountering novel container types, such as a champagne flute or a uniquely colored cup.

Methodology

This study frames filling level estimation as a classification task with four categories: 0%, 50%, 90%, and an "unknown" category for opaque containers where the level is visually obscured. The researchers utilized a ResNet-18 architecture as the backbone for their experiments.

To mitigate overfitting, the authors introduced Adversarial Training (AT) into the transfer learning pipeline. While AT is traditionally used to defend against malicious attacks by training on images with $L_2$-PGD perturbations, this work utilizes AT as a "feature filter." By forcing the network to ignore brittle, high-frequency noise during pre-training, the model is encouraged to learn more robust and generalizable features.

The study compared six distinct training strategies:

  1. ST: Standard Training on the target dataset.
  2. AT: Adversarial Training on the target dataset.
  3. ST→FT: Standard pre-training on ImageNet followed by standard fine-tuning on the target.
  4. AT→FT: Adversarial pre-training on ImageNet followed by standard fine-tuning on the target.
  5. ST→AFT: Standard pre-training on ImageNet followed by adversarial fine-tuning on the target.
  6. AT→AFT: Adversarial pre-training on ImageNet followed by adversarial fine-tuning on the target.

Experimental Design

Experiments were conducted using two primary datasets:

  • Source Dataset: ImageNet (for pre-training).
  • Target Dataset (C-CCM): A curated subset of the CORSMAL Containers Manipulation (CCM) dataset, consisting of 10,269 cropped frames featuring four cups and four drinking glasses.

To rigorously evaluate shape generalization, the authors established three specific train/test splits (S1, S2, S3). These splits were designed to ensure the test set contained container shapes or properties not present in the training set. For instance, one split tested the model exclusively on a champagne flute—a shape with a narrow base—after training only on wider-based containers.

Results and Discussion

The experimental results highlight AT→FT as the superior strategy. Adversarially pre-training on ImageNet followed by standard fine-tuning consistently outperformed all other methods, particularly in scenarios involving unseen container shapes.

Generalization to Novel Shapes

In split S1, which tested the model on a champagne flute, standard training (ST) achieved only ~46% accuracy. The AT→FT strategy improved this performance by approximately 30 percentage points. Similarly, in split S3, standard transfer learning (ST→FT) struggled with a red cup, achieving near 0% accuracy, whereas AT→FT achieved a staggering 99.5% accuracy.

The Failure of Target-Domain AT

Interestingly, the study found that applying adversarial training directly to the small target dataset (ST→AFT or AT→AFT) was detrimental. The authors suggest that because the target dataset is small, adversarial training destroys the useful features transferred from ImageNet without providing enough data for the network to learn new, robust ones. Furthermore, the authors found that minimal fine-tuning—specifically freezing the first block of the ResNet-18 ($L=1$)—yielded the best results, as it preserved the robust features learned during the adversarial pre-training phase.

Conclusion

Adversarial training serves as a powerful regularizer for transfer learning in specialized domains with limited data. By pre-training on a large source dataset with adversarial perturbations, networks learn features that are more resilient to the specific geometric biases of the training containers. While the success of this method depends on the empirical tuning of the perturbation bound ($\epsilon$), it represents a significant step forward in making robotic perception more robust to the diversity of everyday objects. Future work will explore how these techniques handle varying levels of transparency and hand occlusions in more complex environments.

Summary updated

BibTeX
@inproceedings{modas2021improving,
  author = {Apostolos Modas and Alessio Xompero and Ricardo Sanchez-Matilla and Pascal Frossard and Andrea Cavallaro},
  title = {{Improving filling level classification with adversarial training}},
  booktitle = {ICIP},
  year = {2021},
  url = {https://openreview.net/forum?id=73vxqDbHJn},
}
Figure