# Generalized Category Discovery

Sagar Vaze⋆ Kai Han† Andrea Vedaldi⋆ Andrew Zisserman⋆
⋆Visual Geometry Group, University of Oxford
†The University of Hong Kong
<EMAIL_ADDRESS><EMAIL_ADDRESS>
###### Abstract

In this paper, we consider a highly general image recognition setting wherein,
given a labelled and unlabelled set of images, the task is to categorize all
images in the unlabelled set. Here, the unlabelled images may come from
labelled classes or from novel ones. Existing recognition methods are not able
to deal with this setting, because they make several restrictive assumptions,
such as the unlabelled instances only coming from known — or unknown — classes
and the number of unknown classes being known a-priori. We address the more
unconstrained setting, naming it ‘Generalized Category Discovery’, and
challenge all these assumptions. We first establish strong baselines by taking
state-of-the-art algorithms from novel category discovery and adapting them
for this task. Next, we propose the use of vision transformers with
contrastive representation learning for this open world setting. We then
introduce a simple yet effective semi-supervised $k$-means method to cluster
the unlabelled data into seen and unseen classes automatically, substantially
outperforming the baselines. Finally, we also propose a new approach to
estimate the number of classes in the unlabelled data. We thoroughly evaluate
our approach on public datasets for generic object classification including
CIFAR10, CIFAR100 and ImageNet-100, and for fine-grained visual recognition
including CUB, Stanford Cars and Herbarium19, benchmarking on this new setting
to foster future research. Code: github.com/sgvaze/generalized-category-
discovery

Figure 1: We present a new setting: ‘Generalized Category Discovery’ and a
method to tackle it. Our setting can be succinctly described as: given a
dataset, a subset of which has class labels, categorize all unlabelled images
in the dataset. Our method leverages the properties of contrastively trained
vision transformers to assign labels directly through clustering.

##  1 Introduction

Consider an infant sitting in a car and observing the world. Object instances
will pass the car and, for some of these, the infant may have been told their
category (‘that is a dog’, ‘that is a car’) and be able to recognize them.
There will also be instances that the infant has not seen before (cats and
bicycles) and, having seen a number of these instances, we might expect the
infant’s visual recognition system to cluster these into new categories.

This is the problem that we consider in this work: given an image dataset
where only some images are labelled with their category, assign a category
label to all other images, possibly using new categories not observed in the
labelled set. We term this problem Generalized Category Discovery (GCD), and
suggest that this is a realistic use case for many machine vision
applications: whether that is recognizing products in a supermarket;
pathologies in medical images; or vehicles in autonomous driving.

To motivate this problem, consider the limitations of existing image
recognition settings. In image classification, one of the the most widely
studied problems, all of the training images come with class labels.
Furthermore, all images at test time come from the same classes as the
training set. Semi-supervised learning (SSL) [6] introduces the problem of
learning from unlabelled data, but still assumes that all unlabelled images
come from the same set of classes as the labelled ones. More recently, the
tasks of open-set recognition (OSR) [35] and novel-category discovery (NCD)
[17] have tackled open-world settings in which the images at test time may
belong to new classes. However, OSR aims only to detect test-time images which
do not belong to one of the classes in the labelled set, but does not require
any further classification amongst these detected images. Meanwhile, in NCD,
the closest setting to the one tackled in this work, methods learn from
labelled and unlabelled images, and aim to discover new classes in the
unlabelled set. However, NCD still makes the limiting assumption that all of
the unlabelled images come from new categories, which is usually unrealistic.

In this paper, we tackle Generalized Category Discovery in a number of ways.
Firstly, we establish strong baselines by taking representative methods from
NCD and applying them to this task. To do this, we adapt their training and
inference mechanisms to account for our more general setting, as well as
retrain them with a more robust backbone architecture. We show that existing
NCD methods are prone to overfit the labelled classes in this generalized
setting.

Next, observing the potential for NCD methods to overfit their classification
heads to the labelled classes, we propose a simple but effective method for
recognition by clustering. Our key insight is to leverage the strong ‘nearest
neighbour’ classification property of vision transformers along with
contrastive learning. We propose the use of contrastive training and a semi-
supervised $k$-means clustering algorithm to recognize images without a
parametric classifier. We show that these proposed methods substantially
outperform the established baselines, both on generic object recognition
datasets and, particularly, on more challenging fine-grained benchmarks.

Finally, we propose a solution to a challenging and under-investigated problem
in image recognition: estimating the number of categories in unlabelled data.
Almost all methods, including purely unsupervised ones, assume the knowledge
of the number of categories, a highly unrealistic assumption in the the real
world. We propose an algorithm which leverages the labelled set to tackle this
problem.

Our contributions can be summarized as follows:

  * •

The formalization of Generalized Category Discovery (GCD), a new setting for
image recognition.

  * •

The establishment of strong baselines by transferring and adapting state-of-
the-art techniques from standard novel category discovery to this task.

  * •

A simple but effective method for GCD, which uses contrastive representation
learning and clustering to directly provide class labels, and outperforms the
baselines substantially.

  * •

A novel method for estimating the number of categories in unlabelled data, a
largely understudied problem.

We hope that this paper will serve as a springboard for future work on this
more realistic version of open world image recognition.

##  2 Related work

Our work relates to prior work on semi-supervised learning, open-set
recognition, and novel category discovery, which we briefly review next.

Semi-supervised learning. A vast number of methods [6, 30, 34, 37, 46] have
been proposed to tackle the problem of semi-supervised learning (SSL). SSL
assumes that the labelled and unlabelled instances are from the same set of
classes. The objective is to learn a robust classification model leveraging
both the labelled and unlabelled data during training. Amongst existing
methods, the consistency based approaches appear to be popular and effective,
such as LadderNet [33], PI model [27], Mean-teacher [40]. Recently, with the
success of self-supervised learning, methods have also been proposed to
improve SSL by augmenting the methods with self-supervised objectives [34,
46].

Open-set recognition. The problem of open-set recognition (OSR) is formalized
in [35], with the objective being to classify unlabelled instances from the
same semantic classes as the labelled data, while identifying unlabelled
instances from unseen classes. OpenMax [3] is the first deep learning method
to approach this problem with Extreme Value Theory. GANs are often employed to
generate adversarial samples to train the open-set classifier, e.g, [29, 13,
23]. Several methods have been proposed to train models such that images with
large reconstruction error are regarded as open-set samples [45, 31, 38].
There are also methods that learns prototypes for the labelled classes, and
identify the images from unknown classes by the distances to the prototypes
[36, 8, 7]. More recently, [8, 7] proposed to learn the reciprocal points
which describe ‘otherness’ with respect to the labelled classes. [47] jointly
trains a flow-based density estimator and a classification based encoder for
OSR. Finally, Vaze et al. [42] study the correlation between closed-set and
open-set performance, and show that state-of-the-art OSR results can be
obtained by boosting the closed-set performance on the cross-entropy baseline.

Novel category discovery. The problem of novel category discovery (NCD) is
formalized in DTC [17]. Earlier methods that can be applied to this problem
are KCL [19] and MCL [20], both of which maintain two models trained with
labelled data and unlabelled data respectively, for general task transfer
learning. AutoNovel (aka Rankstats) [16, 15] tackles the NCD problem with a
three stage method. The model is firstly trained with self-supervision on all
data for low-level representation learning. Then, it is further trained with
full supervision on labelled data to capture higher level semantic
information. Finally, a joint learning stage is carried out to transfer
knowledge from the labelled to unlabelled data with ranking statistics. Zhao
and Han [48] propose a model with two branches, one for global feature
learning and the other for local feature learning, such that dual ranking
statistics and mutual learning are conducted with these two branches for
better representation learning and new class discovery. OpenMix [50] mixes the
labelled and unlabelled data to avoid the model from over-fitting for NCD. NCL
[49] extracts and aggregates the pairwise pseudo-labels for the unlabelled
data with contrastive learning and generates hard negatives by mixing the
labelled and unlabelled data in the feature space for NCD. Jia et al. [21]
propose an end-to-end NCD method for single- and multi-modal data with
contrastive learning and winner-takes-all hashing. A unified cross-entropy
loss is introduced in UNO [12] to allow the model to be trained on labelled
and unlabelled data jointly by swapping the pseudo-labels from labelled and
unlabelled classification heads.

##  3 Generalized category discovery

We first formalize the task of _Generalized Category Discovery_ (GCD). In
short, we consider the problem of classifying images in a dataset, a subset of
which has known class labels. The task is to assign class labels to all
remaining images, using classes that may or may not be observed in the
labelled images (see Fig. 1, left).

Formally, we define GCD as follows. We consider a dataset $\mathcal{D}$
comprising two parts
$\mathcal{D_{L}}=\\{(\mathbf{x}_{i},y_{i})\\}_{i=1}^{N}\in\mathcal{X}\times\mathcal{Y_{L}}$
and
$\mathcal{D_{U}}=\\{(\mathbf{x}_{i},y_{i})\\}_{i=1}^{M}\in\mathcal{X}\times\mathcal{Y_{U}}$,
where $\mathcal{Y_{L}}\subset\mathcal{Y_{U}}$. During training, the model does
not have access to the labels in $\mathcal{D_{U}}$, and is tasked with
predicting them at test time. Furthermore, we assume access to a validation
set,
$\mathcal{D_{V}}=\\{(\mathbf{x}_{i},y_{i})\\}_{i=1}^{N^{\prime}}\in\mathcal{X}\times\mathcal{Y_{L}}$,
which is disjoint from the training set and contains images from the same
classes as the labelled set. This formalization allows us to clearly see the
distinction with the novel category discovery setting. NCD assumes
$\mathcal{Y_{L}}\cap\mathcal{Y_{U}}=\emptyset$ and existing methods use this
prior knowledge during training.

In this section, we describe the methods we propose in order to tackle GCD. We
begin by describing our approach to the problem. Leveraging recent progress in
self-supervised representation learning, we propose a simple but effective
approach based on contrastive learning, with classification labels provided by
a semi-supervised $k$-means algorithm. Next, we develop a method to estimate
the number of categories in the unlabelled data, which is a challenging task
that is understudied in the literature. Finally, we build two strong baselines
for this problem by modifying state-of-the-art NCD methods, RankStats [16] and
UNO [12], to fit with our setting.

###  3.1 Our approach

The key insight of our approach for image recognition in an open-world setting
is to remove the need for parametric classification heads. Instead, we perform
clustering directly in the feature space of a deep network (see Fig. 1,
right). Classification heads (typically, linear classifiers on top of a
learned embedding) are best trained with the cross-entropy loss, which has
been shown to be susceptible to noisy labels [11]. Furthermore, when training
a linear classifier for unlabelled classes, a typical method is to generate
(noisy) pseudo-labels for the unlabelled instances. This would suggest that
parametric heads are susceptible to performance deterioration on the
unlabelled classes. Finally, we note that, by necessity, classification heads
must be trained from scratch, which further makes them vulnerable to
overfitting on the labelled classes.

Meanwhile, self-supervised contrastive learning has been widely used as pre-
training to achieve robust representations in NCD [21, 49]. Furthermore, when
combined with vision transformers, it generates models which are good nearest
neighbour classifiers [5]. Inspired by this, we find that constrastively
training a ViT model allows us to directly cluster in the model’s feature
space, thereby removing the need for a linear head which could lead to
overfitting. Specifically, we train the representation with a noise
contrastive loss [14] on all images _without using any labels_. This is
important because it avoids overfitting the features to the subset of classes
that are (partially) labelled. We add a further supervised contrastive
component [22] for the labelled instances to make use of the labelled data
(see Fig. 1, middle row on the right).

####  3.1.1 Representation learning

We use, for all methods, a vision transformer (ViT-B-16) [10] pretrained with
DINO [5] self-supervision on (unlabelled) ImageNet [9] as our backbone. This
is motivated firstly because the DINO model is a strong nearest neighbour
classifier, which suggests non-parametric clustering in its feature space
would work well. Secondly, self-supervised vision transformers have
demonstrated the attractive quality of learning to attend to salient parts of
an object without human annotation. We find this feature to be useful for this
task, because _which_ object parts are important for classification is likely
to transfer well from the labelled to the unlabelled categories (see Sec.
4.5).

