jwyang / graph-rcnn.pytorch

[ECCV 2018] Official code for "Graph R-CNN for Scene Graph Generation"
732 stars 157 forks source link

TypeError: Boolean indexing array has incompatible shape #65

Open lorylei opened 5 years ago

lorylei commented 5 years ago

File "main.py", line 127, in main() File "main.py", line 122, in main model = train(cfg, args) File "main.py", line 68, in train model = build_model(cfg, arguments, args.local_rank, args.distributed) File "/data2/linbingqian/test/graph-rcnn/lib/model.py", line 307, in build_model return SceneGraphGeneration(cfg, arguments, local_rank, distributed) File "/data2/linbingqian/test/graph-rcnn/lib/model.py", line 31, in init self.data_loader_train = build_data_loader(cfg, split="train", is_distributed=distributed) File "/data2/linbingqian/test/graph-rcnn/lib/data/build.py", line 60, in build_data_loader dataset = vg_hdf5(cfg, split=split, transforms=transforms, num_im=num_im) File "/data2/linbingqian/test/graph-rcnn/lib/data/vg_hdf5.py", line 56, in init filter_non_overlap=filter_non_overlap and split == "train", File "/data2/linbingqian/test/graph-rcnn/lib/data/vg_hdf5.py", line 243, in load_graphs im_widths = im_h5["image_widths"][split_mask] File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "/home/linbingqian/anaconda3/envs/grcnn/lib/python3.7/site-packages/h5py/_hl/dataset.py", line 553, in getitem selection = sel.select(self.shape, args, dsid=self.id) File "/home/linbingqian/anaconda3/envs/grcnn/lib/python3.7/site-packages/h5py/_hl/selections.py", line 72, in select sel[arg] File "/home/linbingqian/anaconda3/envs/grcnn/lib/python3.7/site-packages/h5py/_hl/selections.py", line 214, in getitem raise TypeError("Boolean indexing array has incompatible shape")

how to deal with such circumustance?

SkyOL5 commented 4 years ago

Hello @lorylei , have you figure out how to deal with this issue? I faced the same error when I try to use mini-vg dataset....

MinglangQiao commented 2 years ago

This is because the length of "im_h5["image_widths"]" in https://github.com/jwyang/graph-rcnn.pytorch/blob/0f294ecb86d5f130e82ee85246b6afd5180240e5/lib/data/vg_hdf5.py#L243 is 108,072, while its index "split_mask" has 108,073 elements. Thus, change:

im_widths = im_h5["image_widths"][split_mask] im_heights = im_h5["image_heights"][split_mask]

to

im_widths = im_h5["image_widths"][split_mask[:-1]] im_heights = im_h5["image_heights"][split_mask[:-1]]

would be a workaround

vamshi813 commented 1 year ago

File "/home/vkmtrddy/Graph-RCNN-master/main.py", line 133, in main() File "/home/vkmtrddy/Graph-RCNN-master/main.py", line 128, in main model = train(cfg, args) File "/home/vkmtrddy/Graph-RCNN-master/main.py", line 73, in train model = build_model(cfg, arguments, args.local_rank, args.distributed) File "/home/vkmtrddy/Graph-RCNN-master/lib/model.py", line 307, in build_model return SceneGraphGeneration(cfg, arguments, local_rank, distributed) File "/home/vkmtrddy/Graph-RCNN-master/lib/model.py", line 31, in init self.data_loader_train = build_data_loader(cfg, split="train", is_distributed=distributed) File "/home/vkmtrddy/Graph-RCNN-master/lib/data/build.py", line 60, in build_data_loader dataset = vg_hdf5(cfg, split=split, transforms=transforms, num_im=num_im) File "/home/vkmtrddy/Graph-RCNN-master/lib/data/vg_hdf5.py", line 53, in init self.split_mask, self.image_index, self.im_sizes, self.gt_boxes, self.gt_classes, self.relationships = load_graphs( File "/home/vkmtrddy/Graph-RCNN-master/lib/data/vg_hdf5.py", line 249, in load_graphs im_widths = im_h5["image_widths"][split_mask[:-1]] File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "/cm/shared/public/apps/python/3.9.13/lib/python3.9/site-packages/h5py/_hl/dataset.py", line 814, in getitem selection = sel.select(self.shape, args, dataset=self) File "/cm/shared/public/apps/python/3.9.13/lib/python3.9/site-packages/h5py/_hl/selections.py", line 64, in select raise TypeError("Boolean indexing array has incompatible shape") TypeError: Boolean indexing array has incompatible shape