facebookresearch / maskrcnn-benchmark

Fast, modular reference implementation of Instance Segmentation and Object Detection algorithms in PyTorch.
MIT License
9.31k stars 2.49k forks source link

when i use this to generate scene graph,i get "RuntimeError" #1336

Open xixihawokao opened 2 years ago

xixihawokao commented 2 years ago

🐛 Bug

when i use this to generate scene graph,i get "RuntimeError", and but some it's fine working on other graph

To Reproduce

Steps to reproduce the behavior:

1.i use this command from "readme" python tools/demo/demo_image.py --config_file sgg_configs/vrd/R152FPN_vrd_reldn.yaml \ --img_file /home/user/JL/myhome/datasets/VQA_datasets/okvqa/Images/train2014/COCO_train2014_000000179526.jpg \ --save_file 'output/1024px-Gen_Robert_E_Lee_on_Traveler_at_Gettysburg_Pa.reldn_relation.jpg'\ --visualize_relation MODEL.ROI_RELATION_HEAD.DETECTOR_PRE_CALCULATED False 2.i just modified the "img_file" for coco 2014 train datasets like this picture id "COCO_train2014_000000179526.jpg"

  1. and i get the error:

./datasets openimages_v5c/vrd/ji_vrd_labelmap.json Traceback (most recent call last): File "tools/demo/demo_image.py", line 192, in main() File "tools/demo/demo_image.py", line 128, in main dets = detect_objects_on_single_image(model, transforms, cv2_img) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/scene_graph_benchmark/tools/demo/detect_utils.py", line 25, in detect_objects_on_single_image prediction = model(img_input) File "/home/user/JL/myhome/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, kwargs) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/scene_graph_benchmark/scene_graph_benchmark/scene_parser.py", line 319, in forward x_pairs, prediction_pairs, relation_losses = self.relation_head(features, predictions, targets) File "/home/user/JL/myhome/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/scene_graph_benchmark/scene_graph_benchmark/relation_head/relation_head.py", line 211, in forward = self.rel_predictor(features, proposals, proposal_pairs) File "/home/user/JL/myhome/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/scene_graph_benchmark/scene_graph_benchmark/relation_head/reldn/reldn.py", line 80, in forward xpred, = self.pred_feature_extractor(features, proposals, proposal_pairs, use_relu=False) File "/home/user/JL/myhome/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/scene_graph_benchmark/scene_graph_benchmark/relation_head/roi_relation_feature_extractors.py", line 134, in forward rel_inds = _get_rel_inds(im_inds, im_inds_pairs, proposal_idx_pairs, len(proposals)) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/scene_graph_benchmark/scene_graph_benchmark/relation_head/sparse_targets.py", line 113, in _get_rel_inds num_rels_im = full_count(im_inds_pairs) File "/home/user/JL/myhome/juyterNotebook_folder/test/test_for_code/scene_graph_benchmark/scene_graph_benchmark/relation_head/sparse_targets.py", line 96, in full_count num_im_new[unique_idx] = num_im RuntimeError: Index put requires the source and destination dtypes match, got Float for the destination and Long for the source.

Expected behavior

i want to use this to generate scence graph for coco datasets

Environment

Please copy and paste the output from the environment collection script from PyTorch (or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

Additional context