Finally, we wish to reflect a realistic and practical setting. In the NCD
literature, it is standard to train a ResNet-18 [18] backbone from scratch for
the target task. However, in a real-world setting, a model is often
initialized with large-scale pretrained weights to optimize performance (often
ImageNet supervised pretraining). In order to avoid conflicts with our
experimental setting (which assumes a finite labelled set), we use self-
supervised ImageNet weights. To enhance the representation such that it is
more tailored for the labelled and unlabelled data we have, we further fine-
tune the representation on our target data jointly with supervised contrastive
learning on the labelled data, and unsupervised contrastive learning on all
the data.

Formally, let $\mathbf{x}_{i}$ and $\mathbf{x}_{i^{\prime}}$ be two views
(random augmentations) of the same image in a mini-batch $B$. The unsupervised
contrastive loss is written as:

$\mathcal{L}^{u}_{i}=-\log\frac{\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{i^{\prime}}/\tau\right)}{\sum_{n}\mathds{1}_{[n\neq
i]}\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{n}/\tau\right)},$ (1)

where $\mathbf{z}_{i}=\phi(f(\mathbf{x}_{i}))$ and $\mathds{1}_{[n\neq i]}$ is
an indicator function evaluating to 1 _iff_ $n\neq i$, and $\tau$ is a
temperature value. $f$ is the feature backbone, and $\phi$ is a multi-layer
perceptron (MLP) projection head.

The supervised contrastive loss is written as:

$\mathcal{L}^{s}_{i}=-\frac{1}{|\mathcal{N}(i)|}\sum_{q\in\mathcal{N}(i)}\log\frac{\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{q}/\tau\right)}{\sum_{n}\mathds{1}_{[n\neq
i]}\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{n}/\tau\right)},$ (2)

where $\mathcal{N}(i)$ denotes the indices of other images having the same
label as $\mathbf{x}_{i}$ in the mini-batch $B$. Finally, we construct the
total loss over the batch as:

$\mathcal{L}^{t}=(1-\lambda)\sum_{i\in B}\mathcal{L}^{u}_{i}+\lambda\sum_{i\in
B_{\mathcal{L}}}\mathcal{L}^{s}_{i}$ (3)

where $B_{\mathcal{L}}$ corresponds to the labelled subset of $B$ and
$\lambda$ is a weight coefficient. Using the labels only in a contrastive
framework, rather than in a cross-entropy loss, means that unlabelled and
labelled data are treated similarly. The supervised contrastive component is
only used to nudge the network towards a semantically meaningful
representation, thereby minimizing overfitting on the labelled classes.

####  3.1.2 Label assignment with semi-supervised $k$-means

Given the learned representation for the data, we can now assign class or
cluster labels for each unlabelled data point, either from the labelled
classes or unseen new classes. Instead of performing this parametrically as is
common in NCD (and risk overfitting to the labelled data) we propose to use a
non-parametric method. Namely, we propose to modify the classic $k$-means into
a constraint algorithm by forcing the assignment of the instances in
$\mathcal{D_{L}}$ to the correct cluster based on their ground-truth labels.
Note, here we assume knowledge of the number of clusters, $k$. We tackle the
problem of estimating this parameter in Sec. 3.2. The initial
$|\mathcal{Y_{L}}|$ centroids for $\mathcal{D_{L}}$ are obtained based on the
ground-truth class labels, and an additional
$|\mathcal{Y_{U}}\setminus\mathcal{Y_{L}}|$ (number of new classes) initial
centroids are obtained from $\mathcal{D_{U}}$ with $k$-means++ [1],
constrained on the centroids of $\mathcal{D_{L}}$. During each centroid update
and cluster assignment cycle, instances from the same class in
$\mathcal{D_{L}}$ are always forced to have the same cluster assignment, while
each instance in $\mathcal{D_{U}}$ can be assigned to any cluster based on the
distance to different centroids. After the semi-supervised $k$-means
converges, each instance in $\mathcal{D_{U}}$ can be assigned a cluster label.
We provide a clear diagram of this in Appendix B.

###  3.2 Estimating the class number in unlabelled data

Here, we tackle the problem of finding the number of classes in the unlabelled
data. In the NCD and unsupervised clustering settings, prior knowledge of the
number of categories in the dataset is assumed, but this is unrealistic in the
real world given that the labels themselves are unknown. To estimate the
number of categories in $\mathcal{D_{U}}$, we leverage the information
available in $\mathcal{D_{L}}$. Specifically, we perform $k$-means clustering
on the entire dataset, $\mathcal{D}$, before evaluating clustering accuracy on
only the labelled subset (see Sec. 4.1 for the metric’s definition).

Clustering accuracy is evaluated by running the Hungarian algorithm [26] to
find the optimal assignment between the set of cluster indices and ground
truth labels. If the number of clusters is higher than the total number of
classes, the extra clusters are assigned to the null set, and all instances
assigned to those clusters are said to have been predicted incorrectly.
Conversely, if the number of clusters is lower than the number of classes,
extra classes are assigned to the null set, and all instances with those
ground truth labels are said to have been to be predicted incorrectly. Thus,
we assume that, if the clustering (across $\mathcal{D}$) is performed with $k$
too high or too low, then this will be reflected in a sub-optimal clustering
accuracy on $\mathcal{D_{L}}$. In other words, we assume clustering accuracy
on the labelled set will be maximized when
$k=|\mathcal{Y_{L}}\cup\mathcal{Y_{U}}|$. This intuition leads us to use the
clustering accuracy as a ‘black box’ scoring function, $ACC=f(k;\mathcal{D})$,
which we optimize with Brent’s algorithm to find the optimal $k$.

###  3.3 Two strong baselines

To the best of our knowledge, there is no baseline for GCD that can be used
as-is from the literature. Instead, we adapt two NCD baselines for it:
RankStats [16], which is widely used as a competitive baseline for novel
category discovery, and UNO [12], which is to the best of our knowledge the
state-of-the-art method for NCD.

##### Baseline: RankStats+

RankStats trains two classifiers on top of a shared feature representation:
the first head is fed instances from the labelled set and is trained with the
cross-entropy loss, while the second head sees only instances from unlabelled
classes (again, in the NCD setting, the labelled and unlabelled classes are
disjoint). In order to adapt RankStats to GCD, we train it with a single
classification head for the total number of classes in the dataset. We then
train the first $|\mathcal{Y_{L}}|$ elements of the head with the cross-
entropy loss, and train the entire head with the binary cross-entropy loss
with pseudo-labels.

##### Baseline: UNO+

Similarly to RankStats, UNO is trained with classification heads for labelled
and unlabelled data. The model is then trained in a SwAV-like manner [4].
First, multiple views (random augmentations) of a batch are generated and fed
to the same model. For the labelled images in the batch, the labelled head is
trained with the cross-entropy loss using the ground truth labels. For the
unlabelled images, predictions (logits from the unlabelled head) are gathered
for a given view and used as pseudo-labels with which to optimize the loss
from other views. To adapt this mechanism, we simply concatenate both the
labelled and unlabelled heads, thus allowing generated pseudo-labels for the
unlabelled samples to belong to any class in the dataset.

##  4 Experiments

###  4.1 Experimental setup

##### Data

We demonstrate results on six datasets in our proposed setting. For each
dataset, we take the training set and sample a set of classes for which we
have labels during training. We further sub-sample 50% of the images from
these classes to constitute the labelled set $\mathcal{D_{L}}$. The remaining
instances from these classes, along with all instances from the other classes,
constitute $\mathcal{D_{U}}$. We further construct the validation set for the
labelled classes from the test or validation split of each dataset.

We first demonstrate results on three generic object recognition datasets:
CIFAR10 [25], CIFAR100 [25] and ImageNet-100 [9]. ImageNet-100 refers to the
ImageNet dataset with 100 classes randomly subsampled. These datasets
establish the methods’ ability to identify categories with abstract class
definitions, as may be encountered in settings such as self-driving or animal
monitoring in the wild.

We further demonstrate results on three fine-grained datasets: CUB [43],
Stanford Cars [24] and Herbarium19 [39]. Recent work has identified the need
for open-set benchmarks which have a clearly defined concept of a ‘semantic
class’ [42], proposing fine-grained visual categorization (FGVC) datasets as a
solution to this. In these benchmarks, there are specific ‘axes of semantic
variation’ — e.g., the difference between two bird species in CUB _vs._ the
difference between a dog and a refrigerator in ImageNet. Thus, the user can be
more confident that the recognition system is identifying new classes based on
a true semantic signal, rather than simply responding to low-level
distributional shifts in the data, as may be the case for generic object
recognition datasets. The long-tailed nature of Herbarium19 adds an additional
dimension to the evaluation.

FGVC datasets further reflect a number of real-world use cases for image
recognition systems, which are deployed in constrained environments with many
similar objects (_e.g_. products in a supermarket). In fact, the Herbarium19
dataset itself represents a real-world use case for GCD: while we are aware of
roughly 400k species of plants, and estimate that there are around 80k yet to
be discovered, it currently takes roughly 35 years from plant collection to
plant species description if performed manually [39]. We summarise the dataset
splits used in our evaluations in Tab. 1, and provide more details in Appendix
A.

Table 1:  Datasets used in our experiments. We show the number of classes in
the labelled and unlabelled sets ($|\mathcal{Y_{L}}|,|\mathcal{Y_{U}}|$), as
well as the number of images ($|\mathcal{D_{L}}|,|\mathcal{D_{U}}|$).

| CIFAR10 | CIFAR100 | ImageNet-100 | CUB | SCars | Herb19
---|---|---|---|---|---|---
$|\mathcal{Y_{L}}|$ | 5 | 80 | 50 | 100 | 98 | 341
$|\mathcal{Y_{U}}|$ | 10 | 100 | 100 | 200 | 196 | 683
$|\mathcal{D_{L}}|$ | 12.5k | 20k | 31.9k | 1.5k | 2.0k | 8.9k
$|\mathcal{D_{U}}|$ | 37.5k | 30k | 95.3k | 4.5k | 6.1k | 25.4k

##### Evaluation protocol

For each dataset, we train the models on $\mathcal{D}$ (without access to the
ground truth labels in $\mathcal{D_{U}}$). At test-time, we measure the
clustering accuracy between the ground truth labels $y_{i}$ and the model’s
predictions $\hat{y}_{i}$ as:

$ACC=\max_{p\in\mathcal{P(Y_{U})}}\frac{1}{M}\sum_{i=1}^{M}\mathds{1}\\{y_{i}=p(\hat{y}_{i})\\}$
(4)

Here, $M=|\mathcal{D_{U}}|$ and $\mathcal{P(Y_{U})}$ is the set of all
permutations of the class labels in the unlabelled set. The maximum over the
set of permutations is computed via the Hungarian optimal assignment algorithm
[26].

##### Implementation details

All methods are trained with a ViT-B-16 backbone with DINO pre-trained
weights, and use the output [CLS] token as the feature representation. All
methods were trained for 200 epochs, or until convergence as defined by the
accuracy on the validation set.

For our method, we fine-tune the final block of the vision transformer with an
initial learning rate of 0.1 which we decay with a cosine annealed schedule.
We use a batch size of 128 and $\lambda=0.35$ in the loss (see Eq. 3).
Furthermore, following standard practise in self-supervised learning, we
project the model’s output through a non-linear projection head before
applying the contrastive loss. We use the same projection head as in [5] and
discard it at test-time.

For the baselines from NCD, we follow the original implementations and
learning schedules as far as possible, referring to the original papers for
details [16, 12]. For these experiments, we freeze the backbone and train only
the classification heads. We also experimented with fine-tuning different
amounts of the backbone, but found that a frozen backbone worked best for the
baseline methods. Finally, we also experimented with training a lightweight
(ResNet-18) backbone from scratch for this task, and also ensured that our
implementations could recreate the reported figures in the original NCD
setting.

Finally, in order to estimate $k$, we run our $k$-estimation method on DINO
features extracted from each of the considered benchmarks. We run Brent’s
algorithm on a constrained domain for $k$, with the minimum set at
$|\mathcal{Y_{L}}|$ and the maximum set at 1000 classes for all datasets.

###  4.2 Comparison with the baselines

