ysmiura / ifcc

The code of Improving Factual Completeness and Consistency of Image-to-text Radiology Report Generation
Apache License 2.0
87 stars 19 forks source link

error in the inference.py when using it on the open-i dataset #5

Open ma5n1sh opened 2 years ago

ma5n1sh commented 2 years ago

when trying to use the inference.py using the following parameters !python infer.py --cuda --corpus open-i --stanza-download --splits /content/ifcc/meta.txt --cache-data cache --batch-size 24 --entity-match /content/open-i_ner.txt.gz --cider-df /content/drive/MyDrive/open-i_train-df.bin.gz --img-model densenet --img-pretrained resources/chexpert_auc14.dict.gz /content/open-i /content/ifcc/checkpoints/checkpoint_nll-bs-emnli.dict.gz resources/glove_mimic-cxr_train.512.txt.gz out_infer we get the following error : Unexpected exception: Traceback (most recent call last): File "infer.py", line 88, in main EpochLog.log_datasets(logger, pbar_vals, 0, 0, None, val_loader, test_loader, save=False, progress=True) File "/content/ifcc/clinicgen/log.py", line 30, in log_datasets results[split] = logger.evaluator.generate_and_eval(data_loader, prog_name) File "/content/ifcc/clinicgen/eval.py", line 668, in generate_and_eval scores, scores_detailed = self.eval(report_ids, refs, hypos, tfidf_vectorizer) File "/content/ifcc/clinicgen/eval.py", line 559, in eval mse, sde, msn, sdn = self.entity_matcher.score(ref_ids, hypos_l) File "/content/ifcc/clinicgen/eval.py", line 156, in score _, _, _, stats = self.nli.sentence_scores_bert_score(texts1, texts2, label='all', prf=self.prf) File "/content/ifcc/clinicgen/nli.py", line 221, in sentence_scores_bert_score _, _, bf = self.bert_score_model.score(bsents1, bsents2) File "/content/ifcc/clinicgen/nli.py", line 535, in score device=self.device, batch_size=self.batch_size, all_layers=self.all_layers).cpu() File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 520, in bert_cos_score_idf sen_batch, model, tokenizer, idf_dict, device=device, all_layers=all_layers File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 399, in get_bert_embedding model, padded_sens[i : i + batch_size], attention_mask=mask[i : i + batch_size], all_layers=all_layers, File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 309, in bert_encode out = model(x, attention_mask=attention_mask, output_hidden_states=all_layers) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'output_hidden_states'

ZQ8332 commented 1 year ago

when trying to use the inference.py using the following parameters !python infer.py --cuda --corpus open-i --stanza-download --splits /content/ifcc/meta.txt --cache-data cache --batch-size 24 --entity-match /content/open-i_ner.txt.gz --cider-df /content/drive/MyDrive/open-i_train-df.bin.gz --img-model densenet --img-pretrained resources/chexpert_auc14.dict.gz /content/open-i /content/ifcc/checkpoints/checkpoint_nll-bs-emnli.dict.gz resources/glove_mimic-cxr_train.512.txt.gz out_infer we get the following error : Unexpected exception: Traceback (most recent call last): File "infer.py", line 88, in main EpochLog.log_datasets(logger, pbar_vals, 0, 0, None, val_loader, test_loader, save=False, progress=True) File "/content/ifcc/clinicgen/log.py", line 30, in log_datasets results[split] = logger.evaluator.generate_and_eval(data_loader, prog_name) File "/content/ifcc/clinicgen/eval.py", line 668, in generate_and_eval scores, scores_detailed = self.eval(report_ids, refs, hypos, tfidf_vectorizer) File "/content/ifcc/clinicgen/eval.py", line 559, in eval mse, sde, msn, sdn = self.entity_matcher.score(ref_ids, hypos_l) File "/content/ifcc/clinicgen/eval.py", line 156, in score _, _, _, stats = self.nli.sentence_scores_bert_score(texts1, texts2, label='all', prf=self.prf) File "/content/ifcc/clinicgen/nli.py", line 221, in sentence_scores_bert_score _, _, bf = self.bert_score_model.score(bsents1, bsents2) File "/content/ifcc/clinicgen/nli.py", line 535, in score device=self.device, batch_size=self.batch_size, all_layers=self.all_layers).cpu() File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 520, in bert_cos_score_idf sen_batch, model, tokenizer, idf_dict, device=device, all_layers=all_layers File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 399, in get_bert_embedding model, padded_sens[i : i + batch_size], attention_mask=mask[i : i + batch_size], all_layers=all_layers, File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 309, in bert_encode out = model(x, attention_mask=attention_mask, output_hidden_states=all_layers) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'output_hidden_states'

