DiscCaptioning icon indicating copy to clipboard operation
DiscCaptioning copied to clipboard

when bash run_att_d.sh ,it broke

Open tonghaiping1996 opened this issue 6 years ago • 13 comments

tonghaiping1996 avatar Mar 01 '20 15:03 tonghaiping1996

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_critical_reward , cider_scores = CiderD_scorer.compute_score(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'

tonghaiping1996 avatar Mar 01 '20 15:03 tonghaiping1996

Did you use the submodules cider to compute cider?

ruotianluo avatar Mar 01 '20 15:03 ruotianluo

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)

tonghaiping1996 avatar Mar 01 '20 15:03 tonghaiping1996

image

ruotianluo avatar Mar 01 '20 16:03 ruotianluo

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

tonghaiping1996 avatar Mar 01 '20 17:03 tonghaiping1996

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?

ruotianluo avatar Mar 01 '20 17:03 ruotianluo

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_critical_reward , cider_scores = CiderD_scorer.compute_score(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'

tonghaiping1996 avatar Mar 01 '20 17:03 tonghaiping1996

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.

ruotianluo avatar Mar 01 '20 17:03 ruotianluo

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')

tonghaiping1996 avatar Mar 02 '20 02:03 tonghaiping1996

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

ruotianluo avatar Mar 02 '20 02:03 ruotianluo

self.document_frequency: 0.0

tonghaiping1996 avatar Mar 02 '20 02:03 tonghaiping1996

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

ruotianluo avatar Mar 02 '20 02:03 ruotianluo

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

tonghaiping1996 avatar Mar 02 '20 02:03 tonghaiping1996