We report results for all compared methods in Tab. 2 and Tab. 3. As an
additional baseline, we also report results when running $k$-means directly on
top of raw DINO features (reported as $k$-means). We report $ACC$ values for
both the ‘Old’ classes (instances in $\mathcal{D_{U}}$ belonging to classes in
$\mathcal{Y_{L}}$) and ‘New’ classes (instances in $\mathcal{D_{U}}$ belonging
to classes in $\mathcal{Y_{U}}\setminus\mathcal{Y_{L}}$). Finally, we report
the aggregated accuracy, ‘All’, over all instances in $\mathcal{D_{U}}$.

The results on the generic object recognition datasets are presented in Tab.
2. We note that, on all datasets, the best performance aggregated over the
entire unlabelled set is achieved by our method. Our model further outperforms
the baselines in most subcategories of the datasets. The exception is
ImageNet-100, where raw DINO features perform better on the ‘New’ classes
(with no labels available in $\mathcal{D}$) and UNO+ performs better on the
‘Old’ ones (from the same classes as those in $\mathcal{D_{L}}$). The first
result is explained as DINO is trained in a self-supervised manner on the
entire ImageNet dataset, where it has been carefully tuned to achieve a strong
representation for all classes. We suggest that the second result is due to
ImageNet-100 containing many classes, but also containing enough images
($\approx$650) per class to reliably train a linear classifier with cross-
entropy. In this regime, in the supervised setting, it is still difficult to
beat a standard classification head. Nonetheless, the best tradeoff between
the ‘New’ and ‘Old’ classes is still achieved by our approach. We also note
that the methods based on parametric classifiers show a substantial
discrepancy between their performances on the ‘Old’ and ‘New’ classes,
demonstrating overfitting on the labelled categories. Across ‘All’ classes in
Tab. 2, on average, our method outperforms the nearest baseline by 6.9% in
absolute terms, and by 9.6% in proportional terms.

The results on the FGVC datasets are shown in Tab. 3. In this more challenging
setting, our approach outperforms the baselines substantially in all cases
except for the ‘Old’ classes in Herbarium19. In this case, RankStats+
demonstrates strong performance, though it once again overfits to the ‘Old’
classes and underperforms our method significantly over ‘All’ classes. On the
FGVC datasets, we find our method outperforms the nearest baseline by 11.6% on
average in absolute terms, and 34.7% in proportional terms.

Table 2: Results on generic image recognition datasets.

| CIFAR10 | CIFAR100 | ImageNet-100
---|---|---|---
Classes | All | Old | New | All | Old | New | All | Old | New
$k$-means [28] | 83.6 | 85.7 | 82.5 | 52.0 | 53.7 | 51.1 | 73.4 | 75.5 | 71.3
RankStats+ | 84.5 | 96.4 | 78.5 | 65.0 | 78.8 | 37.4 | 50.9 | 94.2 | 29.2
UNO+ | 72.4 | 95.0 | 61.1 | 64.1 | 73.8 | 44.8 | 62.3 | 94.7 | 46.0
Ours | 91.5 | 97.9 | 88.2 | 76.9 | 84.5 | 61.7 | 75.1 | 92.2 | 66.5

Table 3: Results on fine-grained image recognition datasets.

| CUB | Stanford Cars | Herbarium19
---|---|---|---
Classes | All | Old | New | All | Old | New | All | Old | New
$k$-means [28] | 35.7 | 42.3 | 32.4 | 14.2 | 14.2 | 14.2 | 14.1 | 14.7 | 13.3
RankStats+ | 37.1 | 73.8 | 18.7 | 29.2 | 53.6 | 17.1 | 31.4 | 54.5 | 18.9
UNO+ | 40.1 | 71.1 | 24.5 | 20.6 | 33.7 | 14.1 | 21.2 | 36.1 | 13.3
Ours | 54.0 | 75.4 | 43.4 | 42.0 | 61.2 | 32.4 | 39.4 | 40.5 | 38.5

Figure 2: TSNE visualization of instances in CIFAR10 for features generated by
a ResNet-50 and ViT model trained with DINO self-supervision on ImageNet, and
a ViT model after fine-tuning with our approach. Table 4:  Estimation of the
number of classes in unlabelled data.

| CIFAR10 | CIFAR100 | ImageNet-100 | CUB | SCars | Herb19
---|---|---|---|---|---|---
Ground truth | 10 | 100 | 100 | 200 | 196 | 683
Ours | 9 | 100 | 109 | 231 | 230 | 520
Error | 10% | 0% | 9% | 16% | 15% | 28%

Table 5: Ablation study on the different components of our approach. | ViT Backbone | Contrastive Loss | Sup. Contrastive Loss | Semi-Sup $k$-means | CIFAR100 | Herbarium19
---|---|---|---|---|---|---
All | Old | New | All | Old | New
(1) | ✗ | ✗ | ✗ | ✗ | 34.0 | 34.8 | 32.4 | 12.1 | 12.5 | 11.9
(2) | ✓ | ✗ | ✗ | ✗ | 52.0 | 53.7 | 51.1 | 14.1 | 14.7 | 13.3
(3) | ✓ | ✓ | ✗ | ✗ | 54.6 | 54.1 | 53.7 | 14.3 | 15.1 | 13.9
(4) | ✓ | ✗ | ✓ | ✗ | 60.5 | 72.2 | 35.0 | 17.8 | 22.7 | 15.4
(5) | ✓ | ✓ | ✓ | ✗ | 74.5 | 81.2 | 61.2 | 30.5 | 35.3 | 27.9
(6) | ✓ | ✓ | ✓ | ✓ | 76.9 | 84.5 | 61.7 | 39.4 | 40.5 | 38.5
Figure 3: Attention visualizations for the DINO-ViT model before (left) and
after (right) fine-tuning with our approach. For Stanford Cars and CUB, we
show an image from the ‘Old’ (first row for each dataset) and ‘New’ classes
(second row for each dataset). Our model learns to specialize attention heads
(shown as columns) to different semantically meaningful parts, which can
transfer between the labelled and unlabelled categories. The model’s heads
learn ‘Windshield’, ‘Headlight’ and ‘Wheelhouse’ for the cars, and ‘Beak’,
‘Head’ and ’Belly’ for the birds. For both models, we select heads with as
focused attention as possible. Recommended viewing in color with zoom.

###  4.3 Estimating the number of classes

We report results on estimating the number of classes in Tab. 4. We find that
on the generic object recognition datasets, we can come very close to the
ground truth number of categories in the unlabelled set, with a maximum error
of 10%. On the FGVC datasets, we report an average discrepancy of 18.9%. We
note the highly challenging nature of the FGVC datasets, with many constituent
classes which are visually similar.

###  4.4 Ablation study

In Tab. 5, we inspect the contributions of the various elements of our
proposed approach. Specifically, we identify the importance of the following
components of the method: ViT backbone; contrastive fine-tuning (regular and
supervised); and semi-supervised $k$-means clustering.

##### ViT Backbone

Rows (1) and (2) show the effect of the ViT model for the clustering task, as
(1) and (2) represent a ResNet-50 model and ViT-B-16 trained with DINO
respectively. The ResNet model performs nearly 20% worse aggregated over ‘Old’
and ‘New’ classes. To disambiguate this from the general capacity of the
architecture, note that the ImageNet linear probe discrepancy (the standard
evaluation protocol for self-supervised models) is roughly 3% [5]. Meanwhile,
the discrepancy in their $k$-NN accuracies on ImageNet is roughly 9% [5],
suggesting why the ViT model performs so much better for the clustering task.

##### Contrastive fine-tuning

Rows (2)-(5) show the effects of introducing different combinations of
contrastive fine-tuning on the target dataset. We find that including any of
the contrastive methods alone gives relatively marginal improvements over
using the raw DINO features. We find that the full benefit is only realized
when combining the self-supervised and supervised contrastive losses on the
target dataset. Specifically, the combination of the contrastive losses allows
us to boost aggregated clustering accuracy by a further 23% on CIFAR100 and by
16% on Herbarium19 (more than doubling the $ACC$ in this case).

##### Semi-supervised $k$-means

The semi-supervised clustering also improves $ACC$ across the board. In
general, we found that semi-supervised clustering was beneficial on all
datasets, and gave a particular boost on the FGVC benchmarks. For instance, in
the Herbarium19 case, it improves aggregated $ACC$ by nearly 10%.

##### Summary

Overall, we find that none of the components of our method are individually
sufficient to achieve good performance across our benchmark datasets.
Specifically, the combination of a vision transformer backbone and contrastive
fine-tuning facilitates strong $k$-means clustering directly in the feature
space of the model. The semi-supervised $k$-means algorithm further allows us
to guide the clustering process with labels and achieve better $ACC$,
especially on the fine-grained datasets.

We further illustrate this point in the TSNE visualizations in Fig. 2,
performed on the CIFAR10 dataset. We show TSNE projections of raw ResNet-50
and ViT DINO features, as well as those of our model. For the ResNet-50
features, points from the same class are generally projected close to each
other, indicating that they are likely to be separable given a simple
transformation (_e.g_. a linear probe). However, they do not form clear
clusters, hinting at these features’ poor down-stream clustering performance.
In contrast, the ViT features form far clearer clusters, which are further
distinguished when trained with our approach.

###  4.5 Qualitative results

Finally, we visualize the attention mechanism of our model to better
understand its performance. Specifically, in Fig. 3 we look at how the final
multi-head attention layer attends to different spatial locations when
supporting the output [CLS] token (which we use as our feature
representation). We show this both for the pre-trained DINO model and after
training with our method. We visualize the attention maps for images from the
‘Old’ and ‘New’ classes for Stanford Cars and CUB.

It is demonstrated in [5] that different attention heads in the DINO model
focus on different regions of an image, without the need for human annotation.
We find this to be the case, with different heads attending to disjoint
regions of the image and typically focusing on important parts. However, after
training with our method, we find heads to be more specialised to semantic
parts, displaying more concentrated and local attention. In this way, we
suggest the model learns to attend to a set of parts which are transferable
between the ‘Old’ and ‘New’ classes, which allows it to better generalize
knowledge from the labelled data.

##  5 Broader impact and limitations

Our method assigns labels to images in an unsupervised manner, including
discovering new labels. Even more than standard image classification methods,
it should be used with care (e.g., by manually checking the results) in
sensitive contexts, such as processing personal data.

We also note some practical limitations. First, we assume that there is no
domain shift between the labelled and unlabelled subsets. For instance, we are
not tackling the problem of a single model reliably classifying photographs
and paintings of the same classes. Second, we do not consider the streaming
setting (also known as continual learning): one would need to re-train the
model from scratch as new data becomes available.

As for the data used in the experiments, we use standard third-party datasets
in a manner compatible with their licenses. Some of these datasets contain
Internet images that feature, often incidentally, people — see [32, 44, 2] for
an in-depth discussion of the privacy implications.

##  6 Conclusions

We have proposed and investigated GCD, a more general, challenging and
realistic variant of NCD. Given a dataset with partial labels for images and
classes, the task is to find the assignment for all unlabelled images, while
discovering any new classes. We have developed baselines for the task by
transferring state-of-the-art algorithms from NCD and further developed a
simple but effective algorithm which substantially outperforms these
baselines. We also proposed a method for identifying the number of categories
in the unlabelled data, which is an understudied problem of practical
significance. We hope that this work can serve as a foundation from which to
tackle this important problem.

