GithubHelp home page GithubHelp logo

vishwanath1306 / attributes-as-operators Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tushar-n/attributes-as-operators

0.0 1.0 0.0 34 KB

Attribute-Object Visual Composition using Attributes as Operators

Python 92.14% MATLAB 2.10% Shell 5.75%

attributes-as-operators's Introduction

Attributes as Operators

Attributes as Operators Model

This code implements an embedding learning framework for visual attribute-object composition (e.g. sliced+orange = sliced orange) by treating objects as vectors, and attributes as operators that modify the object vectors to appropriately compose them into a complex concept. Not only does our approach align conceptually with the linguistic role of attributes as modifiers, but it also generalizes to recognize unseen compositions of objects and attributes. Our model recognizes unseen compositions robustly in an open-world setting on two challenging datasets, and can also generalize to compositions where objects themselves were unseen during training.

This is the code accompanying the work:
Tushar Nagarajan and Kristen Grauman.
Attributes as Operators [arxiv]

Prerequisites

The code is written and tested using Python (2.7) and PyTorch (v0.3.0). MATLAB is required for the AnalogousAttr models only.

Packages: Install using pip install -r utils/requirements.txt

Datasets and Features: We include a script to download all the necessary data: images, features and metadata for the two datasets, pretrained SVM classifier weights, tensor completion code and pretrained models. It must be run before training the models.

bash utils/download_data.sh

UT-Zappos Subset: The UT-Zappos Materials subset, which we use as one of our datasets will be generated as part of the script. The subset is also available to download as raw images from here.

Training a model

Models can be trained using the train script with parameters for the model (visprodNN, redwine, labelembed+, attributeop) and the various regularizers (aux, inv, comm, ant). For example, to train the LabelEmbed+ baseline on UT-Zappos:

python train.py --dataset zappos --data_dir data/ut-zap50k/ --batch_size 512 --lr 1e-4 --max_epochs 1000 --glove_init --model labelembed+ --nlayers 2 --cv_dir cv/zappos/labelembed+

To train the AttributeOperator model with all regularizers on MIT-States and UT-Zappos:

python train.py --dataset mitstates --data_dir data/mit-states/ --batch_size 512 --lr 1e-4 --max_epochs 800 --glove_init --model attributeop --cv_dir cv/mitstates/attrop+aux+inv+comm --lambda_aux 1000.0 --lambda_inv 1.0 --lambda_comm 1.0
python train.py --dataset zappos --data_dir data/ut-zap50k/ --batch_size 512 --lr 1e-4 --max_epochs 1000 --glove_init --model attributeop --cv_dir cv/zappos/attributeop --lambda_aux 1.0 --lambda_comm 1.0

The AnalogousAttr model can be trained using the MATLAB scripts in tensor-completion/. This will use BPTF to complete the incomplete tensors generated from pretrained SVM weights.

cd tensor-completion
matlab -nodisplay -nodesktop -r "try; complete incomplete/mitstates completed/mitstates_30_50.mat 30 50 1; catch; end; quit" > log.log 2> log.err
matlab -nodisplay -nodesktop -r "try; complete incomplete/zappos completed/zappos_100_50.mat 100 50 2; catch; end; quit" > log.log 2> log.err

More examples to train various kinds of models can be found in utils/examples.sh.

Model Evaluation

The Embedding models can be evaluated using the test script.

python test.py --model attributeop --lambda_aux 1.0 --load cv/mitstates/attrop+aux+inv+comm/ckpt_E_800_At_0.188_O_0.227_Cl_0.120_Op_0.114.t7

The AnalogousAttr model can be evaluated using:

python svm.py --dataset mitstates --data_dir data/mit-states/ --evaltf --completed tensor-completion/completed/mitstates_30_50.mat
python svm.py --dataset zappos --data_dir data/ut-zap50k/ --evaltf --completed tensor-completion/completed/zappos_100_50.mat

Cite

If you find this repository useful in your own research, please consider citing:

@article{nagarajan2018attrop,
  title={Attributes as Operators},
  author={Nagarajan, Tushar and Grauman, Kristen},
  journal={ECCV},
  year={2018}
}

attributes-as-operators's People

Contributors

tushar-n 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.