# Amur Tiger Re-identification

*English translation by SOTA – AI Community of the Russian original. Organisers who would like this translation removed can email sota.ai.community@gmail.com.*

*Source: the 2024/25 task collection of the National Technology Olympiad (NTO), "Artificial Intelligence" profile, Final Stage, engineering tour, pp. 144–148, with the final-stage part of the scoring criteria from p. 149: [original PDF](https://ntcontest.ru/upload/sborn2025/%D0%98%D0%98.pdf#page=144).*

## 4.3. Engineering tour

### 4.3.1. General information

The task of the final stage is devoted to the re-identification of wild animals (identifying specific individuals) from camera-trap photos.

Some species have individual features (coat colouring). Scientists create catalogues of the individuals of an identifiable animal species and identify each specific individual from photos, which makes monitoring of the species more efficient.

Artificial intelligence technologies help to process data for re-identification faster and more easily. This saves zoologists' time, allowing them to focus more on saving animals and on scientific research.

Participants in the final stage must solve the task of re-identifying Amur tigers from camera-trap photos using computer vision and metric learning. The embeddings for photos of the same individual must be as close to one another as possible and as different as possible from the embeddings of other individuals.

### 4.3.2. Task background

The Amur tiger is listed in the Red Book of the Russian Federation. Population monitoring helps to collect data on the number of tigers, their distribution and the state of their habitat. This is the basis for developing effective measures to protect and restore the population.

Camera traps make it possible to track the behaviour of tigers, their migration routes, their habitat preferences and their interactions with other species. These data help to study ecosystem relationships and to influence the conservation of the whole species on a broader level.

Zoologists identify individual tigers by the individual pattern on the animal's skin in the photo, and the pattern is different on each side. Re-identification and monitoring of each individual animal make it possible to track the tiger population more effectively.

You need to train a computer vision model that produces a digital representation (an embedding) for a crop containing an image of a tiger from a camera trap.

### 4.3.3. Team requirements and participant competences

Number of participants in a team: 2 people.

Competences that team members must have:

- Data analyst: searching for open data and its exploratory analysis.
- Data Scientist: training the model.

### 4.3.4. Equipment and software

**Table 4.3.1**

| Item | Description |
|---|---|
| Laptops: RAM — 16 GB, SSD storage — 256 GB, processor — Intel Core i3. | For access to the Cloud and internet resources |
| Cloud account (GPU parameters: V100 32Gb) | Training models |

### 4.3.5. Task description

#### Data

The dataset is a set of images in the form of an image archive (`train`, `test`) and a file `train.csv`. It contains difficult examples: photos in which only part of the animal is in the frame or its body is split by an obstacle, as well as night-time and blurred shots. The data were labelled by data-labelling specialists together with zoologists.

The data are split into a training set and a test set in a ratio of approximately 70% and 30% by individual.

The file `train.csv` contains the following columns:

- `file_name` — file name;
- `label` — name of the individual;
- `sequence` — number of the photo series to which this photo belongs;
- `side` — side of the individual in the photo (`left`/`right`).

Materials for the solution:

- folder with photos for training (train): <https://disk.yandex.ru/d/t6YCFGkgodFOCA/train.zip>.
- folder with photos for the test part (test): <https://disk.yandex.ru/d/t6YCFGkgodFOCA/test.zip>.
- file with the labels for the training part: <https://disk.yandex.ru/d/t6YCFGkgodFOCA/train.csv>.

#### Baseline

The example solution given for the task of re-identifying animals in an image is based on the `open metric learning` library (`resnet50` architecture).

The baseline takes you all the way from installing the libraries and training the model to obtaining a file with predictions and the training logs.

Link to the baseline: <https://disk.yandex.ru/d/t6YCFGkgodFOCA/baseline.zip>.

#### Solution format

The competition involves submitting a file with the model's predictions to the platform for the metric to be computed.

The file itself is a `csv` document with two columns:

- `image_name`;
- `recommendation`.

The rows are pairs of an image file name and the corresponding sorted list of all photos from the test set (from the most similar image to the less similar ones).

The use of open (available online) datasets that permit free non-commercial use is allowed.

Manual data labelling is prohibited.

All participants must submit reproducible solutions for checking.

### 4.3.6. Scoring system

Participants submit a `csv` file with predictions with two columns: `image_name` (`query image`) and `recommendation*`.

The rows are pairs of an image file name and the corresponding sorted list of all photos from the test set (from the most similar image to the less similar ones).

The similarity of images is measured with any vector proximity measure (of the participants' choice).

The number of rows equals the number of images in the test set.

To compute the metric, all images from the same series as the `query image`, including the `query image` itself, are removed from the `recommendation` list.

Next, only one (the first) occurrence of each individual in the `recommendation` list is taken into account.

To assess the quality of the re-identification model, the metric used is CMC weighted over the individuals of the test dataset:

$$cmc_w = \frac{1}{N}\sum_{j=1}^{N}\sum_{i=0}^{4} w[i] * sign(find(j) == i),$$

where

$w = [1, 0.9, 0.8, 0.7, 0.6]$;

$sign(*)$ is the indicator function (1 if true, 0 otherwise);

$find(j)$ is the position of the first occurrence of individual $j$, excluding the same individual from the same series as query photo $j$.

- 1 — the correct individual in first place;
- 0.9 — the correct individual in second place;
- 0.8 — the correct individual in third place;
- 0.7 — the correct individual in fourth place;
- 0.6 — the correct individual in fifth place;
- 0 — the correct individual in sixth place or further down.

This value was computed on the ODS platform: <https://ods.ai/competitions/nto24-25-final>.

### 4.3.7. Solution of the task

The link below leads to the solution of the winning team, feel the asi, which achieved the best result (private score: 0.9742990654): <https://disk.yandex.ru/d/t6YCFGkgodFOCA/solution1.zip>.

Structure of the solution archive:

- `README.md` — description of how to run the algorithms;
- `inferense.ipynb` — code for producing the submission file;
- `requirements.txt` — list of all libraries needed to run training and inference;
- `train.ipynb` — file for training the model;
- `train_without_val.ipynb` — file for training the model without validation;
- `models` — folder with the model weights after training;
- `top1_solution.csv` — the submission file.

The solution is based on the OML (open-metric-learning) library. Python version 3.10.12.

Libraries used:

1. `conda create -n nto python=3.10`
2. `pip install -r requirements.txt`

Datasets used:

- the dataset provided by the organisers;
- optionally, ATRW.

Preparing the dataset for training:

- use the environment with `requirements.txt`;
- run the `Dataset create` block in the file `train.ipynb`.

For training each model you can set the `backbone` name, `image_size` and whether ATRW is included in the training set; the names of our models give the version of `efficientnet`, which is the `backbone`, for example `b0`, `b1`, etc.

The number in the model name denotes `image_size`, and `___` at the end means that the model was trained with the code `train_without_val.ipynb`.

Training the Re-ID model:

- use the environment with `requirements.txt`;
- run the `Model` block in the file `train.ipynb`.

Producing the file to submit to the platform:

- use the environment with `requirements.txt`;
- run `inferense.ipynb`.

### 4.3.8. Preparation materials

1. Kevin Musgrave — PyTorch Metric Learning [Online resource]. — Available at: <https://kevinmusgrave.github.io/pytorch-metric-learning/>.
2. TorchRec — A PyTorch Domain Library for Recommendation Systems [Online resource] // PyTorch Blog. — Available at: <https://pytorch.org/blog/introducing-torchrec/>.
3. Zhou K. Deep Person Re-identification: MODEL ZOO [Online resource]. — Available at: <https://kaiyangzhou.github.io/deep-person-reid/MODEL_ZOO>.
4. Open Metric Learning — OML-Team GitHub Repository [Online resource]. — Available at: <https://github.com/OML-Team/open-metric-learning>.

## From Section 5, "Criteria for determining winners and prize-winners": Final stage

### Individual subject tour

- mathematics — maximum possible score for all problems — 100 points;
- informatics — maximum possible score for all problems — 100 points.

### Team engineering tour

Teams in the final stage received from 0 to 100.00 points for the team engineering tour: the team that scored the most points among the teams became the winning team.

All team results were normalised by the formula:

$$\frac{100 \times x}{MAX},$$

where $x$ is the number of points scored by the team,

$MAX$ is the maximum number of points possible for the engineering tour.

In the final stage of the olympiad, a participant's individual score is made up of two parts, each with its own weight: points for the individual solution of problems in subject 1 (mathematics) with weight $K_1 = 0.15$, in subject 2 (informatics) with weight $K_2 = 0.15$, and points for the team solution of the engineering tour tasks with weight $K_3 = 0.7$.
