violetteshev/bottom-up-features

module has no attribute

Opened this issue · 5 comments

Hello, I encountered the following problem when extracting the image features of the custom dataset, can you help me complete the code?

Traceback (most recent call last):
File "extract_features.py", line 82, in
pooled_feat = fasterRCNN(im_data, im_info, gt_boxes, num_boxes)
File "/root/miniconda3/envs/feature/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/bottom-up-features-master/lib/model/faster_rcnn/faster_rcnn.py", line 73, in forward
pooled_feat = self.RCNN_roi_pool(base_feat, rois.view(-1, 5))
File "/root/miniconda3/envs/feature/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/bottom-up-features-master/lib/model/roi_pooling/modules/roi_pool.py", line 14, in forward
return RoIPoolFunction(self.pooled_height, self.pooled_width, self.spatial_scale)(features, rois)
File "/home/bottom-up-features-master/lib/model/roi_pooling/functions/roi_pool.py", line 25, in forward
roi_pooling.roi_pooling_forward_cuda(ctx.pooled_height, ctx.pooled_width, ctx.spatial_scale,
AttributeError: module 'model.roi_pooling._ext.roi_pooling' has no attribute 'roi_pooling_forward_cuda'

I have solved this problem, but I have a new problem, I want to know what the extracted image feature dimension is 2048 (10-100)?

Because when I use the extracted image features to train the model, the following problem arises

RuntimeError: stack expects each tensor to be equal size, but got [100, 10] at entry 0 and [100, 18] at entry 1

Hi. It outputs 10-100 features (1 for each detected object), so the value will differ for each image.

So how do I use these features in the dataloader function? Because the following error was reported in the program

Traceback (most recent call last):
File "E:/vizwiz-vqa/mcan-vqa-master/run.py", line 155, in
execution.run(__C.RUN_MODE)
File "E:\vizwiz-vqa\mcan-vqa-master\core\exec.py", line 513, in run
self.train(self.dataset, self.dataset_eval)
File "E:\vizwiz-vqa\mcan-vqa-master\core\exec.py", line 149, in train
for step, (
File "C:\Users\KAI.conda\envs\fw\lib\site-packages\torch\utils\data\dataloader.py", line 521, in next
data = self._next_data()
File "C:\Users\KAI.conda\envs\fw\lib\site-packages\torch\utils\data\dataloader.py", line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "C:\Users\KAI.conda\envs\fw\lib\site-packages\torch\utils\data_utils\fetch.py", line 52, in fetch
return self.collate_fn(data)
File "C:\Users\KAI.conda\envs\fw\lib\site-packages\torch\utils\data_utils\collate.py", line 84, in default_collate
return [default_collate(samples) for samples in transposed]
File "C:\Users\KAI.conda\envs\fw\lib\site-packages\torch\utils\data_utils\collate.py", line 84, in
return [default_collate(samples) for samples in transposed]
File "C:\Users\KAI.conda\envs\fw\lib\site-packages\torch\utils\data_utils\collate.py", line 56, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: stack expects each tensor to be equal size, but got [100, 14] at entry 0 and [100, 11] at entry 1

进程已结束,退出代码1

Can you provide some reference code to load these features?

You can pad all the features to the max size (100 in this case) with 0. That's what they do in the original MCAN model: code (in proc_img_feat function)