Git Product home page Git Product logo

image_caption's Introduction

Image Caption

Description

Image caption referes to the process of describing an image using a sentence. By asking computers to generate captions based on input image, we may find ways to improve life quality for those with visual impairment. In addition, with image caption we could also build and optimize the search engine for image content.

For our final project for DL Summer '22, we build and use a CNN-RNN model to automatically generate descriptions.

CNN-RNN model: The image is encoded into a context vector by a CNN which can then be passed to a RNN decoder 1 This is an image Here, we use the resnet18 model for our CNN encoder part.

Data

We used the Flickr Image dataset from Kaggle, with a total of 8k images and corresponding human annotated captions.

Model and Notebook

We followed these steps to create our final model:

  1. Tokenizing the captions. We used spacy here.
  2. Image Augmentation
  3. Processed Image as input for CNN (Resnet-18)
  4. CNN -> LSTM
  5. Use output from LSTM to generate result captions

Link to the notebook here. Link to the helper functions and model files.

Result

result

Average Log Loss: 3.3332 after a few epochs

Summary

Issues

  • Model can only use words in the vocab it trains on
  • Loss function only penalize for getting the words wrong. There is no meaning retention
  • Can not work with grammar
  • Need more epochs (Research groups norally take days to train their models)

Future Steps

  • Increase LSTM layering
  • Add in attention
  • Use subwords tokenizers
  • Train for more epochs
  • Use different loss function, for example BLEU, or embedding comparisons

Discussions

Some other implementions using captions could be:

  • Given a sentence/query, find out the matching images.
  • Object detection

Slides

Our Slides for the final presentation

Requirements

Python==3.7.13
jupyter==1.0.0
matplotlib==3.2.2
numpy==1.21.6
pandas==1.3.5
Pillow==7.1.2
spacy==3.3.1
torch @ https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp37-cp37m-linux_x86_64.whl
torchaudio @ https://download.pytorch.org/whl/cu113/torchaudio-0.11.0%2Bcu113-cp37-cp37m-
tqdm==4.64.0

Footnotes

  1. Image reference โ†ฉ

image_caption's People

Contributors

karagain avatar randomaowu avatar

Stargazers

 avatar

Watchers

 avatar

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.