/siamese_networks

Example siamese networks

Primary LanguagePython

Siamese Neworks

This repo implements a resnet-based siamese network for representation learning. You can run th project using the following steps ;

Prepare the dataset for training and testing

For this example we use the Tootally-Looks-Like dataset. To use it, we recommend converting the dataset into tfds format (see tfds_look.py). We split this dataset into 5000 image pairs for training and 116 for testing. You can dowloand the tfds format of the dataset from here. Please download it and apply tar -xf into ~/tensorflow_datasets.

Train the siamese_network using the tfds_look

python train.py -config config/look.ini -model RESNET -gpu 0

You can download the trained model from here. Apply tar -xf into the project folder.

Test the trained model

We will apply similarity search to test the trained encoder. To this end, we can use the sim_search project. Then apply the folowing steps:

  1. Download the testing images. The dataset contains two parallel folders (right and left).
  2. Generate two files, one with the files in the folder right and the other with those in the left.
  3. Run python ssearch.py -config <SIAMESE_NETWORK FOLDER>config/look.ini -catalog -query -model_path

After running you will get some results in the folder results. Some examples appear below (first image is the query and the rest are ordered according to the similarity with the first): output_00204 jpg output_00518 jpg output_00659 jpg output_00944 jpg output_01097 jpg output_02537 jpg