## References

  * [1] David Arthur and Sergei Vassilvitskii.  k-means++: the advantages of careful seeding.  In ACM-SIAM symposium on Discrete algorithms, 2007.
  * [2] Yuki M. Asano, Christian Rupprecht, Andrew Zisserman, and Andrea Vedaldi.  PASS: An ImageNet replacement for self-supervised pretraining without human.  NeurIPS Track on Datasets and Benchmarks, 2021.
  * [3] Abhijit Bendale and Terrance E. Boult.  Towards open set deep networks.  In CVPR, 2016.
  * [4] Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin.  Unsupervised learning of visual features by contrasting cluster assignments.  In NeurIPS, 2020.
  * [5] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin.  Emerging properties in self-supervised vision transformers.  In ICCV, 2021.
  * [6] Olivier Chapelle, Bernhard Scholkopf, and Alexander Zien.  Semi-Supervised Learning.  MIT Press, 2006.
  * [7] Guangyao Chen, Peixi Peng, Xiangqian Wang, and Yonghong Tian.  Adversarial reciprocal points learning for open set recognition.  IEEE TPAMI, 2021.
  * [8] Guangyao Chen, Limeng Qiao, Yemin Shi, Peixi Peng, Jia Li, Tiejun Huang, Shiliang Pu, and Yonghong Tian.  Learning open set network with discriminative reciprocal points.  In ECCV, 2020.
  * [9] Jia Deng, Wei Dong, Richard Socher, Li-Jua Li, Kai Li, and Li Fei-Fei.  Imagenet: A large-scale hierarchical image database.  In CVPR, 2009.
  * [10] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby.  An image is worth 16x16 words: Transformers for image recognition at scale.  In ICLR, 2021.
  * [11] Lei Feng, Senlin Shu, Zhuoyi Lin, Fengmao Lv, Li Li, and Bo An.  Can cross entropy loss be robust to label noise?  In IJCAI, 2020.
  * [12] Enrico Fini, Enver Sangineto, Stéphane Lathuilière, Zhun Zhong, Moin Nabi, and Elisa Ricci.  A unified objective for novel class discovery.  In ICCV, 2021.
  * [13] Zongyuan Ge, Sergey Demyanov, and Rahil Garnavi.  Generative openmax for multi-class open set classification.  In BMVC, 2017.
  * [14] Michael Gutmann and Aapo Hyvärinen.  Noise-contrastive estimation: A new estimation principle for unnormalized statistical models.  In Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, 2010.
  * [15] Kai Han, Sylvestre-Alvise Rebuffi, Sebastien Ehrhardt, Andrea Vedaldi, and Andrew Zisserman.  Automatically discovering and learning new visual categories with ranking statistics.  In ICLR, 2020.
  * [16] Kai Han, Sylvestre-Alvise Rebuffi, Sebastien Ehrhardt, Andrea Vedaldi, and Andrew Zisserman.  Autonovel: Automatically discovering and learning novel visual categories.  IEEE TPAMI, 2021.
  * [17] Kai Han, Andrea Vedaldi, and Andrew Zisserman.  Learning to discover novel visual categories via deep transfer clustering.  In ICCV, 2019.
  * [18] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun.  Deep residual learning for image recognition.  In CVPR, 2016.
  * [19] Yen-Chang Hsu, Zhaoyang Lv, and Zsolt Kira.  Learning to cluster in order to transfer across domains and tasks.  In ICLR, 2018.
  * [20] Yen-Chang Hsu, Zhaoyang Lv, Joel Schlosser, Phillip Odom, and Zsolt Kira.  Multi-class classification without multi-class labels.  In ICLR, 2019.
  * [21] Xuhui Jia, Kai Han, Yukun Zhu, and Bradley Green.  Joint representation learning and novel category discovery on single- and multi-modal data.  In ICCV, 2021.
  * [22] Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and Dilip Krishnan.  Supervised contrastive learning.  arXiv preprint arXiv:2004.11362, 2020.
  * [23] Shu Kong and Deva Ramanan.  Opengan: Open-set recognition via open data generation.  ICCV, 2021.
  * [24] Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei.  3d object representations for fine-grained categorization.  In 4th International IEEE Workshop on 3D Representation and Recognition (3dRR-13), 2013.
  * [25] Alex Krizhevsky and Geoffrey Hinton.  Learning multiple layers of features from tiny images.  Technical report, 2009.
  * [26] Harold W Kuhn.  The hungarian method for the assignment problem.  Naval research logistics quarterly, 1955.
  * [27] Samuli Laine and Timo Aila.  Temporal ensembling for semi-supervised learning.  In ICLR, 2017.
  * [28] James MacQueen.  Some methods for classification and analysis of multivariate observations.  In Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, 1967.
  * [29] Lawrence Neal, Matthew Olson, Xiaoli Fern, Weng-Keen Wong, and Fuxin Li.  Open set learning with counterfactual images.  In ECCV, 2018.
  * [30] Avital Oliver, Augustus Odena, Colin Raffel, Ekin D. Cubuk, and Ian J. Goodfellow.  Realistic evaluation of deep semi-supervised learning algorithms.  In NeurIPS, 2018.
  * [31] Poojan Oza and Vishal M. Patel.  C2ae: Class conditioned auto-encoder for open-set recognition.  In CVPR, 2019.
  * [32] Vinay Uday Prabhu and Abeba Birhane.  Large image datasets: A pyrrhic win for computer vision?  In Proc. WACV, 2020.
  * [33] Antti Rasmus, Harri Valpola, Mikko Honkala, Mathias Berglund, and Tapani Raiko.  Semi-supervised learning with ladder networks.  In NeurIPS, 2015.
  * [34] Sylvestre-Alvise Rebuffi, Sebastien Ehrhardt, Kai Han, Andrea Vedaldi, and Andrew Zisserman.  Semi-supervised learning with scarce annotations.  arxiv, 2019.
  * [35] Walter J. Scheirer, Anderson Rocha, Archana Sapkota, and Terrance E. Boult.  Towards open set recognition.  IEEE TPAMI, 2013.
  * [36] Yu Shu, Yemin Shi, Yaowei Wang, Tiejun Huang, and Yonghong Tian.  P-odn: Prototype-based open deep network for open set recognition.  Scientific Reports, 2020.
  * [37] Kihyuk Sohn, David Berthelot, Chun-Liang Li, Zizhao Zhang, Nicholas Carlini, Ekin D. Cubuk, Alex Kurakin, Han Zhang, and Colin Raffel.  Fixmatch: Simplifying semi-supervised learning with consistency and confidence.  In NeurIPS, 2020.
  * [38] Xin Sun, Zhenning Yang, Chi Zhang, Guohao Peng, and Keck-Voon Ling.  Conditional gaussian distribution learning for open set recognition.  In CVPR, 2020.
  * [39] Kiat Chuan Tan, Yulong Liu, Barbara Ambrose, Melissa Tulig, and Serge Belongie.  The herbarium challenge 2019 dataset.  In Workshop on Fine-Grained Visual Categorization, 2019.
  * [40] Antti Tarvainen and Harri Valpola.  Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results.  In NeurIPS, 2017.
  * [41] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin.  Attention is all you need.  In NeurIPS, 2017.
  * [42] Sagar Vaze, Kai Han, Andrea Vedaldi, and Andrew Zisserman.  Open-set recognition: A good closed-set classifier is all you need.  arXiv preprint arXiv:2110.06207, 2021.
  * [43] Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie.  The caltech-ucsd birds-200-2011 dataset.  Technical Report CNS-TR-2011-001, California Institute of Technology, 2011.
  * [44] Kaiyu Yang, Jacqueline Yau, Li Fei-Fei, Jia Deng, and Olga Russakovsky.  A study of face obfuscation in imagenet.  CoRR, abs/2103.06191, 2021.
  * [45] Ryota Yoshihashi, Wen Shao, Rei Kawakami, Shaodi You, Makoto Iida, and Takeshi Naemura.  Classification-reconstruction learning for open-set recognition.  In CVPR, 2019.
  * [46] Xiaohua Zhai, Avital Oliver, Alexander Kolesnikov, and Lucas Beyer.  S4l: Self-supervised semi-supervised learning.  In ICCV, 2019.
  * [47] Hongjie Zhang, Ang Li, Jie Guo, and Yanwen Guo.  Hybrid models for open set recognition.  In ECCV, 2020.
  * [48] Bingchen Zhao and Kai Han.  Novel visual category discovery with dual ranking statistics and mutual knowledge distillation.  In NeurIPS, 2021.
  * [49] Zhun Zhong, Enrico Fini, Subhankar Roy, Zhiming Luo, Elisa Ricci, and Nicu Sebe.  Neighborhood contrastive learning for novel class discovery.  In CVPR, 2021.
  * [50] Zhun Zhong, Linchao Zhu, Zhiming Luo, Shaozi Li, Yi Yang, and Nicu Sebe.  Openmix: Reviving known knowledge for discovering novel visual categories in an open world.  In CVPR, 2021.

Generalized Category Discovery
Appendices

Figure 4: Semi-supervised $k$-means algorithm shown for $k=5$. Given partially
labelled data points (Initial Data), we first initialize $|\mathcal{Y_{L}}|=3$
centroids by the average of labelled data points in each labelled class (shown
as colored dots). Starting from these centroids, we run $k$-means++ (dashed
arrows) on the unlabelled data (black dots) to further obtain
$|\mathcal{Y_{U}}\setminus\mathcal{Y_{L}}|=2$ centroids (Centroid
Initialization). Having obtained $k=5$ centroids (colored stars), we assign
each data point a cluster label by identifying its nearest centroid (Cluster
Assignment), after which we can update the centroids by averaging all data
points in each cluster (Centroid Update). We repeat the cycle of Cluster
Assignment and Centroid Update iteratively, until the $k$-means algorithm
converges. During each cycle, we force the labelled data points to follow
their ground-truth label, _i.e_. all labelled points of the same class fall
into the same cluster.

##  Appendix A Dataset details

Here, we describe which classes constitute the ‘Old’ and ‘New’ categories in
the Generalized Category Discovery setting, for each dataset used in this
paper.

For all datasets, we sample 50% of the classes as ‘Old’ classes
($\mathcal{Y_{L}}$) and keep the rest as ‘New’
($\mathcal{Y_{U}}\setminus\mathcal{Y_{L}}$). For all datasets, except for
Herbarium19, we use the first 50% of classes (according to their class index)
in $\mathcal{Y_{L}}$. For Herbarium19, to account for the long-tailed nature
of the dataset, we randomly sample the ‘Old’ classes from the total list of
classes. Further details on the splits can be found in Tab. 1 in the main
paper.

##  Appendix B Semi-supervised $k$-means

We elaborate on the semi-supervised $k$-means algorithm for GCD (from Sec.
3.1.2 of the main paper) in Fig. 4.

##  Appendix C Estimating the number of classes

In Fig. 5, we provide motivation for our algorithm in Sec. 3.2 of the main
paper, which is used to estimate the number of classes in the dataset
($k=|\mathcal{Y_{L}}\cup\mathcal{Y_{U}}|$). 111Note that
$|\mathcal{Y_{L}}\cup\mathcal{Y_{U}}|=|\mathcal{Y_{U}}|$ as
$|\mathcal{Y_{L}}\subset\mathcal{Y_{U}}|$. We use the former notation for
clarity.

Specifically, we plot how the clustering accuracy on the labelled subset
($\mathcal{D_{L}}$) changes as we run $k$-means with varying $k$ on the entire
dataset ($\mathcal{D_{L}}\cup\mathcal{D_{U}})$, for a range of datasets. It
can be seen that the $ACC$ on the labelled subset follows an approximately
bell-shaped function for all datasets. Furthermore, the function is maximized
when $k$-means clustering is run with roughly the ground truth number of
classes for each dataset, indicating that optimizing for this maximum is a
reasonable way of identifying the total number of categories.

Figure 5: Plot showing how the clustering accuracy on the labelled subset
($\mathcal{D_{L}}$) changes as we run $k$-means, with varying $k$, on the
entire dataset ($\mathcal{D_{L}}\cup\mathcal{D_{U}}$). The ground-truth number
of classes in CIFAR10, CIFAR100, ImageNet-100 and CUB are $[10,100,100,200]$
respectively.

##  Appendix D Attention maps

Here, we expand upon the attention visualizations from Fig. 3. We first
describe the process for constructing them, before providing further examples
in Fig. 6.

##### Visualization construction:

The attention visualizations were constructed by considering how different
attention heads, supporting the output [CLS] token, attended to different
spatial locations. Specifically, consider the input to the final block of the
ViT model, $\mathbf{X}\in\mathbbm{R}^{(HW+1)\times D}$, corresponding to a
feature for each of the $HW$ patches fed to the model, plus a feature
corresponding to the [CLS] token. Here, $HW=14\times 14=196$ patches at
resolution $16\times 16$ pixels. These features are passed to a multi-head
self-attention ($MHSA$) layer which can be described as:

$MHSA(\mathbf{X})=[head_{1},\dots,head_{h}]\mathbf{W_{0}},$ (5)

where

$head_{j}=Attention(\mathbf{XW}_{j}^{Q},\mathbf{XW}_{j}^{K},\mathbf{XW}_{j}^{V}).$
(6)

In other words, the layer comprises several attention heads ($h=12$ in the ViT
model) which each independently attend over the input features to the block.
We refer to [41] for more details on the self-attention mechanism. We note
that, for each feature $i\in\mathbf{X}$, an attention vector is generated for
each head $j$, as $A_{ij}\in[0,1]^{HW+1}$ to describe how every head $j$
relates each feature to every other feature.

