ttanida / rgrg

Code for the CVPR paper "Interactive and Explainable Region-guided Radiology Report Generation"
MIT License
147 stars 25 forks source link

Inference Error #29

Open Markin-Wang opened 5 months ago

Markin-Wang commented 5 months ago

Hi, thank you for your work. when I do the inference on MIMIC-CXR dataset using the checkpoint provided and the script test_set_evaluation.py. It gives me following error:

[INFO]: Test loader: computing scores for object detector, region selection and region abnormal module... 0it [00:00, ?it/s] [INFO]: Test loader: computing scores for object detector, region selection and region abnormal module... DONE. [INFO]: Test loader 2: computing scores for object detector, region selection and region abnormal module... 54%|███████████████████████████████████████████████████████████▊
Traceback (most recent call last): File "/home/jun/Documents/projects/phd/baselines/rgrg/./src/full_model/test_set_evaluation.py", line 898, in main() File "/home/jun/Documents/projects/phd/baselines/rgrg/./src/full_model/test_set_evaluation.py", line 894, in main evaluate_model_on_test_set(model, test_loader, test_2_loader, tokenizer) File "/home/jun/Documents/projects/phd/baselines/rgrg/./src/full_model/test_set_evaluation.py", line 735, in evaluate_model_on_test_set obj_detector_scores, region_selection_scores, region_abnormal_scores = evaluate_obj_detector_and_binary_classifiers_on_test_set(model, test_loader, test_2_loader) File "/home/jun/Documents/projects/phd/baselines/rgrg/./src/full_model/test_set_evaluation.py", line 709, in evaluate_obj_detector_and_binary_classifiers_on_test_set num_images = iterate_over_test_loader(test_2_loader, num_images, is_test_2_loader=True) File "/home/jun/Documents/projects/phd/baselines/rgrg/./src/full_model/test_set_evaluation.py", line 592, in iterate_over_test_loader output = model( File "/home/jun/anaconda3/envs/rgrg/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, *kwargs) File "/home/jun/Documents/projects/phd/baselines/rgrg/src/full_model/report_generation_model.py", line 91, in forward obj_detector_loss_dict, detections, top_region_features, class_detected = self.object_detector(images, image_targets) File "/home/jun/anaconda3/envs/rgrg/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, **kwargs) File "/home/jun/Documents/projects/phd/baselines/rgrg/src/object_detector/object_detector.py", line 217, in forward self._check_targets(targets) File "/home/jun/Documents/projects/phd/baselines/rgrg/src/object_detector/object_detector.py", line 148, in _check_targets torch._assert( File "/home/jun/anaconda3/envs/rgrg/lib/python3.9/site-packages/torch/init.py", line 833, in _assert assert condition, message AssertionError: Expected target boxes to be a tensor of shape [N, 4], got torch.Size([0]).

Seems no target boxes are given?

ttanida commented 5 months ago

If you didn't change the script and used the correct checkpoint, then the problem is the data. Check that the test csv files correct specify the target boxes.

If they don't (which is most likely the case), debug why create_dataset.py did not correctly create the csv files. create_dataset.py is just a simple python script, just put some break points in there and see what goes on.