Giter Club home page Giter Club logo

best_first's Introduction

Non Sequential Decoding Strategies

This repository implements my research---a non sequential auto regressive model that generates captions. The model has the ability to insert new words into already generated sentences.

Have Fun! -Brandon

Installation

To install our implementation, run the following:

git clone https://github.com/brandontrabucco/best_first
cd best_first

git submodule init
git submodule update

export PYTHONPATH="$PYTHONPATH:path/to/tensorflow/models/"
pip install -e .

Building The Dataset

To build the datasets in our experiments, place images and captions into the data folder into the corresponding images/ and captions/ folders. Then, run the following build scripts:

python data/process_images.py \
    --image_folder data/images/ \
    --image_feature_folder data/image_features/ \
    --batch_size=64  \
    --image_height 299 \
    --image_width 299

python data/process_captions.py \
    --caption_folder data/captions/ \
    --caption_feature_folder data/caption_features_best_first_2_violations/ \
    --ordering "best_first" \
    --max_violations 2 \
    --min_word_frequency 5 \
    --vocab_file data/vocab.txt \
    --tagger_file data/tagger.pkl \
    --max_caption_length 20

python data/create_tfrecords.py \
    --image_feature_folder data/image_features/ \
    --caption_feature_folder data/caption_features_best_first_2_violations/ \
    --tfrecord_folder data/tfrecords_best_first_2_violations/ \
    --num_samples_per_shard 4096

Training The Model

To start training and run continuous evaluation of the model checkpoints, run the following python scripts. Performance is measured using BLEU, CIDEr, METEOR, and several other metrics.

python scripts/train.py \
    --tfrecord_folder data/tfrecords_best_first_2_violations/ \
    --vocab_file data/vocab.txt \
    --logging_dir best_first_2_violations \
    --ckpt best_first_2_violations/model.ckpt

python scripts/eval.py \
    --tfrecord_folder data/tfrecords_best_first_2_violations/ \
    --vocab_file data/vocab.txt \
    --logging_dir best_first_2_violations \
    --ckpt best_first_2_violations/model.ckpt

Running The Model

To perform inference and interact with the trained model to suggest new words into existing captions, run the following inference script, and respond to the prompts that are printed to the terminal.

python scripts/inference.py \
    --image image.jpg \
    --image_height 299 \
    --image_width 299 \
    --vocab_file data/vocab.txt \
    --tagger_file data/tagger.pkl \
    --max_caption_length 20 \
    --beam_size 100 \
    --ckpt best_first_2_violations/model.ckpt

best_first's People

Contributors

brandontrabucco avatar

Stargazers

 avatar

Watchers

 avatar  avatar

best_first's Issues

Improving Beam Search

Update the beam search to not allow beams with the same caption to exist (if a beam is encountered with the same caption and higher log prob, replace the existing beam with that caption.)

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.