HI, may i ask how to preprocess open-i dataset

xcharxlie commented 1 year ago

HEre

when trying to use the inference.py using the following parameters !python infer.py --cuda --corpus open-i --stanza-download --splits /content/ifcc/meta.txt --cache-data cache --batch-size 24 --entity-match /content/open-i_ner.txt.gz --cider-df /content/drive/MyDrive/open-i_train-df.bin.gz --img-model densenet --img-pretrained resources/chexpert_auc14.dict.gz /content/open-i /content/ifcc/checkpoints/checkpoint_nll-bs-emnli.dict.gz resources/glove_mimic-cxr_train.512.txt.gz out_infer we get the following error : Unexpected exception: Traceback (most recent call last): File "infer.py", line 88, in main EpochLog.log_datasets(logger, pbar_vals, 0, 0, None, val_loader, test_loader, save=False, progress=True) File "/content/ifcc/clinicgen/log.py", line 30, in log_datasets results[split] = logger.evaluator.generate_and_eval(data_loader, prog_name) File "/content/ifcc/clinicgen/eval.py", line 668, in generate_and_eval scores, scores_detailed = self.eval(report_ids, refs, hypos, tfidf_vectorizer) File "/content/ifcc/clinicgen/eval.py", line 559, in eval mse, sde, msn, sdn = self.entity_matcher.score(ref_ids, hypos_l) File "/content/ifcc/clinicgen/eval.py", line 156, in score _, _, _, stats = self.nli.sentence_scores_bert_score(texts1, texts2, label='all', prf=self.prf) File "/content/ifcc/clinicgen/nli.py", line 221, in sentence_scores_bert_score _, _, bf = self.bert_score_model.score(bsents1, bsents2) File "/content/ifcc/clinicgen/nli.py", line 535, in score device=self.device, batch_size=self.batch_size, all_layers=self.all_layers).cpu() File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 520, in bert_cos_score_idf sen_batch, model, tokenizer, idf_dict, device=device, all_layers=all_layers File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 399, in get_bert_embedding model, padded_sens[i : i + batch_size], attention_mask=mask[i : i + batch_size], all_layers=all_layers, File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 309, in bert_encode out = model(x, attention_mask=attention_mask, output_hidden_states=all_layers) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'output_hidden_states'

HI there, did you find any solution for this problem? I'm now meeting the same issue.

xcharxlie commented 1 year ago

when trying to use the inference.py using the following parameters !python infer.py --cuda --corpus open-i --stanza-download --splits /content/ifcc/meta.txt --cache-data cache --batch-size 24 --entity-match /content/open-i_ner.txt.gz --cider-df /content/drive/MyDrive/open-i_train-df.bin.gz --img-model densenet --img-pretrained resources/chexpert_auc14.dict.gz /content/open-i /content/ifcc/checkpoints/checkpoint_nll-bs-emnli.dict.gz resources/glove_mimic-cxr_train.512.txt.gz out_infer we get the following error : Unexpected exception: Traceback (most recent call last): File "infer.py", line 88, in main EpochLog.log_datasets(logger, pbar_vals, 0, 0, None, val_loader, test_loader, save=False, progress=True) File "/content/ifcc/clinicgen/log.py", line 30, in log_datasets results[split] = logger.evaluator.generate_and_eval(data_loader, prog_name) File "/content/ifcc/clinicgen/eval.py", line 668, in generate_and_eval scores, scores_detailed = self.eval(report_ids, refs, hypos, tfidf_vectorizer) File "/content/ifcc/clinicgen/eval.py", line 559, in eval mse, sde, msn, sdn = self.entity_matcher.score(ref_ids, hypos_l) File "/content/ifcc/clinicgen/eval.py", line 156, in score _, _, _, stats = self.nli.sentence_scores_bert_score(texts1, texts2, label='all', prf=self.prf) File "/content/ifcc/clinicgen/nli.py", line 221, in sentence_scores_bert_score _, _, bf = self.bert_score_model.score(bsents1, bsents2) File "/content/ifcc/clinicgen/nli.py", line 535, in score device=self.device, batch_size=self.batch_size, all_layers=self.all_layers).cpu() File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 520, in bert_cos_score_idf sen_batch, model, tokenizer, idf_dict, device=device, all_layers=all_layers File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 399, in get_bert_embedding model, padded_sens[i : i + batch_size], attention_mask=mask[i : i + batch_size], all_layers=all_layers, File "/usr/local/lib/python3.7/dist-packages/bert_score/utils.py", line 309, in bert_encode out = model(x, attention_mask=attention_mask, output_hidden_states=all_layers) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'output_hidden_states'

HI, may i ask how to preprocess open-i dataset

Hi there, did you solve it? I have the same problem