jiasenlu / adaptiveattention Goto Github PK
View Code? Open in Web Editor NEWImplementation of "Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning"
Home Page: https://arxiv.org/abs/1612.01887
License: Other
Implementation of "Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning"
Home Page: https://arxiv.org/abs/1612.01887
License: Other
Hi, I used your pretrained model for Flickr30k Dataset. However, the performance is very bad than the performance on paper.
Bleu_1: 0.206
Bleu_2: 0.122
Bleu_3: 0.077
Bleu_4: 0.051
computing METEOR score...
METEOR: 0.108
computing Rouge score...
ROUGE_L: 0.278
computing CIDEr score...
CIDEr: 0.377
computing SPICE score...
Parsing reference captions
Parsing test captions
SPICE evaluation took: 3.287 s
SPICE: 0.161
Could you please check the pretrained model ?
By the way, after creating h5 and json file for flickr30k dataset, parameter number did not match with the pretrained model. Thus, I had to take word_count_threshold 4.
Pretrained Model
For evaluation, you can directly download the pretrained model.
The pre-trained model for COCO can be download here. The pre-trained model for Flickr30K can be download here.
Does anyone know if this has a tensorflow version?
It seems that in many papers the input of LSTM is just composed of word embedding vector.
I am not familiar with lua and torch. Do you have a tensorflow version or provide some other available implement based on tensorflow ?
Please tell me how to run th command in google colab else in local machine ?
Hi Jiasen,
The performance of your released model, (coco_train.t7, cocotalk_vocab.json)
seems to be much better than the performance reported in the highlighted row from table 1 in your paper (screenshot attached). I feel that I must be understanding something incorrectly about the code/models.
My understanding is that the following models were trained using the standard karpathy splits of the mscoco captions and that model (1) was used to generate the lowermost results in table 1.
URL=https://filebox.ece.vt.edu/~jiasenlu/codeRelease/AdaptiveAttention
wget $URL/model/COCO/coco_train/coco_train.t7 # (1)
wget $URL/data/COCO/cocotalk_vocab.json -O coco_vocab.json
wget $URL/model/COCO/coco_challenge/model_id1_34.t7 -O coco_challenge_model_id1_34.t7 # (2)
wget $URL/data/COCO/cocotalk_challenge_vocab.json -O coco_challenge_vocab.json
However when I test the predictions of these models on the test portion of karpathy splits then all the metrics are much higher than the ones reported in table 1 of the paper. Do you have any idea why the eval metrics might be so much better than the ones reported in the paper? I have tested my own evaluation code as well and tested it by reproducing the results in the LRCN paper so I am fairly sure that my evaluation code is correct.
Bleu1 | B2 | B3 | B4 | Cider | Meteor | Rouge | |
---|---|---|---|---|---|---|---|
InPaper | 0.742 | 0.580 | 0.439 | 0.332 | 1.085 | 0.266 | 0.549 |
MyEval (1) | 0.794 | 0.647 | 0.513 | 0.403 | 1.287 | 0.293 | 0.595 |
MyEval (2) | 0.782 | 0.628 | 0.485 | 0.368 | 1.219 | 0.285 | 0.580 |
Loading model from: save/coco_train.t7
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:343: unknown Torch class <cudnn.SpatialConvolution>
stack traceback:
[C]: in function 'error'
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:343: in function 'readObject'
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:369: in function 'readObject'
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:369: in function 'readObject'
/home/sarath/torch/install/share/lua/5.1/nn/Module.lua:192: in function 'read'
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:351: in function 'readObject'
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:369: in function 'readObject'
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:369: in function 'readObject'
/home/sarath/torch/install/share/lua/5.1/torch/File.lua:409: in function 'load'
[string "opt = {}..."]:14: in main chunk
[C]: in function 'xpcall'
/home/sarath/torch/install/share/lua/5.1/itorch/main.lua:210: in function </home/sarath/torch/install/share/lua/5.1/itorch/main.lua:174>
/home/sarath/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll'
/home/sarath/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
/home/sarath/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
/home/sarath/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
/home/sarath/torch/install/share/lua/5.1/itorch/main.lua:389: in main chunk
[C]: in function 'require'
(command line):1: in main chunk
[C]: at 0x00406670
Will the uploaded checkpoints work for even CPU DEMO ???
If not could you supply the checkpoints for CPU demo???
Hi @jiasenlu,
Thanks for uploading the code! I was going through it and comparing it with the paper.
I have a few questions on both the paper and code and was hoping you could clarify :
We use a single layer neural network to transform the visual sentinel vector st and LSTM output vector ht into new vectors that have the dimension d
Can you tell whats the single layer network in the paper?
If it refers to W_s and W_g, aren't they're converted to k dimension vectors?
In the code, at L29-L31, if I'm not mistaken, you're transforming w_t and v^g individually (notation from the paper) and summing them. In the paper however, they're simply concatenated and transformed to i2h.
In the attention.lua module, i'm not sure what the 2 conv inputs are? The paper only indicates h, s and V as inputs.
Dear Jiasen Lu,
Thank you for your interesting work.
I want to use this model for handwritten recognition. how to modify the cnn for larger input images?
Thanks alot.
Line utils = require 'misc.utils'
fails with the following traceback:
/home/****/torch/install/share/lua/5.1/hdf5/ffi.lua:71: Unsupported HDF5 version: 1.10.1
I installed it as was described in the torch-hdf5 repo, and version 1.10 must be newer than 1.8...
I also ran dpkg -s libhdf5-dev
which gave me Version: 1.8.16+docs-4ubuntu1
which is again newer than 1.8.14
Could you help?
What to do if I want to evaluate my own images like neuraltalk2: " $ th eval.lua -model /path/to/model -image_folder /path/to/image/directory -num_images 10 "
hi, do you have a pytorch version source code?
Thanks for code!
I have run the code and found that the validation results is very good, but during testing ,the result is embarrassing. I fisrt using the default parameters setting, and then the papameter setting is changed according to the content of paper. The situation is just the same. Like the note in the code, I'm dying overhere. Who knows how to obtain better results during testing? please tell me.
Thanks again!
According to the paper "Knowing When to Look", LSTM only receive the word vector Xt and the previous hidden state Ht-1,instead of the image vector,but your code includes the image vector when building the LSTM.
Would you please explain it ?
Thank you very much
Hello, when I loaded the pre-trained model,the following problem occurred:
/opt/zbstudio/bin/linux/x64/lua: ...ngll/PycharmProjects/AdaptiveAttention-master1/train.lua:162: bad argument #1 to 'copy' (sizes do not match at /tmp/luarocks_cutorch-scm-1-9584/cutorch/lib/THC/generic/THCTensorCopy.c:48)
stack traceback:
[C]: in function 'copy'
...ngll/PycharmProjects/AdaptiveAttention-master1/train.lua:162: in main chunk
[C]: at 0x00404f08
Can you help me?
Hi Jiasen,
I want to test the model on 2014 Testing images. After using prepro_coco_test.py to process the test images, I find that I am not able to let eval_visulization.lua to test correctly.
"ix_to_word" is lack in the output json made by prepro_coco_test.py
"labels" is lack in the output h5 made by prepro_coco_test.py
Could you tell me how to run the test image without their tagged captions?
Thanks!
I am having this error in Demo.ipynb
./misc/utils.lua:54: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: in function 'pairs'
./misc/utils.lua:54: in function 'count_keys'
[string "opt = {}..."]:9: in main chunk
[C]: in function 'xpcall'
/home/imrankhurram/.luarocks/share/lua/5.1/itorch/main.lua:210: in function </home/imrankhurram/.luarocks/share/lua/5.1/itorch/main.lua:174>
/home/imrankhurram/.luarocks/share/lua/5.1/lzmq/poller.lua:80: in function 'poll'
.../imrankhurram/.luarocks/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
.../imrankhurram/.luarocks/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
.../imrankhurram/.luarocks/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
/home/imrankhurram/.luarocks/share/lua/5.1/itorch/main.lua:389: in main chunk
[C]: in function 'require'
(command line):1: in main chunk
[C]: at 0x00406670
What is its solution?
Dear Jiasen Lu,
Thank you for your work on "Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning".
I am writing to ask about the "visual sentinel": what is the difference between your "visual sentinel" and the hidden state ht?
I think your visual sentinel "st" and the LSTM's hidden state "ht" are the same except for the different symbols. Am I right ? If I am wrong, could you kindly give me some further explanation?
Many thanks in advance for your answer.
Kind regards
Zhennan Wang
hi Jiasen,
the demo.ipynb file in the project gives the example on how to captioning.
but I don't know how to get the corresponding attention map for each word.
could you show the example?
thanks!
I think I got the answer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.