ruotianluo / DiscCaptioning

Code for Discriminability objective for training descriptive captions(CVPR 2018)
110 stars 21 forks source link

when bash run_att_d.sh ,it broke #20

Open tonghaiping1996 opened 4 years ago

tonghaiping1996 commented 4 years ago

hello,when i run bash run_att_d.sh,it was wrong,can you help me ? thank you~: File "train.py", line 242, in train(opt) File "train.py", line 121, in train loss = model(fc_feats, att_feats, att_masks, labels, masks, data) File "/root/anaconda3/envs/PSENet1/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, **kwargs) File "/mnt/code/dis_fpn+bot/models/JointModel.py", line 116, in forward reward, cider_greedy = rewards.get_self_critical_reward(data, gen_result, greedy_res) File "/mnt/code/dis_fpn+bot/misc/rewards.py", line 50, in get_self_criticalreward , cider_scores = CiderD_scorer.computescore(gts, res) File "/root/anaconda3/envs/PSENet1/lib/python2.7/site-packages/pyciderevalcap/ciderD/ciderD.py", line 49, in compute_score (score, scores) = self.cider_scorer.compute_score() File "/root/anaconda3/envs/PSENet1/lib/python2.7/site-packages/pyciderevalcap/ciderD/ciderD_scorer.py", line 209, in compute_score score = self.compute_cider() File "/root/anaconda3/envs/PSENet1/lib/python2.7/site-packages/pyciderevalcap/ciderD/ciderD_scorer.py", line 184, in compute_cider vec, norm, length = counts2vec(test) File "/root/anaconda3/envs/PSENet1/lib/python2.7/site-packages/pyciderevalcap/ciderD/ciderD_scorer.py", line 133, in counts2vec df = np.log(max(1.0, self.document_frequency[ngram])) TypeError: 'float' object has no attribute 'getitem'

ruotianluo commented 4 years ago

Did you use the submodules cider to compute cider?

tonghaiping1996 commented 4 years ago

thank you for your reply~ In the bash run_att_d.sh ,i set cider_optimization =1,then compute cider as follow and take the error: (what is the meaning of the submodules?) File "/mnt/code/dis_fpn+bot/models/JointModel.py", line 116, in forward reward, cider_greedy = rewards.get_self_critical_reward(data, gen_result, greedy_res) File "/mnt/code/dis_fpn+bot/misc/rewards.py", line 50, in get_self_critical_reward , cider_scores = CiderD_scorer.compute_score(gts, res)

ruotianluo commented 4 years ago
image
tonghaiping1996 commented 4 years ago

I just redownloaded the submodule and still got this error...

ruotianluo commented 4 years ago

File "/root/anaconda3/envs/PSENet1/lib/python2.7/site-packages/pyciderevalcap/ciderD/ciderD_scorer.py", line 133, in counts2vec df = np.log(max(1.0, self.document_frequency[ngram])) TypeError: 'float' object has no attribute 'getitem'

The path python2.7/site-packages/pyciderevalcap seems indicating that you can a pyciderevalcap installed in your enviroment. Can you verify if the path is different or the same?

tonghaiping1996 commented 4 years ago

I deleted the python2.7/site-packages/pyciderevalcap package,use the submodel under the DiscCaptioning-master,but still got the error... File "train.py", line 242, in train(opt) File "train.py", line 121, in train loss = model(fc_feats, att_feats, att_masks, labels, masks, data) File "/root/anaconda3/envs/PSENet1/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, **kwargs) File "/mnt/code/DiscCaptioning-master/models/JointModel.py", line 116, in forward reward, cider_greedy = rewards.get_self_critical_reward(data, gen_result, greedy_res) File "/mnt/code/DiscCaptioning-master/misc/rewards.py", line 50, in get_self_criticalreward , cider_scores = CiderD_scorer.computescore(gts, res) File "cider/pyciderevalcap/ciderD/ciderD.py", line 54, in compute_score (score, scores) = tmp_cider_scorer.compute_score() File "cider/pyciderevalcap/ciderD/ciderD_scorer.py", line 219, in compute_score score = self.compute_cider() File "cider/pyciderevalcap/ciderD/ciderD_scorer.py", line 194, in compute_cider vec, norm, length = self.counts2vec(test) File "cider/pyciderevalcap/ciderD/ciderD_scorer.py", line 169, in counts2vec df = np.log(max(1.0, self.document_frequency[ngram])) TypeError: 'float' object has no attribute 'getitem'

ruotianluo commented 4 years ago

Did you run python scripts/prepro_ngrams.py --input_json data/dataset_coco.json --dict_json data/cocotalk.json --output_pkl data/coco-train --split train.

tonghaiping1996 commented 4 years ago

yes,the result files are there TIM图片20200302100759

I print the ngram of File "cider/pyciderevalcap/ciderD/ciderD_scorer.py", line 171, in counts2vec df = np.log(max(1.0, self.document_frequency[ngram])) the result :ngram>>>> <type 'tuple'> ('3', '1', '271', '17')

ruotianluo commented 4 years ago

can you print self.document_frequency, this should be dictionary.

tonghaiping1996 commented 4 years ago

self.document_frequency: 0.0

ruotianluo commented 4 years ago

can you print what's in coco-train-idx.p

tonghaiping1996 commented 4 years ago

Thank you very much. The problem really is in this document. Thank you again.