We look at only the attention values for the [CLS] token, $A_{0j}$, and
further only look at the elements which attend to spatial locations. We find
that, while some heads have uninterpretable attention maps, certain heads
specialize to attend to coherent semantic object parts.

##### Discussion on attention visualizations

We provide further attention visualizations in Fig. 6. We show the same
attention heads as shown in Fig. 3 (both for models trained with our method
and for the original DINO model).

We first note that the DINO features often attend to salient object regions.
For instance, ‘Head 1’ of the model often focuses on the wheel of the car (in
the Stanford Cars examples), while ‘Head 2’ of the model generally attends to
the heads of the birds (in the CUB examples). Overall, however, with the pre-
trained DINO model, there is relatively little semantic consistency between
the attention maps of a given head (_i.e_. within columns for each dataset).

In contrast, we find that the models trained with our approach specialize
attention heads in semantically meaningful ways. The heads shown correspond to
‘Windshield’, ‘Headlight’ and ‘Wheelhouse’ for the Stanford Cars model, and
‘Beak’, ‘Head’ and ‘Belly’ for the CUB model. We find these maps to be
relatively robust to nuisance factors such as pose and scale shift, as well as
distracting objects in the image. We note a failure case (rightmost image, Row
2), as the ‘Wheelhouse’ attention head is forced to attend to miscellaneous
regions of the car, as the car’s wheelhouse is not visible in this image.

The ability of the model to identify and distinguish different semantic parts
of an object is useful for the GCD task. Particularly in the fine-grained
setting, the constituent set of parts of an object (‘Head’, ‘Beak’, ‘Belly’
_etc_. for the birds) transfer between ‘Old’ and ‘New’ classes. Thus, we
suggest that the attention mechanism of the model allows it to generalize its
understanding from the labelled ‘Old’ classes, and apply it to the unlabelled
‘New’ ones.

Figure 6: Attention visualizations. Attention maps for the DINO model before
(left) and after (right) fine-tuning with our approach on the Stanford Cars
(top) and CUB (bottom) datasets. For each dataset, we show two rows of images
from the ‘Old’ classes (solid green box) and two rows of images from the ‘New’
classes (dashed red box). Our model learns to specialize attention heads
(shown as columns) to different semantically meaningful object parts, which
can transfer between the ‘Old’ and ‘New’ categories.


# An infrared light-guide based target positioning system for operation in a
harsh environment

Falk Schupp<EMAIL_ADDRESS>Michael Bölting  Patrick Achenbach111Now at
Thomas Jefferson National Accelerator Facility, 12000 Jefferson Avenue,
Newport News, VA, USA. Sebastian Bleser  Josef Pochodzalla  Marcell Steinen

on behalf of the $\overline{\text{P}}$ANDA collaboration  Helmholtz Institute
Mainz, GSI Helmholtz Centre for Heavy Ion Research, Darmstadt, Johannes
Gutenberg University, 55099 Mainz, Germany  Institute for Nuclear Physics,
Johannes Gutenberg University, 55099 Mainz, Germany

###### Abstract

In the $\overline{\text{P}}$ANDA experiment’s hypernuclear and hyperatom
setup, a positioning system for the primary production target is required,
which will be located in the center of the solenoid magnet, in ultra-high
vacuum, and exposed to high radiation levels. In this work, a prototype for a
positioning sensor was built using a bisected light guide for infrared light
and a low-priced readout system based on microcontrollers. In contrast to many
modern positioning systems that require electronics in direct proximity, this
setup has no active electronic components close to the moving parts.

The prototype system was operated with a resolution of better than
$5\text{\,}\mathrm{\SIUnitSymbolMicro m}$, and with a repeatability of better
than $\pm$ $18\text{\,}\mathrm{\SIUnitSymbolMicro m}$ in a total of 14 000
measurements. The demonstrated performance is by far satisfying the
positioning requirement of $\pm$ $300\text{\,}\mathrm{\SIUnitSymbolMicro m}$
in the hypernuclear and hyperatom setup at $\overline{\text{P}}$ANDA.

††journal: Nucl. Instrum. Methods Phys. Res.

##  1 Introduction

The large production cross section for hyperons and antihyperons in antiproton
induced interactions provides an unprecedented tool to study strange baryons
and antibaryons in nuclear system. The antiProton ANnihilations at DArmstadt
($\overline{\text{P}}$ANDA) experiment, which is a planned fixed-target
experiment at the international Facility for Antiproton and Ion Research
(FAIR) [1], is the ideal place for such studies. $\overline{\text{P}}$ANDA is
intended to operate at the antiproton storage ring HESR and it will address
various aspects of the strong interaction, with strangeness nuclear physics
being one of its research pillars [2, 3, 4, 5, 6, 7, 8]. These studies are
made possible by the modular structure of the $\overline{\text{P}}$ANDA
detector which allows to integrate a dedicated target station, that combines a
primary production target with a secondary target to stop the produced
hyperons and antihyperons. This paper focuses on the positioning system for
the primary targets in the center of the target station.

##  2 The target system of the hypernuclear and hyperatom setup

Figure 1: CAD drawing of the target setup indented to be used at
$\overline{\text{P}}$ANDA. The beam enters from the right and passes through a
hollow Pb barrel (green) along its axis. Up to five diamond filament targets
are mounted on thin frames (red). A frame can be moved into the barrel through
a thin slot by a piezo motor. In case a filament needs to be replaced, its
frame will be moved out of the barrel and a slide (gray) will bring another
frame into position. The piezo motor for the movement of the slide in
$z$-direction is mounted beneath.

The primary target will be made from a thin carbon filament which will be
moved into the halo of the antiproton beam. It will be located inside the
$\overline{\text{P}}$ANDA solenoid approximately
$55\text{\,}\mathrm{c}\mathrm{m}$ upstream of the hydrogen target position
[6]. For the strangeness nuclear physics measurements, $\Xi^{-}$ hyperons will
be produced in $\overline{p}\,+\,^{12}$C interactions and subsequently stopped
inside the secondary target. In case of the planned $\Xi^{-}$ hyperatom
studies, this secondary target will be made of a Pb barrel surrounding the
beam and the primary target. The primary target system has to meet several
requirements:

  * 1.

During the filling of the storage ring with antiprotons, the filament needs to
be retracted from the circulating beam. This will happen typically once per
hour.

  * 2.

During data taking, the number of antiprotons will decrease monotonously. In
order to keep the luminosity constant, the filament has to be moved
continuously closer to the center of the beam by up to one millimeter.

  * 3.

Carbon filaments are very filigree and radiation damage during operation could
require a replacement. Therefore, the system must be able to remotely extract
a damaged filament, move a replacement into position, and insert it through a
thin slit into the beam pipe.

  * 4.

The system must operate in ultra-high vacuum, inside a $2\text{\,}\mathrm{T}$
solenoid magnetic field, and less than $10\text{\,}\mathrm{c}\mathrm{m}$ away
from the antiproton interaction point.

  * 5.

To optimize the capture probability of the short-lived $\Xi^{-}$ and to
minimize the absorption of gamma rays emitted from hyperatoms or hypernuclei,
the system must be as compact as possible.

The environmental conditions pose severe restriction on the use of
commercially available active electronics for monitoring the movements.
Therefore, we developed a system based on piezo motors for positioning and an
infrared sensor with light guides for monitoring. In this system there is no
need for active electronics in the proximity of the antiproton interaction
point, and it is capable of operating under a wide range of environmental
conditions to satisfy the above requirements. Although we refer in this paper
to the target systems of the planned hyperatom and hypernucei measurements at
$\overline{\text{P}}$ANDA, a similar setup based on piezo motors as driving
systems may be used in other experiments where similar conditions apply.

Figure 1 shows a CAD drawing of the target setup indented to be used at
$\overline{\text{P}}$ANDA for the study of $\Xi^{-}$-Pb hyperatoms. The size
of the setup is indicated by the coordinate system on the left. The beam
enters from the right and passes through a hollow Pb barrel along its axis.
The diamond filaments are mounted on thin frames. A frame can be moved into
the barrel through a $2\text{\,}\mathrm{mm}$ wide slot by a piezo motor. In
case a filament needs to be replaced, its frame will be moved out of the
barrel and a slide can be moved to an alternative position to move in another
frame. The slide movement in $z$-position is realized by a piezo motor mounted
beneath.

The overall thickness of the frame is about
$500\text{\,}\mathrm{\SIUnitSymbolMicro m}$. Considering the possible side
clearance of the moving rod and mechanical uncertainties, the system is
required to reliably position a frame within bounds of about $\pm
300\text{\,}\mathrm{\SIUnitSymbolMicro m}$.

Figure 2: Functional principle of the positioning system (top) and a
corresponding measured signal sequence during slide movement with constant
velocity. Three representative situations are shown.

##  3 The infrared light-based positioning system

To monitor the slide position, light is injected perpendicular on a reflector
by a bidirectional light guide. In this way, the sensor and electronics can be
placed at a safe distance — up to several meters — from the interaction point
of the antiprotons. The light intensity collected via the light guide depends
on its distance to the reflector and on the surface characteristics of the
reflector as illustrated in the top part of Figure 2. The signal sequence
measured by a sensor while moving the reflector with constant velocity over
the light guide is shown in the bottom part of the figure. In this study, time
is a measure of the position of the reflector with respect to the light guide.
In situation (a), the incident light hits the reflector (gray)
perpendicularly, and the largest intensity is reflected towards the light
guide (black arrows). This results in a maximum of the measured voltage signal
as shown in the bottom part of the figure. In position (b), the surface
reflects a fraction of the incident light out of the acceptance of the light
guide (red arrows). A suitable reflector geometry produces a minimum in the
voltage signal at this position. While reaching the top of the elevation the
signal rises again and forms a local maximum (c). Following this, the signal
sequence is reversed. Both minima are easy to identify and can be used for
positioning the target system. The height of the local maximum however,
depends strongly on the alignment of the plateau of the ridge with respect to
the light guide. As a consequence, the signal shape and amplitude will vary
with each modification of the light guide setup.

##  4 The prototype setup

Figure 3: Photographs of the Tippkemper-Matrix IRS-U2LA optical sensor and the
bisected light guide. Its two sections were illuminated differently for
demonstration. Figure 4: Rear view of the positioning stage with the light
guide seen on the left and the laser-based position monitor in the center. In
the background the reflector with different vertical elevations is visible.

In a prototype setup we used a Tippkemper-Matrix opto-electronic analog sensor
of type IRS-U-2LA [9] using infrared light with
$880\text{\,}\mathrm{n}\mathrm{m}$, coupled to a $1\text{\,}\mathrm{m}$ long
bisected light guide with a diameter of $2\text{\,}\mathrm{m}\mathrm{m}$ (up
to $15\text{\,}\mathrm{m}$ length available) and an optical aperture angle of
the light guide’s head of approximately
$65\text{\,}\mathrm{\SIUnitSymbolDegree}$.

Both ends of the light guide are shown to the left in Figure 3. The insert
shows an enlarged view of both sections of the light guide. For this
photograph the two sections were illuminated differently. The light guide is
coupled to the laser and the optical sensor, respectively, by means of a
proximity sensor, which is depicted in the upper right of Figure 3.

Figure 5:  Top: parameters describing the ridge geometry (c.f. Table 1). Bottom: microscope photographs of ridge no. 2 viewed from the top (left) and from the side (right). No. | Total width | Top width | Slope 1 | Slope 2
---|---|---|---|---
Design | Actual | Design | Actual | Actual | Actual
1 | 2.5 | 2.5 | 0.5 | 0.5 | 1.0 | 1.0
2 | 3.0 | 2.9 | 1.0 | 1.0 | 0.9 | 1.0
3 | 3.5 | 3.4 | 1.5 | 1.5 | 1.0 | 1.0
4 | 4.0 | 3.9 | 2.0 | 2.1 | 1.0 | 0.8
5 | 4.5 | 4.5 | 2.5 | 2.3 | 1.2 | 1.0
Table 1: Design and actual values in $\text{\,}\mathrm{mm}$ for the five
different ridges of the reflector. All values were measured using a ZEISS
O-INSPECT 5/4/3 [10]. The uncertainty of the top width is about
$0.1\text{\,}\mathrm{mm}$ for ridge no. 1–4 and $0.2\text{\,}\mathrm{mm}$ for
no. 5. Each ridge had a height of approximately $1\text{\,}\mathrm{mm}$.
Figure 6: Measured signal of the Tippkemper sensor for one pass of the setup
over the entire reflector at a distance of $4\text{\,}\mathrm{mm}$. Except for
the pair on the left, the signal saturated between the two related minima.
Therefore, unlike in Figure 2, the position of local maxima could not be
observed. The distance between the minima correlates with the plateau sizes
listed in Table 1. The top part illustrates the geometry of corresponding
ridges nos. 1 to 5 from left to right.

