sairin1202 / Commonsense-Knowledge-Aware-Concept-Selection-For-Diverse-and-Informative-Visual-Storytelling

The implement of Commonsense Knowledge Aware Concept Selection For Diverse and Informative Visual Storytelling
MIT License
11 stars 2 forks source link

TypeError: tuple indices must be integers or slices, not str #4

Open caoyuanbao opened 3 years ago

caoyuanbao commented 3 years ago

Hello, Now I have an error when I run the evaluation.py in visualstorytelling section, it seems due to the definition of EncoderOut in visualstorytelling/generator.py which is a namedtuple. error is as follows:

Traceback (most recent call last):
  File "evaluation.py", line 169, in <module>
    main()
  File "evaluation.py", line 165, in main
    generate(opt, bart)
  File "evaluation.py", line 135, in generate
    hypo = generate_sentence(album_id, keywords, model)  # keywords  5 ge 809
  File "evaluation.py", line 90, in generate_sentence
    story = model.generate(cond=feats, keys=keywords, top_k=-1, top_p=0.9)
  File "/home/caidesheng/caojie/workspace2/Commonsense-Knowledge-Aware-Concept-Selection-For-Diverse-and-Informative-Visual-Storytelling/visualstorytelling/bart.py", line 109, in generate
    'src_lengths': torch.tensor([cond.shape[1]+key_tokens.shape[1]])
  File "/home/caidesheng/miniconda3/envs/teran/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context
    return func(*args, **kwargs)
  File "/home/caidesheng/caojie/workspace2/Commonsense-Knowledge-Aware-Concept-Selection-For-Diverse-and-Informative-Visual-Storytelling/visualstorytelling/generator.py", line 116, in generate
    return self._generate(model, sample, **kwargs)
  File "/home/caidesheng/miniconda3/envs/teran/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context
    return func(*args, **kwargs)
  File "/home/caidesheng/caojie/workspace2/Commonsense-Knowledge-Aware-Concept-Selection-For-Diverse-and-Informative-Visual-Storytelling/visualstorytelling/generator.py", line 304, in _generate
    tokens[:, :step + 1], encoder_outs, temperature=self.temperature,
  File "/home/caidesheng/miniconda3/envs/teran/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context
    return func(*args, **kwargs)
  File "/home/caidesheng/caojie/workspace2/Commonsense-Knowledge-Aware-Concept-Selection-For-Diverse-and-Informative-Visual-Storytelling/visualstorytelling/generator.py", line 545, in forward_decoder
    temperature=temperature,
  File "/home/caidesheng/caojie/workspace2/Commonsense-Knowledge-Aware-Concept-Selection-For-Diverse-and-Informative-Visual-Storytelling/visualstorytelling/generator.py", line 577, in _decode_one
    if self.incremental_states is not None:
  File "/home/caidesheng/.cache/torch/hub/pytorch_fairseq_master/fairseq/models/fairseq_model.py", line 326, in forward_decoder
    return self.decoder(prev_output_tokens, **kwargs)
  File "/home/caidesheng/miniconda3/envs/teran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/caidesheng/.cache/torch/hub/pytorch_fairseq_master/fairseq/models/transformer/transformer_decoder.py", line 222, in forward
    alignment_heads=alignment_heads,
  File "/home/caidesheng/.cache/torch/hub/pytorch_fairseq_master/fairseq/models/transformer/transformer_decoder.py", line 244, in extract_features
    alignment_heads,
  File "/home/caidesheng/.cache/torch/hub/pytorch_fairseq_master/fairseq/models/transformer/transformer_decoder.py", line 287, in extract_features_scriptable
    if encoder_out is not None and len(encoder_out["encoder_out"]) > 0:
TypeError: tuple indices must be integers or slices, not str
WiteRon commented 8 months ago

same error

caoyuanbao commented 8 months ago

自动回复:你好,我已经收到你的邮件,待我细看后联系曹洁