论文地址:https://arxiv.org/pdf/2103.05950.pdf
代码地址:https://github.com/megvii-research/FSCE
论文阅读:https://blog.csdn.net/qiankendeNMY/article/details/128390284
我的配置:
Python :3.8(ubuntu18.04)
Pytorch :1.6.0
Cuda :10.1
GPU:RTX 2080 Ti(11GB) * 2
requirements.txt文件下载:https://github.com/ucbdrive/few-shot-object-detection
pip install -r requirements.txt
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
pip install 'git+https://github.com/facebookresearch/fvcore'
解决参考:
https://blog.csdn.net/weixin_45355608/article/details/116528406
python setup.py build develop
解决:
(1)修改 ./fedet/model_zoo下configs文件的内容,改成configs文件夹所在的路径
(2)执行以下命令,创建软链接
ln -sf 【configs文件夹所在的路径】 ./fsdet/model_zoo
例如:
ln -sf /root/autodl-tmp/configs ./fsdet/model_zoo
解决:
降低pytorch的版本,原来我的pytorch版本是1.6,降低到了1.4就可以正常运行了:
https://github.com/megvii-research/FSCE/issues/19
build成功
cd datasets
wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
tar xf VOCtrainval_11-May-2012.tar
tar xf VOCtrainval_06-Nov-2007.tar
tar xf VOCtest_06-Nov-2007.tar
python tools/train_net.py --num-gpus 2 --config-file configs/PASCAL_VOC/base-training/R101_FPN_base_training_split1.yml
解决:
手动下载pkl文件:
https://dl.fbaipublicfiles.com/detectron2/ImageNetPretrained/MSRA/R-101.pkl
然后,修改yml.py中pkl文件的路径,改为pkl文件在本机上的存储路径,例如: /path/to/ImageNetPretrained/MSRA/R-101.pkl.
Traceback (most recent call last):
File "/root/miniconda3/lib/python3.8/site-packages/torch/multiprocessing/spawn.py", line 20, in _wrap
fn(i, *args)
File "/root/autodl-tmp/fsdet/engine/launch.py", line 84, in _distributed_worker
main_func(*args)
File "/root/autodl-tmp/tools/train_net.py", line 116, in main
return trainer.train()
File "/root/autodl-tmp/fsdet/engine/defaults.py", line 397, in train
super().train(self.start_iter, self.max_iter)
File "/root/autodl-tmp/fsdet/engine/train_loop.py", line 132, in train
self.run_step()
File "/root/autodl-tmp/fsdet/engine/train_loop.py", line 212, in run_step
loss_dict = self.model(data)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__
result = self.forward(*input, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 458, in forward
output = self.module(*inputs[0], **kwargs[0])
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__
result = self.forward(*input, **kwargs)
File "/root/autodl-tmp/fsdet/modeling/meta_arch/rcnn.py", line 166, in forward
_, detector_losses = self.roi_heads(images, features, proposals, gt_instances)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__
result = self.forward(*input, **kwargs)
File "/root/autodl-tmp/fsdet/modeling/roi_heads/roi_heads.py", line 443, in forward
losses = self._forward_box(features_list, proposals) # get losses from fast_rcnn.py::FastRCNNOutputs
File "/root/autodl-tmp/fsdet/modeling/roi_heads/roi_heads.py", line 464, in _forward_box
box_features = self.box_pooler(features, [x.proposal_boxes for x in proposals]) # [None, 256, POOLER_RESOLU, POOLER_RESOLU]
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__
result = self.forward(*input, **kwargs)
File "/root/autodl-tmp/fsdet/modeling/poolers.py", line 233, in forward
output[inds] = pooler(x_level, pooler_fmt_boxes_level)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__
result = self.forward(*input, **kwargs)
File "/root/autodl-tmp/fsdet/layers/roi_align.py", line 93, in forward
return roi_align(
File "/root/autodl-tmp/fsdet/layers/roi_align.py", line 19, in forward
output = _C.roi_align_forward(
RuntimeError: Not compiled with GPU support
这个问题死活解决不了,删了所有环境重新配置之后就没有再出现这个问题了。但是花了不少时间,希望有大佬看到的话能够提出解决方案。
python tools/ckpt_surgery.py --src1 checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth --method randinit --save-dir checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1
方法一:
python datasets/prepare_voc_few_shot.py --seeds 1 30
方法二:直接选择下载作者提供的网页数据集
wget -r -R index.html http://dl.yf.io/fs-det/datasets
将下载好的VOC数据集存放在datasets文件夹中的vocsplit文件夹下:
修改模型的权重路径为model_resnet_surgery.pth文件的保存路径:
python tools/train_net.py --num-gpus 2 \
--config-file configs/PASCAL_VOC/split1/10shot_CL_IoU.yml
python tools/test_net.py --num-gpus 2 \
--config-file configs/PASCAL_VOC/split1/10shot_CL_IoU.yml \
--eval-only
解决:
参考:https://github.com/megvii-research/FSCE/issues/9
如有错误,欢迎指正!