This system was mounted on the target setup actuated by a friction-based piezo
motor (Piezo LEGS Linear 6N, LL1011D [11]). To independently verify the
position, a laser-based position monitor (MicroE Systems M1000V [12]) was
mounted together with the light guide. The encoder of that position monitor
has a native resolution of $5\text{\,}\mathrm{\SIUnitSymbolMicro m}$ when used
without interpolation. However, since this encoder is not radiation hard, it
cannot be used during operation at $\overline{\text{P}}$ANDA. A photography of
the prototype setup is shown in Figure 4. On the left, the bi-directional
light guide can be seen. The laser-based position monitor is located in the
center. In the background, the moving reflector with five vertical ridges is
visible. At $\overline{\text{P}}$ANDA, the reflector will be mounted on the
$z$-position slide, see Figure 1.

The prototype setup was controlled with Arduino Due microcontrollers using the
onboard analog-to-digital converters for the measurements. One microcontroller
was used exclusively to process the signal of the laser-based position
monitor. The second microcontroller served as a control system, measuring the
signal of the Tippkemper sensor, controlling the movements with the piezo
motors, and to save the recorded data of both sensors.

A milled and surface treated aluminium plate (surface roughness $Ra=$
$0.4\text{\,}\mathrm{\SIUnitSymbolMicro m}$) with five different trapezoidal
shaped ridges was used as reflector. The parameters describing the geometry of
the ridges are defined in the top part of Figure 5. In Table 1, the design
values of the 5 ridges on the reflector are listed, as are the actual values
of the produced reflector, measured with a Zeiss O-Inspect 543. The width of
the top of the shapes was varied in the range between
$0.5\text{\,}\mathrm{mm}$ and $2.5\text{\,}\mathrm{mm}$. To verify the surface
quality, photographs were taken with a microscope, showing the aluminium
surface with only minor irregularities and well defined edges. As an example,
the lower part of Figure 5 shows photographs of ridge no. 2.

Since the light guide was bisected in two distinct sectors, see Figure 3, care
had to be taken of the light guide’s alignment: defined as the angle $\phi$
between the separation line of the two sectors of the light guide and the
direction of movement of the reflector. The positive value of $\phi$ means
that the emitting sector approaches the ridge first. The head of the light
guide was placed in a bracket in front of the aluminium reflector so that the
incident light is perpendicular to the reflector surface, while still allowing
to vary distance and alignment. Even after carefully inserting the light
guide, a deviation of $\Delta\phi=\pm$$$ from its intended direction can not
be excluded.

In the following, the gap between the light guide and the flat top of the
ridges will be denoted as $d_{\mathrm{LR}}$. Due to the limited space
available in the prototype, the gap is limited to a ranges of
$d_{\mathrm{LR}}$ = 0 to $5\text{\,}\mathrm{mm}$. In practice, a certain
minimum distance of about $1\text{\,}\mathrm{mm}$ is required for the
reflected light to be able to reach the receiving sector of the light guide.

##  5 Systematic study of the positioning system

Figure 7: Signal of ridge no. 3 measured at different gaps $d_{\mathrm{LR}}$.
The relative positions were chosen in such a way that the midpoint between the
two minima lies on top of each other.

In the following, the detected light intensity is studied when changing the
gap $d_{\mathrm{LR}}$ between the light guide and the reflector as well as the
orientation $\phi$ of the bisected light guide. The default value for the gap
was $d_{\mathrm{LR}}=$ $2\text{\,}\mathrm{mm}$ and the parting line between
the two sections was perpendicular to the ridges, i.e. $\phi=$$$.

The lower part of Figure 6 shows the measured signal of the Tippkemper sensor
for one full pass of the setup over the entire reflector at a gap of
$d_{\mathrm{LR}}=$ $4\text{\,}\mathrm{mm}$. If the injected light hits the
slopes of the ridges it is scattered out of the acceptance of the light guide.
The five ridges of the reflector have very similar slopes and differ mainly in
the width of the plateau, see Table 1. As a consequence, the depths of the
minima in the detected light are similar (c.f. situation (b) in Figure 2).
Because of a high incident light intensity, the sensor reached saturation of
the analog-to-digital converter at positions away from the ridges and in the
center of the ridges where a significant fraction of the injected light is
reflected into the acceptance of the collecting section (c.f. Figure 3).

Figure 8: Mean separation between two minima for the different widths of the
reflector plateaus and different gaps $d_{\mathrm{LR}}$. For each gap 200
scans in total (100 for each direction of motion) were performed. As an
example, the regression line for $d_{\mathrm{LR}}=$ $1\text{\,}\mathrm{mm}$
illustrates the approximate linear dependency.

Figure 7 shows the signal from ridge no. 3 for different gaps between the
light guide and the plateau. For all distances, the minima are clearly
visible. The adjustment of the gap required an intervention into the
mechanical setup. To overlay the different measurements for the different
gaps, the relative positions were aligned at the midpoint between the two
minima. The relative position of the minima shifted only slightly for larger
gaps. Because of the bisected geometry of the light guide, a major fraction of
the reflected light does not enter the sensitive area of the light guide for
very small gaps $\sim$ $1\text{\,}\mathrm{mm}$. As a consequence, the sensor
did not saturate and a local maximum developed in the center between the two
minima (black points in Figure 7).

The widths of the plateaus seen in Figure 6 correspond to the widths of the
ridge as displayed in the upper part of the figure and listed in Table 1.
However, the observed plateaus also depend on the incident light intensity and
hence also on the gap. In fact, the locations of the minima in Figure 6 are
less sensitive to the intensity of the incident light. We evaluated the mean
distance ${\Delta}d_{min}$ between two minima from 200 scans to characterize
the observed intensity function and to study the effect of the width of the
ridge.

Figure 8 shows ${\Delta}d_{min}$ as a function of the measured top widths
(c.f. Table 1). The different colors correspond to different gaps. The
regression line for a gap of $1\text{\,}\mathrm{mm}$ illustrates a
approximately linear dependency except for the widest ridge. This irregularity
may reflect the uncertainty in the optical measurements.

##  6 Precision of the position determination

High accuracy and high precision of the $z$-position slide is required. Since
the movement can not be independently controlled, a self-calibration procedure
is needed which provides a low bias and a high repeatability. To determine the
quality of the prototype system, the setup was moved repeatedly over all five
ridges. The analog output of the Tippkemper sensor and the position
information of the laser-based monitor was recorded simultaneously. The data
could than be used in an offline analysis to find all minima in the analog
voltage signal and their corresponding positions. The midpoint between two
corresponding minima was used as a measure of the $z$-position.

As an example, Figure 9 shows the measured position of the first peak for
ridge no. 3. For this measurement, 1000 scans at a fixed gap of
$2\text{\,}\mathrm{mm}$ were performed. The data are shown separately for the
two directions of motion. The measured position depends on the direction
because of the finite processing time of the Tippkemper module. The time to
process the optical information within the readout electronics of the sensor
is specified by the manufacturer with up to $5\text{\,}\mathrm{ms}$. Based on
the average driving speed of the setup, the difference between the two
positions in Figure 9 corresponds to approximately $6.5\text{\,}\mathrm{ms}$.
This difference is within the specified value when considering that the delay
affects the motion in an opposite way for the two directions. Using an
improved sensor with less delay could reduce this effect. In the present setup
we can eliminate this bias by approaching a position always from the same
side, and calibrating each position taking the delay into account. It was
verified that the delay is constant over time by determining it for each pair
of left$/$right movements. The root-mean- square (rms) width of the peaks is
$\sigma\sim$ $5\text{\,}\mathrm{\SIUnitSymbolMicro m}$, which proves the
excellent precision of the setup.

Figure 9: Distribution of the position of the first minimum for ridge no. 3 separated for the two directions of motion. Here, a gap of $d_{\mathrm{LR}}=$ $2\text{\,}\mathrm{mm}$ and an orientation of the light guide of $\phi=$$$ was chosen. For each direction of the motor, 1000 scans were performed. One bin of the histogram corresponds to one step of the laser-based position monitor. Ridge no. |  $\sigma_{\mathrm{min1}}$ [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$] |  $\sigma_{\mathrm{min2}}$ [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$]
---|---|---
1 | $2.6\pm 0.2\text{\,}$ | $3.6\pm 0.3\text{\,}$
2 | $2.5\pm 0.2\text{\,}$ | $2.6\pm 0.2\text{\,}$
3 | $3.2\pm 0.3\text{\,}$ | $4.9\pm 0.4\text{\,}$
4 | $2.6\pm 0.2\text{\,}$ | $2.4\pm 0.2\text{\,}$
5 | $2.9\pm 0.2\text{\,}$ | $2.5\pm 0.2\text{\,}$
Table 2: Position resolution for all 5 ridges at a fixed gap
$d_{\mathrm{LR}}=$ $2.0\pm 0.2\text{\,}\mathrm{mm}$ and an alignment angle of
$\phi=$$\pm$$$. For this measurement, 100 scans were performed for each ridge.

100 scans over of all five ridges were performed. For a selected gap of
$d_{\mathrm{LR}}=$ $2\text{\,}\mathrm{mm}$ the achieved precision is given in
Table 2. Since each ridge results in two minima, both rms widths are listed.
For ridge no. 3 the resolution seems to be slightly worse. In all cases, the
resolution is better than $5\text{\,}\mathrm{\SIUnitSymbolMicro m}$. The light
guide was first installed with a parallel alignment of $\phi=$$$. Then, the
light guide was rotated by $None$ and the measurement was repeated. Finally,
the transmitting and receiving side were inverted to $\phi=$$$. For each of
the three alignment angles $\phi$ at a fixed gap of $2\text{\,}\mathrm{mm}$,
the rms widths for all five ridges were determined. The weighted mean standard
deviations, serving as a measure of precision for each alignment, are listed
in Table 3. A parallel alignment is superior to a perpendicular one. In the
parallel case, the light guide is symmetric relative to the axis of motion of
the reflector and combined with the symmetric reflector shape this is expected
to lead to symmetric signals at the left and right slope. In the perpendicular
case, the distribution of light depends on whether the slope is moved near the
emitting or receiving sector first.

Alignment $\phi$ | Precision $\sigma$ [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$]
---|---
$$$\pm$$$ | $2.8\pm 0.1\text{\,}$
$$$\pm$$$ | $8.8\pm 0.2\text{\,}$
$$$\pm$$$ | $10.9\pm 0.3\text{\,}$
Table 3: Dependence of the measured precision for the position on the alignment of the bisected light guide. The gap was $2\text{\,}\mathrm{mm}$. A positive angle $\phi$ indicates that the emitting sector of the light guide approached the trapezoidal shaped ridge first. Gap $d_{LR}$ [$\text{\,}\mathrm{mm}$] | Precision $\sigma$ [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$]
---|---
$1.0\pm 0.2\text{\,}$ | $3.7\pm 0.1\text{\,}$
$2.0\pm 0.2\text{\,}$ | $2.8\pm 0.1\text{\,}$
$3.0\pm 0.2\text{\,}$ | $3.4\pm 0.1\text{\,}$
$4.0\pm 0.2\text{\,}$ | $3.8\pm 0.1\text{\,}$
$5.0\pm 0.2\text{\,}$ | $5.2\pm 0.1\text{\,}$
Table 4: Dependence of the measured precision of the position on the gap
between the light guide and the reflector. The alignment angle was $$$\pm$$$.

The dependence on the gap was also studied and the weighted mean standard
deviation of all measured minima was used as a measure of precision. The
results are listed in Table 4. For the setup used in our study, a distance of
$2\text{\,}\mathrm{mm}$ was optimal, with a significant degradation of the
precision with increasing or decreasing gaps. In all cases, the precision was
better than $\sigma\approx$ $5\text{\,}\mathrm{\SIUnitSymbolMicro m}$.

