Keras Image Embeddings using Contrastive Loss

Overview

Keras-Image-Embeddings-using-Contrastive-Loss

Image to Embedding projection in vector space. Implementation in keras and tensorflow for custom data. Batch all triplet loss for one-shot/few-shot learning. Triplet is generated for One-shot learning using augmentation between anchor and positive.

Requirements:

tensorflow = 2.4.1, tensorflow-gpu = 2.4.1, Keras = 2.2.4, imgaug = 0.4.0, numpy >= 1.19.5, pandas >= 1.1.3, opencv-contrib-python >= 4.5.1.48, opencv-python >= 4.4.0.44

You might also like...
Re-implementation of the Noise Contrastive Estimation algorithm for pyTorch, following "Noise-contrastive estimation: A new estimation principle for unnormalized statistical models." (Gutmann and Hyvarinen, AISTATS 2010)

Noise Contrastive Estimation for pyTorch Overview This repository contains a re-implementation of the Noise Contrastive Estimation algorithm, implemen

Image-to-Image Translation with Conditional Adversarial Networks (Pix2pix) implementation in keras

pix2pix-keras Pix2pix implementation in keras. Original paper: Image-to-Image Translation with Conditional Adversarial Networks (pix2pix) Paper Author

OpenL3: Open-source deep audio and image embeddings

OpenL3 OpenL3 is an open-source Python library for computing deep audio and image embeddings. Please refer to the documentation for detailed instructi

Python package to generate image embeddings with CLIP without PyTorch/TensorFlow
Python package to generate image embeddings with CLIP without PyTorch/TensorFlow

imgbeddings A Python package to generate embedding vectors from images, using OpenAI's robust CLIP model via Hugging Face transformers. These image em

Code for Dual Contrastive Learning for Unsupervised Image-to-Image Translation, NTIRE, CVPRW 2021.
Code for Dual Contrastive Learning for Unsupervised Image-to-Image Translation, NTIRE, CVPRW 2021.

arXiv Dual Contrastive Learning Adversarial Generative Networks (DCLGAN) We provide our PyTorch implementation of DCLGAN, which is a simple yet powerf

Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Face Mask Detection on Image and Video using tensorflow and keras
Face Mask Detection on Image and Video using tensorflow and keras

Face-Mask-Detection Face Mask Detection on Image and Video using tensorflow and keras Train Neural Network on face-mask dataset using tensorflow and k

Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

 UmlsBERT: Clinical Domain Knowledge Augmentation of Contextual Embeddings Using the Unified Medical Language System Metathesaurus
UmlsBERT: Clinical Domain Knowledge Augmentation of Contextual Embeddings Using the Unified Medical Language System Metathesaurus

UmlsBERT: Clinical Domain Knowledge Augmentation of Contextual Embeddings Using the Unified Medical Language System Metathesaurus General info This is

