GithubHelp home page GithubHelp logo

joeyy5588 / p2c Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 125 KB

Official Implementation of the paper "Paraphrasing is all you need for Novel Object Captioning", accepted by NeurIPS 2022

License: MIT License

Python 99.49% Shell 0.51%

p2c's Introduction

Paraphrasing Is All You Need for Novel Object Captioning

This repository contains the official PyTorch implementation for the paper. paper link

Yang, C. F., Tsai, Y. H. H., Fan, W. C., Salakhutdinov, R. R., Morency, L. P., & Wang, F. (2022). Paraphrasing Is All You Need for Novel Object Captioning. Advances in Neural Information Processing Systems, 35, 6492-6504.

Installation

  • Follow the instruction from here: link to set up the environment of our codebase, and replace the directory oscar/ with p2c/
  • Install CLIP from the offical repo: link, and place the CLIP directory under the root directory
  • Download the pre-trained CLIP model and save it using the following code: torch.save(_use_new_zipfile_serialization=False) Then replace line 381 in CLIP/clip/model.py with this line: for attr in [*[f"{s}_proj_weight" for s in ["in"]], "in_proj_bias"]:
  • Install the object detection model TSD from here: link

Data

  • It is recommended to download large files with AzCopy for faster speed
path/to/azcopy copy <link> <target folder> --recursive
  • For COCO dataset, download the region features and detection tags from here: link
  • Download the testing data for nocaps from here: link Note that this link only provides data in validation set. For testing set, please extract them from the data below.
  • For Open Images Dataset, download the region features from here: link
  • For Open Images Dataset, use the TSD model to generate the detection tags.
  • Parse the region features and detection tags into the same format as the COCO dataset, and place the generated files in p2c/data. Codes for generating the tsv file can be found here: link

Training

P2C:

  • To perform VIVO pre-training
$ bash scripts/vivo.sh
  • To perform our stage 1 training (Describing novel objects with linguistic fluency)
$ bash scripts/stage1.sh
  • To perform our stage 2 training (Learning novel object captions with fidelity and adequacy)
$ bash scripts/stage2.sh

Reproducing VinVL+VIVO:

  • To perform VIVO pre-training
$ bash scripts/vivo.sh
  • To perform cross-entropy optimization
$ bash scripts/xe.sh
  • To perform SCST optimization
$ bash scripts/scst.sh

Testing

To evaluate the result on the testing set, replace val.yaml with test.yaml

  • To perform greedy decoding
$ bash scripts/inference.sh --num_beams 1 --test_yaml data/val.yaml
  • To perform beam search
$ bash scripts/inference.sh --num_beams 5 --test_yaml data/val.yaml
  • To perform Constrained Beam Search (CBS)
$ bash scripts/cbs.sh --test_yaml data/val.yaml

p2c's People

Contributors

joeyy5588 avatar

Stargazers

Rajat Rasal avatar JunmingZhao 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.