In our test setup, the accuracy of the absolute position determination was
limited by the resolution of $5\text{\,}\mathrm{\SIUnitSymbolMicro m}$ of the
laser-based encoder. Any further improvement of the accuracy would require the
use of the encoder’s interpolation feature.

To quantify the reliability with which a selected position can be approached,
we determined the maximum deviation from the mean position for 1000 scans for
ridge no. 3 as shown in Figure 9. The base widths are
$11\text{\,}\mathrm{\SIUnitSymbolMicro m}$ and
$25\text{\,}\mathrm{\SIUnitSymbolMicro m}$ for the two directions. Approaching
a position from the same direction, the largest deviation will be of the order
of $\pm$ $15\text{\,}\mathrm{\SIUnitSymbolMicro m}$.

During a long-term measurement, the five ridges were scanned 7000 times for
each direction of motion. For the two directions, maximum deviations of
$35.4\text{\,}\mathrm{\SIUnitSymbolMicro m}$ and
$30.4\text{\,}\mathrm{\SIUnitSymbolMicro m}$ were observed. Thus, the
repeatability was better than $\pm$$18\text{\,}\mathrm{\SIUnitSymbolMicro m}$.

##  7 Summary

A positioning sytem was built using a bisected light guide with infrared light
and a low-priced readout system based on microcontrollers. The system was
proven to operate with a resolution of better than
$5\text{\,}\mathrm{\SIUnitSymbolMicro m}$, which is more than sufficient for
use in the hypernuclear and hyperatom experiments at
$\overline{\text{P}}$ANDA. In 14 000 measurements, the repeatability was
better than $\pm$ $18\text{\,}\mathrm{\SIUnitSymbolMicro m}$ and thus far
better than the maximum allowed deviation at $\overline{\text{P}}$ANDA of
$\simeq$ $300\text{\,}\mathrm{\SIUnitSymbolMicro m}$.

Finally, it is important to note, that in case of a loss of the sensor status,
e.g. during long-time operation at $\overline{\text{P}}$ANDA, the position can
be re-calibrated by approaching the endpoints or by a scan over one or more
ridges with an accuracy of better than $\pm$
$5\text{\,}\mathrm{\SIUnitSymbolMicro m}$. We, therefore, conclude that the
reliability of the system will be sufficient for a safe operation at
$\overline{\text{P}}$ANDA.

In future, several questions could be addressed for a further improvement of
such a system.

  * 1.

Alternative geometries of the ridges, e.g. different slopes or different
shapes, could be investigated.

  * 2.

Polishing or gold-plating the reflector could reduce local variations of the
reflectivity.

  * 3.

Improved sensor electronics could help to minimize the latency of the readout.

  * 4.

Using a statistically mixed light guide could reduce the sensitivity to the
direction of movement.

  * 5.

The placement of the light guide relative to the reflector surface could be
optimized.

Commercially available solutions such as laser-based position encoders may
offer better resolutions, however, the major advantage of the presented system
is its endurance under harsh environmental conditions. The presented method
could also be of interest for other applications.

## Acknowledgement

This project has received travel funds from the European Union’s Horizon 2020
research and innovation programme under grant agreement No 824093.

We would also like to thank Heinrich Leithoff from the Helmholtz Institute
Mainz for his contribution to this work by measuring the reflector geometry
with a Zeiss O-Inspect.

The presented data were in part collected within the work of the diploma
thesis of Falk Schupp and the doctoral thesis of Michael Bölting, both at the
Helmholtz Institute Mainz of the Johannes Gutenberg University Mainz.

## References

  * [1] G. Barucca, F. Davì, G. Lancioni, P. Mengucci, L. Montalto, P. P. Natali, N. Paone, D. Rinaldi, L. Scalise, B. Krusche, M. Steinacher, Z. Liu, C. Liu, B. Liu, X. Shen, S. Sun, G. Zhao, J. Zhao, M. Albrecht, W. Alkakhi, S. Bökelmann, S. Coen, F. Feldbauer, M. Fink, J. Frech, V. Freudenreich, M. Fritsch, J. Grochowski, R. Hagdorn, F. H. Heinsius, T. Held, T. Holtmann, I. Keshk, H. Koch, B. Kopf, M. Kümmel, M. Küßner, J. Li, L. Linzen, S. Maldaner, J. Oppotsch, S. Pankonin, M. Pelizäus, S. Pflüger, J. Reher, G. Reicherz, C. Schnier, M. Steinke, T. Triffterer, C. Wenzel, U. Wiedner, H. Denizli, N. Er, U. Keskin, S. Yerlikaya, A. Yilmaz, R. Beck, V. Chauhan, C. Hammann, J. Hartmann, B. Ketzer, J. Müllers, B. Salisbury, C. Schmidt, U. Thoma, M. Urban, A. Bianconi, M. Bragadireanu, D. Pantea, S. Rimjaem, M. Domagala, G. Filo, E. Lisowski, F. Lisowski, M. Michałek, P. Poznański, J. Płazek, K. Korcyl, P. Lebiedowicz, K. Pysz, W. Schäfer, A. Szczurek, M. Firlej, T. Fiutowski, M. Idzik, J. Moron, K. Swientek, P. Terlecki, G. Korcyl, R. Lalik, A. Malige, P. Moskal, K. Nowakowski, W. Przygoda, N. Rathod, P. Salabura, J. Smyrski, I. Augustin, R. Böhm, I. Lehmann, L. Schmitt, V. Varentsov, M. Al-Turany, A. Belias, H. Deppe, R. Dzhygadlo, H. Flemming, A. Gerhardt, K. Götzen, A. Heinz, P. Jiang, R. Karabowicz, S. Koch, U. Kurilla, D. Lehmann, J. Lühning, U. Lynen, H. Orth, K. Peters, J. Pütz, J. Ritman, G. Schepers, C. J. Schmidt, C. Schwarz, J. Schwiening, A. Täschner, M. Traxler, B. Voss, P. Wieczorek, V. Abazov, G. Alexeev, M. Y. Barabanov, V. K. Dodokhov, A. Efremov, A. Fechtchenko, A. Galoyan, G. Golovanov, E. K. Koshurnikov, Y. Y. Lobanov, A. G. Olshevskiy, A. A. Piskun, A. Samartsev, S. Shimanski, N. B. Skachkov, A. N. Skachkova, E. A. Strokovsky, V. Tokmenin, V. Uzhinsky, A. Verkheev, A. Vodopianov, N. I. Zhuravlev, D. Watts, M. Böhm, W. Eyrich, A. Lehmann, D. Miehling, M. Pfaffinger, K. Seth, T. Xiao, A. Ali, A. Hamdi, M. Himmelreich, M. Krebs, S. Nakhoul, F. Nerling, P. Gianotti, V. Lucherini, G. Bracco, S. Bodenschatz, K. T. Brinkmann, L. Brück, S. Diehl, V. Dormenev, M. Düren, T. Erlen, C. Hahn, A. Hayrapetyan, J. Hofmann, S. Kegel, F. Khalid, I. Köseoglu, A. Kripko, W. Kühn, V. Metag, M. Moritz, M. Nanova, R. Novotny, P. Orsich, J. P. de Lira, M. Sachs, M. Schmidt, R. Schubert, M. Strickert, T. Wasem, H. G. Zaunick, E. Tomasi-Gustafsson, D. Glazier, D. Ireland, B. Seitz, R. Kappert, M. Kavatsyuk, H. Loehner, J. Messchendorp, V. Rodin, K. Kalita, G. Huang, D. Liu, H. Peng, H. Qi, Y. Sun, X. Zhou, M. Kunze, K. Azizi, A. T. Olgun, Z. Tavukoglu, A. Derichs, R. Dosdall, W. Esmail, A. Gillitzer, F. Goldenbaum, D. Grunwald, L. Jokhovets, J. Kannika, P. Kulessa, S. Orfanitski, G. Perez-Andrade, D. Prasuhn, E. Prencipe, E. Rosenthal, S. Schadmand, R. Schmitz, A. Scholl, T. Sefzick, V. Serdyuk, T. Stockmanns, D. Veretennikov, P. Wintz, P. Wüstner, H. Xu, Y. Zhou, X. Cao, Q. Hu, Y. Liang, V. Rigato, L. Isaksson, P. Achenbach, O. Corell, A. Denig, M. Distler, M. Hoek, W. Lauth, H. H. Leithoff, H. Merkel, U. Müller, J. Petersen, J. Pochodzalla, S. Schlimme, C. Sfienti, M. Thiel, S. Bleser, M. Bölting, L. Capozza, A. Dbeyssi, A. Ehret, R. Klasen, R. Kliemt, F. Maas, C. Motzko, O. Noll, D. R. Piñeiro, F. Schupp, M. Steinen, S. Wolff, I. Zimmermann, D. Kazlou, M. Korzhik, O. Missevitch, P. Balanutsa, V. Chernetsky, A. Demekhin, A. Dolgolenko, P. Fedorets, A. Gerasimov, A. Golubev, A. Kantsyrev, D. Y. Kirin, N. Kristi, E. Ladygina, E. Luschevskaya, V. A. Matveev, V. Panjushkin, A. V. Stavinskiy, A. Balashoff, A. Boukharov, M. Bukharova, O. Malyshev, E. Vishnevsky, D. Bonaventura, P. Brand, B. Hetz, N. Hüsken, J. Kellers, A. Khoukaz, D. Klostermann, C. Mannweiler, S. Vestrick, D. Bumrungkoh, C. Herold, K. Khosonthongkee, C. Kobdaj, A. Limphirat, K. Manasatitpong, T. Nasawad, S. Pongampai, T. Simantathammakul, P. Srisawad, N. Wongprachanukul, Y. Yan, C. Yu, X. Zhang, W. Zhu, E. Antokhin, A. Y. Barnyakov, K. Beloborodov, V. E. Blinov, I. A. Kuyanov, S. Pivovarov, E. Pyata, Y. Tikhonov, A. E. Blinov, S. Kononov, E. A. Kravchenko, M. Lattery, G. Boca, D. Duda, M. Finger, M. Finger, A. Kveton, I. Prochazka, M. Slunecka, M. Volf, V. Jary, O. Korchak, M. Marcisovsky, G. Neue, J. Novy, L. Tomasek, M. Tomasek, M. Virius, V. Vrba, V. Abramov, S. Bukreeva, S. Chernichenko, A. Derevschikov, V. Ferapontov, Y. Goncharenko, A. Levin, E. Maslova, Y. Melnik, A. Meschanin, N. Minaev, V. Mochalov, V. Moiseev, D. Morozov, L. Nogach, S. Poslavskiy, A. Ryazantsev, S. Ryzhikov, P. Semenov, I. Shein, A. Uzunian, A. Vasiliev, A. Yakutin, S. Belostotski, G. Fedotov, A. Izotov, S. Manaenkov, O. Miklukho, B. Cederwall, M. Preston, P. E. Tegner, D. Wölbing, K. Gandhi, A. K. Rai, S. Godre, V. Crede, S. Dobbs, P. Eugenio, M. P. Bussa, S. Spataro, D. Calvo, P. D. Remigis, A. Filippi, G. Mazza, R. Wheadon, F. Iazzi, A. Lavagno, A. Akram, H. Calen, W. I. Andersson, T. Johansson, A. Kupsc, P. Marciniewski, M. Papenbrock, J. Regina, J. Rieger, K. Schönning, M. Wolke, A. Chlopik, G. Kesik, D. Melnychuk, J. Tarasiuk, M. Wojciechowski, S. Wronka, B. Zwieglinski, C. Amsler, P. Bühler, J. Marton, S. Zimmermann, C. S. Fischer, J. Haidenbauer, C. Hanhart, M. F. M. Lutz, S. M. Ryan, PANDA phase one, The European Physical Journal A 57 (6) (jun 2021).  doi:10.1140/epja/s10050-021-00475-y.
URL https://doi.org/10.1140%2Fepja%2Fs10050-021-00475-y

  * [2] J. Pochodzalla, Future hypernuclear physics at mami-c and panda-gsi, Nuclear Physics A 754 (2005) 430 – 442, proceedings of the Eighth International Conference on Hypernuclear and Strange Particle Physics.  doi:https://doi.org/10.1016/j.nuclphysa.2005.01.027.
