karpathy/neuraltalk

list index out of range error

pecorarista opened this issue · 3 comments

I created coco_sample directory containing the following files.

  • COCO_val2014_000000463825.jpg
  • model_checkpoint_coco_visionlab43.stanford.edu_lstm_11.14.p (from here)
  • tasks.txt (containing one line COCO_val2014_000000463825.jpg)
  • vgg_feats.mat (from here)

I ran the following command.

python predict_on_images.py coco_sample/model_checkpoint_coco_visionlab43.stanford.edu_lstm_11.14.p -r coco_sample

I got an error message as below.

parsed parameters:
{
"beam_size": 1,
"checkpoint_path": "coco_sample/model_checkpoint_coco_visionlab43.stanford.edu_lstm_11.14.p",
"root_path": "coco_sample"
}
loading checkpoint coco_sample/model_checkpoint_coco_visionlab43.stanford.edu_lstm_11.14.p
image 0/123287:
/home/ec2-user/neuraltalk/imagernn/lstm_generator.py:227: RuntimeWarning: overflow encountered in exp
IFOGf[t,:3_d] = 1.0/(1.0+np.exp(-IFOG[t,:3_d]))
PRED: (-14.587771) a man and a woman sitting on a bench in the middle of a park
image 1/123287:
Traceback (most recent call last):
File "predict_on_images.py", line 109, in
main(params)
File "predict_on_images.py", line 66, in main
img['local_file_path'] =img_names[n]
IndexError: list index out of range

Isn't it possible to run predict_on_images.py on a few images?

Maybe should check "-m" parameter in predict_on_images.py.

Thank you @liuchang8am.
But I don't understand what you are saying.
I don't think predict_on_images.py provides "-m" option.

I understand why I got such a strange result.
I didn't know how vgg_feats.mat was used and
that filenames in tasks.txt should have been aligned according to the order of features in that file.

After I wrote filenames in tasks.txt according to the order of files in dataset.json,
which I got from here,
neuraltalk generates reasonable sentences for each picture of MS COCO.

Thank you.