microsoft / Oscar

Oscar and VinVL
MIT License
1.03k stars 248 forks source link

train and validating without the label from object detection, (add_od_labels = False) #169

Open DesaleF opened 2 years ago

DesaleF commented 2 years ago

I have been playing with VinVL models for a while. I was trying to evaluate the model without the labels of the object detector. However after training the model with add_od_label set to False, is causing the following problem. I tried to bebug it but I did not manage to find the main cause of the problem. the error is cause by the shape mismat of input_ids at line 807 of modeling_bert.py file. I would approciate for any help regarding training and evaluating VinVL model without the object detection labels.


Traceback (most recent call last):
  File "oscar/run_captioning.py", line 967, in <module>
    main()
  File "oscar/run_captioning.py", line 961, in main
    evaluate_file = evaluate(args, test_dataloader, model, tokenizer, checkpoint)
  File "oscar/run_captioning.py", line 678, in evaluate
    test(args, val_dataloader, model, tokenizer, predict_file)
  File "oscar/run_captioning.py", line 770, in test
    tsv_writer(gen_rows(), cache_file)
  File "/usr/src/app/Oscar/oscar/utils/tsv_file_ops.py", line 17, in tsv_writer
    for value in values:
  File "oscar/run_captioning.py", line 754, in gen_rows
    outputs = model(**inputs)
  File "/miniconda/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/src/app/Oscar/oscar/modeling/modeling_bert.py", line 631, in forward
    return self.generate(*args, **kwargs)
  File "/usr/src/app/Oscar/oscar/modeling/modeling_bert.py", line 806, in generate
    assert input_ids.shape == (batch_size, self.max_seq_len)
AssertionError

The training stage works without any error, but I am having this problem during evaluation stage

linlin9527 commented 2 years ago

Can you tell me how you solved this problem? thank you