Giter Club home page Giter Club logo

image-captioning's Introduction

Image Captioning using Neural Networks and Visual Attention

This project aims at generating novel, natural language captions of input images, using an encoder-decoder architecture that uses a CNN as image encoder and an LSTM RNN as a feature decoder. The project is implemented using Tensorflow, and is roughly based on Show, Attend and Tell: Neural Image Caption Generation with Visual Attention paper by Kelvin Xu et al. All the code has been thoroughly commented on for ease of understanding. Schematic below roughly shows the structure of the training graph ('Z' denotes the 'Context Vector'):

picture alt

Overview:

  • Uses a multi-threaded input pipeline implemented using Tensorflow Queues, producing a fast, steady stream of inputs from multiple TFRecord files(shards), with rigorous shuffling of data for data augmentation.
  • Uses Google AutoML Project's NASNet architecture to extract visual features from images. NASNet currently has highest recorded accuracy on ImageNetLSVRC2012 data set.
  • Trained on MS COCO 2017 Training data set. The final pre-processed data consists of 5,87,605 image-caption pairs. The vocabulary used consists of 10,204 words(words occuring >=5 times in MSCOCO captions data).
  • The LSTM RNN is combined with Soft Attention Mechanism, which computes attention weights, applies them to image features, and produces a "context vector", which is fed into LSTM as an additional input along with hidden states. This gives our LSTM more contextual information at every time-step for producing higher quality captions while decoding.
  • Added L2 regularization to all fully-connected layers and applied drop-out ratio of 0.5 on LSTM and FC Layers to prevent over-fitting.
  • The image-caption pairs from data set were added to SequenceExample protocol buffers and then written to files with TFRecord file format. This helps in faster, asynchronous reading of data by input pipeline.

To Do: Use Beam Search decoder with LSTM instead of Greedy decoder for greater quality captions.

Results:

The model achieves following scores on COCO 2014 Validation and Test data:

  • BLUE1: 70.07
  • BLUE2: 52.88
  • BLUE3: 37.95
  • BLUE4: 26.68
  • Meteor: 23.61
  • Rogue-L: 51.29
  • CIDEr: 84.81

An Android application was also developed that sends the images to the online Flask server, which runs the frozen inference graph and returns the captions to the client. The captions generated for the COCO test and validation images are usually relevant to the images. However, I wanted to know how it performs on random images that are NOT a part of the MS COCO test and validation data set. Below are the examples of captions generated using the Android application on some such images:

picture alt picture alt picture alt

picture alt picture alt picture alt

References:

image-captioning's People

Contributors

aayusharm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

image-captioning's Issues

Captions not being generated.

Firstly, great work man. I tried running the android app and everything worked fine but the captions are not being generated. I see that you have mentioned that flask server generates the captions. Can you help me with the steps to execute the code? How to get the caption displayed on my mobile phone?

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.