All Projects → ardiya → Siamesenetwork Tensorflow

ardiya / Siamesenetwork Tensorflow

Licence: mit
Using siamese network to do dimensionality reduction and similar image retrieval

Projects that are alternatives of or similar to Siamesenetwork Tensorflow

Deepembeding
图像检索和向量搜索,similarity learning,compare deep metric and deep-hashing applying in image retrieval
Stars: ✭ 83 (-67.83%)
Mutual labels:  jupyter-notebook, image-retrieval
Delf enhanced
Wrapper of DELF Tensorflow Model
Stars: ✭ 98 (-62.02%)
Mutual labels:  jupyter-notebook, image-retrieval
Delf Pytorch
PyTorch Implementation of "Large-Scale Image Retrieval with Attentive Deep Local Features"
Stars: ✭ 245 (-5.04%)
Mutual labels:  jupyter-notebook, image-retrieval
Amazing Python Scripts
🚀 Curated collection of Amazing Python scripts from Basics to Advance with automation task scripts.
Stars: ✭ 229 (-11.24%)
Mutual labels:  jupyter-notebook
2018 Daguan Competition
2018年"达观杯"文本智能处理挑战赛-长文本分类-rank4
Stars: ✭ 256 (-0.78%)
Mutual labels:  jupyter-notebook
Numpy
Jupyter Notebook & Data Associated with my Tutorial video on the Python NumPy Library
Stars: ✭ 255 (-1.16%)
Mutual labels:  jupyter-notebook
Genadv tutorial
TensorFlow tutorial on Generative Adversarial Models
Stars: ✭ 257 (-0.39%)
Mutual labels:  jupyter-notebook
Stock Analysis
Regression, Scrapers, and Visualization
Stars: ✭ 255 (-1.16%)
Mutual labels:  jupyter-notebook
Panoptic Toolbox
Stars: ✭ 257 (-0.39%)
Mutual labels:  jupyter-notebook
Pytorch Cheatsheet
Check out improved:
Stars: ✭ 256 (-0.78%)
Mutual labels:  jupyter-notebook
Learntools
Tools and tests used in Kaggle Learn exercises
Stars: ✭ 256 (-0.78%)
Mutual labels:  jupyter-notebook
Dl Imperial Maths
Code and assignment repository for the Imperial College Mathematics department Deep Learning course
Stars: ✭ 256 (-0.78%)
Mutual labels:  jupyter-notebook
Whale
Stars: ✭ 257 (-0.39%)
Mutual labels:  jupyter-notebook
Causality
Stars: ✭ 252 (-2.33%)
Mutual labels:  jupyter-notebook
Course Nlp
A Code-First Introduction to NLP course
Stars: ✭ 3,029 (+1074.03%)
Mutual labels:  jupyter-notebook
Sipmask
SipMask: Spatial Information Preservation for Fast Image and Video Instance Segmentation (ECCV2020)
Stars: ✭ 255 (-1.16%)
Mutual labels:  jupyter-notebook
Keras Tutorials
Simple tutorials using Keras Framework
Stars: ✭ 257 (-0.39%)
Mutual labels:  jupyter-notebook
Da Rnn
📃 **Unofficial** PyTorch Implementation of DA-RNN (arXiv:1704.02971)
Stars: ✭ 256 (-0.78%)
Mutual labels:  jupyter-notebook
Ssm
Bayesian learning and inference for state space models
Stars: ✭ 255 (-1.16%)
Mutual labels:  jupyter-notebook
Place Recognition Using Autoencoders And Nn
Place recognition with WiFi fingerprints using Autoencoders and Neural Networks
Stars: ✭ 256 (-0.78%)
Mutual labels:  jupyter-notebook

Siamese Network Tensorflow

Siamese network is a neural network that contain two or more identical subnetwork. The objective of this network is to find the similarity or comparing the relationship between two comparable things. Unlike classification task that uses cross entropy as the loss function, siamese network usually uses contrastive loss or triplet loss.

Siamese network has a lot of function, this repository is trying to use Siamese network to do a dimensionality reduction and image retrieval.

This project follows Hadsell-et-al.'06 [1] by computing the Euclidean distance on the output of the shared network and by optimizing the contrastive loss (see paper for more details). The contastive loss is defined as follows

-contrastive loss function-

The -D formula- is the distance of between the output of the network N with the input Xleft and the input Xright.

The similarity function is defined as -sim function-. This function will be activated when the Label Y equal to 1 and deactivated when Y is equal to 0. The goal of this function is to minimize the distance of the pairs.

The dissimilarity function is defined as -dissim function-. This function will be activated when the Label Y is equal to 0 and deactivated when Y is equal to 1. The goal of this function is to give a penalty of the pairs when the distance is lower than margin m.

[1] "Dimensionality Reduction by Learning an Invariant Mapping" http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf

Model

The input of these will be image_left, image_right and . Our model uses 5 layer of convolutional layer and pooling followed. We do not use fully convolutonal net because convolution operation is faster on GPU(especially using CUDNN). See http://cs231n.github.io/convolutional-networks/#convert for more information on converting FC layer to Conv layer.

Run

Train the model

git clone https://github.com/ardiya/siamesenetwork-tensorflow
python train.py

Tensorboard Visualization(After training)

tensorboard --logdir=train.log

Updates

  • Update the API to 1.0
  • Cleanup the old code

Dimensionality reduction

The images below shows the final Result on MNIST test dataset. By only using 2 features, we can easily separate the input images.

The gif below shows some animation until it somehow converges.

Image retrieval

Image retrieval uses the trained model to extract the features and get the most similar image using cosine similarity. See here

Retrieving similar test image from trainset

  • Select id 865 in test image

  • Retrieved top n similar image from train data with ids of [53144 47864 11074 51561 41350 34215 48182] from train data

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].