URL http://www.sciencedirect.com/science/article/pii/S0375947405000813

  * [3] A. Sanchez Lorente, A. S. Botvina, J. Pochodzalla, Production of excited double hypernuclei via fermi breakup of excited strange systems, Physics Letters B 697 (3) (2011) 222 – 228.  doi:10.1016/j.physletb.2011.02.002.
URL http://www.sciencedirect.com/science/article/pii/S0370269311001237

  * [4] J. Pochodzalla, Exploring the potential of antihyperons in nuclei with antiprotons, Physics Letters B 669 (5) (2008) 306 – 310.  doi:10.1016/j.physletb.2008.10.016.
URL http://www.sciencedirect.com/science/article/pii/S0370269308012355

  * [5] A. Sanchez Lorente, S. Bleser, M. Steinen, J. Pochodzalla, Antihyperon potentials in nuclei via exclusive antiproton-nucleus reactions, Physics Letters B 749 (2015) 421 – 424.  doi:10.1016/j.physletb.2015.08.025.
URL http://www.sciencedirect.com/science/article/pii/S0370269315006267

  * [6] B. Singh, W. Erni, B. Krusche, M. Steinacher, M. Albrecht, T. Erlen, M. Fink, F. Heinsius, T. Held, T. Holtmann, S. Jasper, I. Keshk, H. Koch, B. Kopf, M. Kuhlmann, M. Kümmel, S. Leiber, M. Mikirtychyants, P. Musiol, A. Mustafa, M. Pelizäus, J. Pychy, M. Richter, C. Schnier, T. Schröder, C. Sowa, M. Steinke, T. Triffterer, U. Wiedner, M. Ball, R. Beck, C. Hammann, B. Ketzer, M. Kube, P. Mahlberg, M. Rossbach, C. Schmidt, R. Schmitz, U. Thoma, M. Urban, D. Walther, C. Wendel, A. Wilson, A. Bianconi, M. Bragadireanu, M. Caprini, D. Pantea, B. Patel, W. Czyzycki, M. Domagala, G. Filo, J. Jaworowski, M. Krawczyk, E. Lisowski, F. Lisowski, M. Michalek, P. Poznanski, J. Plazek, K. Korcyl, A. Kozela, P. Kulessa, P. Lebiedowicz, K. Pysz, W. Schäfer, A. Szczurek, T. Fiutowski, B. Kamys, S. Kistryn, G. Korcyl, W. Krzemien, A. Magiera, P. Moskal, A. Psyzniak, Z. Rudy, P. Salabura, J. Smyrski, P. Strzempek, A. Wronska, I. Augustin, R. Böhm, I. Lehmann, D. N. Marinescu, L. Schmitt, V. Varentsov, M. Al-Turany, A. Belias, H. Deppe, R. Dzhygadlo, A. Ehret, H. Flemming, A. Gerhardt, K. Götzen, A. Gromliuk, L. Gruber, R. Karabowicz, R. Kliemt, M. Krebs, U. Kurilla, D. Lehmann, S. Löchner, J. Lühning, U. Lynen, H. Orth, M. Patsyuk, K. Peters, T. Saito, G. Schepers, C. Schmidt, C. Schwarz, J. Schwiening, A. Täschner, M. Traxler, C. Ugur, B. Voss, P. Wieczorek, A. Wilms, M. Zühlsdorf, V. Abazov, G. Alexeev, A. Arefiev, V. Astakhov, M. Barabanov, B. Batyunya, Y. Davydov, V. Dodokhov, A. Efremov, A. Fechtchenko, A. Fedunov, A. Galoyan, S. Grigoryan, E. Koshurnikov, V. Lobanov, Y. Lobanov, A. Makarov, L. Malinina, V. Malyshev, A. Olshevskiy, E. Perevalova, A. Piskun, T. Pocheptsov, G. Pontecorvo, V. Rodionov, Y. Rogov, R. Salmin, A. Samartsev, M. Sapozhnikov, G. Shabratova, N. Skachkov, A. Skachkova, E. Strokovsky, M. Suleimanov, R. Teshev, V. Tokmenin, V. Uzhinsky, A. Vodopyanov, S. Zaporozhets, N. Zhuravlev, A. Zorin, D. Branford, D. Glazier, D. Watts, M. Böhm, A. Britting, W. Eyrich, A. Lehmann, M. Pfaffinger, F. Uhlig, S. Dobbs, K. Seth, A. Tomaradze, T. Xiao, D. Bettoni, V. Carassiti, A. C. Ramusino, P. Dalpiaz, A. Drago, E. Fioravanti, I. Garzia, M. Savriè, V. Akishina, I. Kisel, G. Kozlov, M. Pugach, M. Zyzak, P. Gianotti, C. Guaraldo, V. Lucherini, A. Bersani, G. Bracco, M. Macri, R. Parodi, K. Biguenko, K. Brinkmann, V. D. Pietro, S. Diehl, V. Dormenev, P. Drexler, M. Düren, E. Etzelmüller, M. Galuska, E. Gutz, C. Hahn, A. Hayrapetyan, M. Kesselkaul, W. Kühn, T. Kuske, J. Lange, Y. Liang, V. Metag, M. Nanova, S. Nazarenko, R. Novotny, T. Quagli, S. Reiter, J. Rieke, C. Rosenbaum, M. Schmidt, R. Schnell, H. Stenzel, U. Thöring, M. Ullrich, M. Wagner, T. Wasem, B. Wohlfarth, H. Zaunick, D. Ireland, G. Rosner, B. Seitz, P. Deepak, A. Kulkarni, A. Apostolou, M. Babai, M. Kavatsyuk, P. Lemmens, M. Lindemulder, H. Loehner, J. Messchendorp, P. Schakel, H. Smit, M. Tiemens, J. van der Weele, R. Veenstra, S. Vejdani, K. Dutta, K. Kalita, A. Kumar, A. Roy, H. Sohlbach, M. Bai, L. Bianchi, M. Büscher, L. Cao, A. Cebulla, R. Dosdall, A. Gillitzer, F. G. nd D. Grunwald, A. Herten, Q. Hu, G. Kemmerling, H. Kleines, A. Lehrach, R. Nellen, H. Ohm, S. Orfanitski, D. Prasuhn, E. Prencipe, J. Pütz, J. Ritman, S. Schadmand, T. Sefzick, V. Serdyuk, G. Sterzenbach, T. Stockmanns, P. Wintz, P. Wüstner, H. Xu, A. Zambanini, S. Li, Z. Li, Z. Sun, H. Xu, V. Rigato, L. Isaksson, P. Achenbach, O. Corell, A. Denig, M. Distler, M. Hoek, A. Karavdina, W. Lauth, Z. Liu, H. Merkel, U. Müller, J. Pochodzalla, S. Schlimme, C. Sfienti, M. Thiel, H. Ahmadi, S. Ahmed, S. Bleser, L. Capozza, M. Cardinali, A. Dbeyssi, M. Deiseroth, F. Feldbauer, M. Fritsch, B. Fröhlich, P. Jasinski, D. Kang, D. Khaneft, R. Klasen, H. Leithoff, D. Lin, F. Maas, S. Maldaner, M. Martìñez Rojo, M. Marta, M. Michel, M. Mora Espì, C. M. Morales, C. Motzko, F. Nerling, O. Noll, S. Pflüger, A. Pitka, D. Rodrìguez Piñeiro, A. Sanchez Lorente, M. Steinen, R. Valente, T. Weber, M. Zambrana, I. Zimmermann, A. Fedorov, M. Korjik, O. Missevitch, A. Boukharov, O. Malyshev, I. Marishev, P. Balanutsa, V. Balanutsa, V. Chernetsky, A. Demekhin, A. Dolgolenko, P. Fedorets, A. Gerasimov, V. Goryachev, V. Chandratre, V. Datar, D. Dutta, V. Jha, H. Kumawat, A. Mohanty, A. Parmar, B. Roy, G. Sonika, C. Fritzsch, S. Grieser, A. Hergemöller, B. Hetz, N. Hüsken, A. Khoukaz, J. Wessels, K. Khosonthongkee, C. Kobdaj, A. Limphirat, P. Srisawad, Y. Yan, M. Barnyakov, A. Barnyakov, K. Beloborodov, A. Blinov, V. Blinov, V. Bobrovnikov, S. Kononov, E. Kravchenko, I. Kuyanov, K. Martin, A. Onuchin, S. Serednyakov, A. Sokolov, Y. Tikhonov, E. Atomssa, R. Kunne, D. Marchand, B. Ramstein, J. Van de Wiele, Y. Wang, G. Boca, S. Costanza, P. Genova, P. Montagna, A. Rotondi, V. Abramov, N. Belikov, S. Bukreeva, A. Davidenko, A. Derevschikov, Y. Goncharenko, V. Grishin, V. Kachanov, V. Kormilitsin, A. Levin, Y. Melnik, N. Minaev, V. Mochalov, D. Morozov, L. Nogach, S. Poslavskiy, A. Ryazantsev, S. Ryzhikov, P. Semenov, I. Shein, A. Uzunian, A. Vasiliev, A. Yakutin, E. Tomasi-Gustafsson, U. Roy, B. Yabsley, S. Belostotski, G. Gavrilov, A. Izotov, S. Manaenkov, O. Miklukho, D. Veretennikov, A. Zhdanov, K. Makonyi, M. Preston, P. Tegner, D. Wölbing, T. Bäck, B. Cederwall, A. Rai, S. Godre, D. Calvo, S. Coli, P. D. Remigis, A. Filippi, G. Giraudo, S. Lusso, G. Mazza, M. Mignone, A. Rivetti, R. Wheadon, F. Balestra, F. Iazzi, R. Introzzi, A. Lavagno, J. Olave, A. Amoroso, M. Bussa, L. Busso, F. D. Mori, M. Destefanis, L. Fava, L. Ferrero, M. Greco, J. Hu, L. Lavezzi, M. Maggiora, G. Maniscalco, S. Marcello, S. Sosio, S. Spataro, R. Birsa, F. Bradamante, A. Bressan, A. Martin, H. Calen, W. I. Andersson, T. Johansson, A. Kupsc, P. Marciniewski, M. Papenbrock, J. Pettersson, K. Schönning, M. Wolke, B. Galnander, J. Diaz, V. P. Chackara, A. Chlopik, G. Kesik, D. Melnychuk, B. Slowinski, A. Trzcinski, M. Wojciechowski, S. Wronka, B. Zwieglinski, P. Bühler, J. Marton, D. Steinschaden, K. Suzuki, E. Widmann, J. Zmeskal, J. Gerl, I. Kojouharov, J. Kojouharova, Study of doubly strange systems using stored antiprotons, Nuclear Physics A 954 (2016) 323–340, recent Progress in Strangeness and Charm Hadronic and Nuclear Physics.  doi:10.1016/j.nuclphysa.2016.05.014.
URL http://www.sciencedirect.com/science/article/pii/S0375947416301282

  * [7] M. Steinen, P. Achenbach, M. Bölting, J. Pochodzalla, F. Schupp, Heavy $\Xi^{-}$ hyperatoms at $\overline{\mbox{P}}$ANDA, PoS PANIC2021 (2022) 207.  doi:10.22323/1.380.0207.
  * [8] Christiansen, Martin, Schupp, Falk, Achenbach, Patrick, Bölting, Michael, Pochodzalla, Josef, Steinen, Marcell, Exploring the neutron skin by hyperon-antihyperon production in antiproton-nucleus interactions, EPJ Web Conf. 271 (2022) 02011.  doi:10.1051/epjconf/202227102011.
URL https://doi.org/10.1051/epjconf/202227102011

  * [9] Tippkemper-Matrix GmbH, Proximity Switch from Product family IRS-LA / IRN-LA / IRD-LA (2020).
URL https://www.tippkemper-matrix.de/en/products/measuring-
sensors/photoelectric-proximity-switches/irs-la-irn-la-ird-la-optical-
proximity-switches/

  * [10] Carl Zeiss IQS Deutschland GmbH, ZEISS O-INSPECT (2022).
URL https://www.zeiss.de/messtechnik/produkte/systeme/optical-
measurement/o-inspect.html#technicaldata

  * [11] PiezoMotor, Piezo LEGS (2020).
URL http://www.piezomotor.com/linear-motors

  * [12] Celera Motion, MicroE Mercury™1000V: Vacuum Rated Analog Encoder (2003).
URL https://www.celeramotion.com/microe/products/linear-
encoders/compact/mercury-series-m1000/