Comments
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 34% 🎉

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /datasets/few-shot-dataset/train/airplane/0008.jpg | 0.71kb | 0.39kb | 45.15% | | /datasets/few-shot-dataset/train/ship/0006.jpg | 0.75kb | 0.43kb | 42.02% | | /datasets/one-shot-dataset/test/bird.jpg | 0.78kb | 0.46kb | 40.75% | | /datasets/one-shot-dataset/train/airplane.jpg | 0.79kb | 0.48kb | 39.90% | | /datasets/one-shot-dataset/train/deer.jpg | 0.80kb | 0.48kb | 39.61% | | /datasets/few-shot-dataset/train/deer/0000.jpg | 0.79kb | 0.48kb | 39.16% | | /datasets/few-shot-dataset/train/airplane/0002.jpg | 0.81kb | 0.50kb | 39.02% | | /datasets/few-shot-dataset/train/bird/0004.jpg | 0.80kb | 0.49kb | 38.73% | | /datasets/few-shot-dataset/test/ship/0014.jpg | 0.82kb | 0.50kb | 38.71% | | /datasets/few-shot-dataset/test/cat/0013.jpg | 0.80kb | 0.49kb | 38.53% | | /datasets/few-shot-dataset/train/ship/0010.jpg | 0.82kb | 0.50kb | 38.52% | | /datasets/few-shot-dataset/train/deer/0006.jpg | 0.82kb | 0.51kb | 38.02% | | /datasets/few-shot-dataset/train/bird/0006.jpg | 0.83kb | 0.52kb | 37.82% | | /datasets/few-shot-dataset/train/bird/0008.jpg | 0.83kb | 0.52kb | 37.65% | | /datasets/few-shot-dataset/test/deer/0013.jpg | 0.84kb | 0.52kb | 37.50% | | /datasets/few-shot-dataset/test/automobile/0014.jpg | 0.83kb | 0.52kb | 37.35% | | /datasets/few-shot-dataset/train/ship/0008.jpg | 0.84kb | 0.53kb | 36.96% | | /datasets/few-shot-dataset/train/frog/0008.jpg | 0.84kb | 0.53kb | 36.81% | | /datasets/one-shot-dataset/test/ship.jpg | 0.86kb | 0.54kb | 36.76% | | /datasets/few-shot-dataset/train/airplane/0011.jpg | 0.85kb | 0.54kb | 36.47% | | /datasets/few-shot-dataset/train/deer/0011.jpg | 0.85kb | 0.54kb | 36.21% | | /datasets/few-shot-dataset/test/automobile/0012.jpg | 0.87kb | 0.55kb | 36.11% | | /datasets/few-shot-dataset/test/bird/0013.jpg | 0.86kb | 0.55kb | 36.10% | | /datasets/few-shot-dataset/train/bird/0010.jpg | 0.86kb | 0.55kb | 36.05% | | /datasets/few-shot-dataset/train/frog/0002.jpg | 0.85kb | 0.54kb | 36.01% | | /datasets/few-shot-dataset/train/bird/0011.jpg | 0.87kb | 0.56kb | 35.98% | | /datasets/few-shot-dataset/test/truck/0013.jpg | 0.85kb | 0.54kb | 35.71% | | /datasets/few-shot-dataset/train/bird/0005.jpg | 0.85kb | 0.55kb | 35.71% | | /datasets/few-shot-dataset/train/cat/0004.jpg | 0.88kb | 0.57kb | 35.67% | | /datasets/one-shot-dataset/test/frog.jpg | 0.87kb | 0.56kb | 35.67% | | /datasets/few-shot-dataset/train/cat/0002.jpg | 0.87kb | 0.56kb | 35.64% | | /datasets/one-shot-dataset/train/cat.jpg | 0.88kb | 0.56kb | 35.60% | | /datasets/few-shot-dataset/train/airplane/0004.jpg | 0.86kb | 0.56kb | 35.37% | | /datasets/few-shot-dataset/train/ship/0003.jpg | 0.88kb | 0.57kb | 35.37% | | /datasets/few-shot-dataset/test/dog/0013.jpg | 0.88kb | 0.57kb | 35.27% | | /datasets/few-shot-dataset/train/cat/0009.jpg | 0.89kb | 0.57kb | 35.17% | | /datasets/few-shot-dataset/train/ship/0004.jpg | 0.88kb | 0.57kb | 35.11% | | /datasets/few-shot-dataset/train/truck/0004.jpg | 0.86kb | 0.56kb | 35.03% | | /datasets/one-shot-dataset/test/cat.jpg | 0.88kb | 0.57kb | 35.03% | | /datasets/few-shot-dataset/train/deer/0002.jpg | 0.88kb | 0.57kb | 35.01% | | /datasets/few-shot-dataset/train/automobile/0007.jpg | 0.89kb | 0.58kb | 34.97% | | /datasets/few-shot-dataset/train/frog/0001.jpg | 0.89kb | 0.58kb | 34.95% | | /datasets/few-shot-dataset/train/airplane/0005.jpg | 0.88kb | 0.58kb | 34.88% | | /datasets/few-shot-dataset/train/deer/0003.jpg | 0.89kb | 0.58kb | 34.80% | | /datasets/few-shot-dataset/train/cat/0007.jpg | 0.91kb | 0.59kb | 34.74% | | /datasets/few-shot-dataset/train/frog/0007.jpg | 0.88kb | 0.58kb | 34.73% | | /datasets/few-shot-dataset/train/frog/0009.jpg | 0.91kb | 0.59kb | 34.66% | | /datasets/few-shot-dataset/test/deer/0012.jpg | 0.89kb | 0.58kb | 34.58% | | /datasets/few-shot-dataset/test/deer/0014.jpg | 0.91kb | 0.59kb | 34.55% | | /datasets/few-shot-dataset/train/horse/0010.jpg | 0.90kb | 0.59kb | 34.52% | | /datasets/few-shot-dataset/test/frog/0013.jpg | 0.91kb | 0.59kb | 34.41% | | /datasets/few-shot-dataset/train/cat/0008.jpg | 0.90kb | 0.59kb | 34.35% | | /datasets/few-shot-dataset/train/deer/0005.jpg | 0.90kb | 0.59kb | 34.34% | | /datasets/few-shot-dataset/train/cat/0005.jpg | 0.89kb | 0.58kb | 34.29% | | /datasets/few-shot-dataset/train/deer/0001.jpg | 0.89kb | 0.59kb | 34.25% | | /datasets/few-shot-dataset/train/ship/0000.jpg | 0.90kb | 0.59kb | 34.24% | | /datasets/few-shot-dataset/train/cat/0011.jpg | 0.90kb | 0.59kb | 34.24% | | /datasets/few-shot-dataset/test/cat/0012.jpg | 0.91kb | 0.60kb | 34.23% | | /datasets/one-shot-dataset/test/truck.jpg | 0.91kb | 0.60kb | 34.19% | | /datasets/few-shot-dataset/test/ship/0012.jpg | 0.89kb | 0.59kb | 34.17% | | /datasets/one-shot-dataset/train/truck.jpg | 0.93kb | 0.61kb | 34.11% | | /datasets/few-shot-dataset/train/ship/0011.jpg | 0.91kb | 0.60kb | 34.09% | | /datasets/few-shot-dataset/train/automobile/0004.jpg | 0.91kb | 0.60kb | 34.05% | | /datasets/few-shot-dataset/test/frog/0012.jpg | 0.92kb | 0.61kb | 34.01% | | /datasets/few-shot-dataset/train/horse/0006.jpg | 0.91kb | 0.60kb | 33.69% | | /datasets/few-shot-dataset/train/frog/0011.jpg | 0.91kb | 0.61kb | 33.69% | | /datasets/few-shot-dataset/train/deer/0010.jpg | 0.91kb | 0.61kb | 33.69% | | /datasets/few-shot-dataset/test/horse/0013.jpg | 0.94kb | 0.62kb | 33.61% | | /datasets/few-shot-dataset/train/airplane/0009.jpg | 0.95kb | 0.63kb | 33.61% | | /datasets/few-shot-dataset/train/airplane/0003.jpg | 0.90kb | 0.60kb | 33.59% | | /datasets/few-shot-dataset/train/bird/0000.jpg | 0.91kb | 0.61kb | 33.55% | | /datasets/few-shot-dataset/train/automobile/0001.jpg | 0.94kb | 0.63kb | 33.47% | | /datasets/few-shot-dataset/train/deer/0009.jpg | 0.93kb | 0.62kb | 33.40% | | /datasets/few-shot-dataset/train/deer/0004.jpg | 0.94kb | 0.63kb | 33.40% | | /datasets/one-shot-dataset/test/dog.jpg | 0.93kb | 0.62kb | 33.30% | | /datasets/few-shot-dataset/train/frog/0003.jpg | 0.94kb | 0.63kb | 33.23% | | /datasets/one-shot-dataset/train/bird.jpg | 0.94kb | 0.63kb | 33.20% | | /datasets/few-shot-dataset/train/cat/0006.jpg | 0.95kb | 0.64kb | 33.16% | | /datasets/one-shot-dataset/train/horse.jpg | 0.93kb | 0.62kb | 33.16% | | /datasets/few-shot-dataset/train/truck/0008.jpg | 0.93kb | 0.62kb | 33.12% | | /datasets/few-shot-dataset/train/ship/0002.jpg | 0.94kb | 0.63kb | 33.09% | | /datasets/few-shot-dataset/train/cat/0010.jpg | 0.93kb | 0.63kb | 32.81% | | /datasets/few-shot-dataset/train/automobile/0006.jpg | 0.96kb | 0.64kb | 32.79% | | /datasets/few-shot-dataset/train/bird/0002.jpg | 0.94kb | 0.63kb | 32.75% | | /datasets/few-shot-dataset/train/frog/0010.jpg | 0.94kb | 0.63kb | 32.74% | | /datasets/few-shot-dataset/train/cat/0003.jpg | 0.93kb | 0.63kb | 32.71% | | /datasets/few-shot-dataset/train/truck/0006.jpg | 0.94kb | 0.63kb | 32.67% | | /datasets/few-shot-dataset/train/bird/0003.jpg | 0.94kb | 0.63kb | 32.67% | | /datasets/few-shot-dataset/train/horse/0002.jpg | 0.94kb | 0.63kb | 32.64% | | /datasets/few-shot-dataset/train/horse/0000.jpg | 0.97kb | 0.65kb | 32.63% | | /datasets/few-shot-dataset/train/automobile/0002.jpg | 0.98kb | 0.66kb | 32.60% | | /datasets/few-shot-dataset/train/automobile/0008.jpg | 0.92kb | 0.62kb | 32.59% | | /datasets/few-shot-dataset/train/truck/0010.jpg | 0.94kb | 0.63kb | 32.57% | | /datasets/few-shot-dataset/train/deer/0008.jpg | 0.93kb | 0.63kb | 32.53% | | /datasets/few-shot-dataset/train/automobile/0009.jpg | 0.95kb | 0.64kb | 32.51% | | /datasets/few-shot-dataset/train/truck/0009.jpg | 0.93kb | 0.63kb | 32.46% | | /datasets/few-shot-dataset/train/automobile/0000.jpg | 0.96kb | 0.65kb | 32.42% | | /datasets/few-shot-dataset/test/ship/0013.jpg | 0.96kb | 0.65kb | 32.42% | | /datasets/one-shot-dataset/test/automobile.jpg | 0.98kb | 0.66kb | 32.40% | | /datasets/few-shot-dataset/train/automobile/0010.jpg | 0.98kb | 0.66kb | 32.40% | | /datasets/few-shot-dataset/test/automobile/0013.jpg | 0.94kb | 0.64kb | 32.40% | | /datasets/few-shot-dataset/test/bird/0014.jpg | 0.96kb | 0.65kb | 32.32% | | /datasets/few-shot-dataset/train/automobile/0011.jpg | 0.96kb | 0.65kb | 32.31% | | /datasets/few-shot-dataset/train/frog/0006.jpg | 0.95kb | 0.64kb | 32.30% | | /datasets/few-shot-dataset/train/frog/0000.jpg | 0.94kb | 0.63kb | 32.25% | | /datasets/few-shot-dataset/test/horse/0012.jpg | 0.95kb | 0.65kb | 32.17% | | /datasets/few-shot-dataset/train/truck/0000.jpg | 0.98kb | 0.67kb | 31.94% | | /datasets/one-shot-dataset/test/airplane.jpg | 0.96kb | 0.65kb | 31.94% | | /datasets/few-shot-dataset/train/truck/0007.jpg | 0.95kb | 0.65kb | 31.83% | | /datasets/few-shot-dataset/test/dog/0014.jpg | 0.95kb | 0.65kb | 31.79% | | /datasets/one-shot-dataset/train/dog.jpg | 1.00kb | 0.68kb | 31.57% | | /datasets/few-shot-dataset/test/frog/0014.jpg | 0.98kb | 0.67kb | 31.43% | | /datasets/one-shot-dataset/train/frog.jpg | 0.98kb | 0.67kb | 31.43% | | /datasets/few-shot-dataset/train/truck/0003.jpg | 0.98kb | 0.67kb | 31.27% | | /datasets/few-shot-dataset/train/truck/0011.jpg | 0.97kb | 0.67kb | 30.95% | | /datasets/few-shot-dataset/test/truck/0012.jpg | 0.98kb | 0.68kb | 30.91% | | /datasets/few-shot-dataset/train/truck/0001.jpg | 0.98kb | 0.67kb | 30.83% | | /datasets/one-shot-dataset/test/horse.jpg | 1.02kb | 0.71kb | 30.78% | | /datasets/few-shot-dataset/train/horse/0004.jpg | 1.02kb | 0.71kb | 30.65% | | | | | | | Total : | 107.43kb | 70.56kb | 34.32% |


    📝 docs | :octocat: repo | 🙋🏾 issues | 🏪 marketplace

    ~Imgbot - Part of Optimole family

    opened by imgbot[bot] 0
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 35% 🎉

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /datasets/few-shot-dataset/train/horse/0009.jpg | 0.79kb | 0.48kb | 39.56% | | /datasets/few-shot-dataset/train/ship/0007.jpg | 0.80kb | 0.48kb | 39.14% | | /datasets/few-shot-dataset/train/ship/0009.jpg | 0.83kb | 0.51kb | 38.50% | | /datasets/few-shot-dataset/test/airplane/0014.jpg | 0.81kb | 0.50kb | 38.41% | | /datasets/one-shot-dataset/train/ship.jpg | 0.82kb | 0.51kb | 37.65% | | /datasets/few-shot-dataset/test/bird/0012.jpg | 0.84kb | 0.53kb | 37.46% | | /datasets/few-shot-dataset/train/airplane/0001.jpg | 0.85kb | 0.53kb | 37.30% | | /datasets/few-shot-dataset/train/horse/0008.jpg | 0.87kb | 0.55kb | 36.54% | | /datasets/few-shot-dataset/train/ship/0005.jpg | 0.87kb | 0.55kb | 36.22% | | /datasets/few-shot-dataset/train/airplane/0007.jpg | 0.85kb | 0.55kb | 35.77% | | /datasets/few-shot-dataset/train/horse/0003.jpg | 0.88kb | 0.57kb | 35.52% | | /datasets/few-shot-dataset/test/horse/0014.jpg | 0.91kb | 0.59kb | 35.28% | | /datasets/few-shot-dataset/train/airplane/0000.jpg | 0.87kb | 0.56kb | 35.14% | | /datasets/few-shot-dataset/test/dog/0012.jpg | 0.89kb | 0.58kb | 35.05% | | /datasets/few-shot-dataset/train/cat/0001.jpg | 0.88kb | 0.57kb | 35.03% | | /datasets/few-shot-dataset/train/horse/0005.jpg | 0.90kb | 0.59kb | 34.67% | | /datasets/few-shot-dataset/train/ship/0001.jpg | 0.89kb | 0.58kb | 34.61% | | /datasets/few-shot-dataset/train/frog/0005.jpg | 0.90kb | 0.59kb | 34.52% | | /datasets/few-shot-dataset/test/cat/0014.jpg | 0.91kb | 0.60kb | 34.51% | | /datasets/few-shot-dataset/train/horse/0007.jpg | 0.91kb | 0.59kb | 34.48% | | /datasets/few-shot-dataset/train/automobile/0005.jpg | 0.90kb | 0.59kb | 34.39% | | /datasets/few-shot-dataset/test/airplane/0012.jpg | 0.90kb | 0.59kb | 34.16% | | /datasets/few-shot-dataset/train/bird/0001.jpg | 0.92kb | 0.60kb | 33.94% | | /datasets/few-shot-dataset/test/airplane/0013.jpg | 0.95kb | 0.63kb | 33.85% | | /datasets/one-shot-dataset/test/deer.jpg | 0.91kb | 0.61kb | 33.76% | | /datasets/few-shot-dataset/train/horse/0011.jpg | 0.92kb | 0.61kb | 33.72% | | /datasets/few-shot-dataset/train/automobile/0003.jpg | 0.92kb | 0.61kb | 33.58% | | /datasets/few-shot-dataset/train/airplane/0010.jpg | 0.93kb | 0.62kb | 33.51% | | /datasets/few-shot-dataset/test/truck/0014.jpg | 0.94kb | 0.63kb | 33.23% | | /datasets/few-shot-dataset/train/bird/0007.jpg | 0.94kb | 0.63kb | 32.99% | | /datasets/few-shot-dataset/train/frog/0004.jpg | 0.93kb | 0.62kb | 32.95% | | /datasets/few-shot-dataset/train/horse/0001.jpg | 0.95kb | 0.64kb | 32.33% | | /datasets/one-shot-dataset/train/automobile.jpg | 0.96kb | 0.65kb | 32.31% | | /datasets/few-shot-dataset/train/cat/0000.jpg | 0.95kb | 0.64kb | 32.27% | | /datasets/few-shot-dataset/train/truck/0005.jpg | 0.99kb | 0.68kb | 31.27% | | | | | | | Total : | 31.27kb | 20.37kb | 34.86% |


    📝 docs | :octocat: repo | 🙋🏾 issues | 🏪 marketplace

    ~Imgbot - Part of Optimole family

    opened by imgbot[bot] 0
