GithubHelp home page GithubHelp logo

ovshake / cobra Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 3.0 488 KB

Code for COBRA: Contrastive Bi-Modal Representation Algorithm (https://arxiv.org/abs/2005.03687)

License: MIT License

Python 100.00%
representation-learning cross-modal contrastive-learning machine-learning pytorch

cobra's Introduction

COBRA: Contrastive Bi-Modal Representation Algorithm

This repository contains the code for the paper COBRA: Contrastive Bi-Modal Representation Algorithm (ArXiv) by Vishaal Udandarao, Abhishek Maiti, Deepak Srivatsav, Suryatej Reddy, Yifang Yin and Rajiv Ratn Shah.

Methodology

We present a novel framework COBRA that aims to train two modalities (image and text) in a joint fashion inspired by the Contrastive Predictive Coding (CPC) and Noise Contrastive Estimation (NCE) paradigms which preserve both inter and intra-class relationships. We empirically show that this framework reducesthe modality gap significantly and generates a robust and task agnostic joint-embedding space. We outperform existing work on four diverse downstream tasks spanning across seven benchmark cross-modal datasets.

A visualisation of the loss function:

Supervised Contrastive Loss

Architecture

Datasets

The 7 datasets used to empirically prove our results are:

  1. PKU-XMedia
  2. MS-COCO
  3. NUS-Wide 10k
  4. Wikipedia
  5. FakeNewsNet
  6. MeTooMA
  7. CrisisMMD

t-SNEs

Results

Wikipedia MS-COCO PKU-XMedia MS-COCO MS-COCO MS-COCO MS-COCO

Instructions for running

The code has been tested on Python 3.6.8 and PyTorch 1.5.1.

  • Install all the dependencies using the following command:
pip install -r requirements.txt
  • Create a folder features to save the trained models
  • To train COBRA, use the following command:
python main.py
  • To switch between NCE contrastive loss and softmax contrastive loss, change the use_nce flag. To change the number of anchor points and number of negative samples, modify the num_anchors and num_negative_samples respectively.

Queries

In case of any queries, please open an issue. We will respond as soon as possible.

cobra's People

Contributors

ovshake avatar vishaal27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cobra's Issues

dataset

Hello, do you have the download link of xmediafeatures.mat?

Test script for COCO

Hi,
Thank you so much for sharing the work! I am wondering if you can release the test script for coco dataset?

Ckpts of a trained network

Dear Abhishek Maiti,

Thank you for sharing your code and paper. I am very much interested in your work and would like to test COBRA for a cross-modal retrieval problem. So, can you kindly provide checkpoints for your model?

Sincerely,
Magauiya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.