jz462 / Large-Scale-VRD.pytorch

Implementation for the AAAI2019 paper "Large-scale Visual Relationship Understanding"
https://arxiv.org/abs/1804.10660
MIT License
144 stars 25 forks source link

Using --use_gt_boxes and --use_gt_labels with run_inference() #15

Open pulinagrawal opened 4 years ago

pulinagrawal commented 4 years ago

Hi,

Can we use ground truth boxes and/or labels with run_inference()? If so, I cannot find an example of the format that they need to be provided in.

Any help will be much appreciated. Thanks!

pulinagrawal commented 4 years ago

I have tried box_proposals but the don't affect the output. I also tried roidb which gave me the following error

Traceback (most recent call last): File "/home/ubuntu/Large-Scale-VRD.pytorch/tools/prediction.py", line 283, in im_results = im_detect_rels(model, im, dataset_name, box_proposals, timers, roidb=roidb, use_gt_labels=True) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/core/test_rel.py", line 56, in im_detect_rels rel_results = im_get_det_rels(model, im, dataset_name, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, box_proposals, roidb, use_gt_labels) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/core/test_rel.py", line 93, in im_get_det_rels return_dict = model(inputs) File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, *kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/nn/parallel/data_parallel.py", line 108, in forward outputs = [self.module(inputs[0], kwargs[0])] File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/model_builder_rel.py", line 233, in forward return self._forward(data, im_info, dataset_name, roidb, use_gt_labels, rpn_kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/model_builder_rel.py", line 303, in _forward sbj_det_feat = self.Box_Head(blob_conv, rel_ret, rois_name='sbj_rois', use_relu=True) File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, *kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/VGG16.py", line 72, in forward sampling_ratio=cfg.FAST_RCNN.ROI_XFORM_SAMPLING_RATIO File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/model_builder_rel.py", line 627, in roi_feature_transform resolution, resolution, spatial_scale, sampling_ratio)(blobs_in, rois) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/roi_xfrom/roi_align/functions/roi_align.py", line 28, in forward rois, output) File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/utils/ffi/init.py", line 202, in safe_call result = torch._C._safe_call(args, *kwargs) TypeError: initializer for ctype 'struct THCudaTensor ' must be a pointer to same type, not cdata 'struct THCudaDoubleTensor *'

With the following code


args.use_gt_boxes = True
args.use_gt_labels = True
box_proposals = np.array([np.array(inst.bbox, dtype=int) for inst in instance_list])
gt_labels = np.array([inst.label for inst in instance_list])
roidb = {}
roidb['sbj_gt_boxes'] = box_proposals
roidb['obj_gt_boxes'] = box_proposals
roidb['sbj_gt_labels'] = gt_labels
roidb['obj_gt_labels'] = gt_labels
im_results = im_detect_rels(model, im, dataset_name, box_proposals, timers, roidb=roidb, use_gt_labels=True)
print(im_results)`
junchen14 commented 3 years ago

I have tried box_proposals but the don't affect the output. I also tried roidb which gave me the following error

Traceback (most recent call last): File "/home/ubuntu/Large-Scale-VRD.pytorch/tools/prediction.py", line 283, in im_results = im_detect_rels(model, im, dataset_name, box_proposals, timers, roidb=roidb, use_gt_labels=True) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/core/test_rel.py", line 56, in im_detect_rels rel_results = im_get_det_rels(model, im, dataset_name, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, box_proposals, roidb, use_gt_labels) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/core/test_rel.py", line 93, in im_get_det_rels return_dict = model(inputs) File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, *kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/nn/parallel/data_parallel.py", line 108, in forward outputs = [self.module(inputs[0], kwargs[0])] File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/model_builder_rel.py", line 233, in forward return self._forward(data, im_info, dataset_name, roidb, use_gt_labels, rpn_kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/model_builder_rel.py", line 303, in _forward sbj_det_feat = self.Box_Head(blob_conv, rel_ret, rois_name='sbj_rois', use_relu=True) File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/VGG16.py", line 72, in forward sampling_ratio=cfg.FAST_RCNN.ROI_XFORM_SAMPLING_RATIO File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/model_builder_rel.py", line 627, in roi_feature_transform resolution, resolution, spatial_scale, sampling_ratio)(blobs_in, rois) File "/home/ubuntu/Large-Scale-VRD.pytorch/lib/modeling/roi_xfrom/roi_align/functions/roi_align.py", line 28, in forward rois, output) File "/home/ubuntu/anaconda3/envs/scene-graph/lib/python3.7/site-packages/torch/utils/ffi/init*.py", line 202, in safe_call result = torch._C._safe_call(args, *kwargs) TypeError: initializer for ctype 'struct THCudaTensor ' must be a pointer to same type, not cdata 'struct THCudaDoubleTensor *'

With the following code

args.use_gt_boxes = True
args.use_gt_labels = True
box_proposals = np.array([np.array(inst.bbox, dtype=int) for inst in instance_list])
gt_labels = np.array([inst.label for inst in instance_list])
roidb = {}
roidb['sbj_gt_boxes'] = box_proposals
roidb['obj_gt_boxes'] = box_proposals
roidb['sbj_gt_labels'] = gt_labels
roidb['obj_gt_labels'] = gt_labels
im_results = im_detect_rels(model, im, dataset_name, box_proposals, timers, roidb=roidb, use_gt_labels=True)
print(im_results)`

I found that there are some images with null objects, and probably that is the reason of such errors