Owner
Shravan Anand K
Mechatronics | AI/ML/DL | Computer Vision | Robotics Enthusiast
Shravan Anand K
An implementation for the loss function proposed in Decoupled Contrastive Loss paper.

Decoupled-Contrastive-Learning This repository is an implementation for the loss function proposed in Decoupled Contrastive Loss paper. Requirements P

Ramin Nakhli 71 Dec 4, 2022
Saeed Lotfi 28 Dec 12, 2022
Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation)

Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation) Download Synthia dataset The model uses

null 32 Sep 21, 2022
Implement of "Training deep neural networks via direct loss minimization" in PyTorch for 0-1 loss

This is the implementation of "Training deep neural networks via direct loss minimization" published at ICML 2016 in PyTorch. The implementation targe

Cuong Nguyen 1 Jan 18, 2022
PyTorch implementation for Partially View-aligned Representation Learning with Noise-robust Contrastive Loss (CVPR 2021)

2021-CVPR-MvCLN This repo contains the code and data of the following paper accepted by CVPR 2021 Partially View-aligned Representation Learning with

XLearning Group 33 Nov 1, 2022
Official pytorch implementation of "Feature Stylization and Domain-aware Contrastive Loss for Domain Generalization" ACMMM 2021 (Oral)

Feature Stylization and Domain-aware Contrastive Loss for Domain Generalization This is an official implementation of "Feature Stylization and Domain-

null 22 Sep 22, 2022
This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras)

Yogi-Optimizer_Keras This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras) The NeurIPS-Paper can be found here: http://papers.nips.c

null 14 Sep 13, 2022
Keras udrl - Keras implementation of Upside Down Reinforcement Learning

keras_udrl Keras implementation of Upside Down Reinforcement Learning This is me

Eder Santana 7 Jan 24, 2022
Example-custom-ml-block-keras - Custom Keras ML block example for Edge Impulse

Custom Keras ML block example for Edge Impulse This repository is an example on

Edge Impulse 8 Nov 2, 2022
Classification models 1D Zoo - Keras and TF.Keras

Classification models 1D Zoo - Keras and TF.Keras This repository contains 1D variants of popular CNN models for classification like ResNets, DenseNet

Roman Solovyev 12 Jan 6, 2023