栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Faster-ILOD、maskrcnn

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Faster-ILOD、maskrcnn

论文

Faster ILOD: Incremental learning for object detectors based on faster RCNN 2020

论文:https://arxiv.org/abs/2003.03901
代码:https://github.com/CanPeng123/Faster-ILOD

代码 一、Requirements:
  • PyTorch 1.0 from a nightly release. It will not work with 1.0 nor
    1.0.1. Installation instructions can be found in https://pytorch.org/get-started/locally/

  • torchvision from master

  • cocoapi

  • yacs

  • matplotlib

  • GCC >= 4.9

  • OpenCV

  • CUDA >= 9.0

二、安装 Step-by-step installation
# first, make sure that your conda is setup properly with the right environment
# for that, check that `which conda`, `which pip` and `which python` points to the
# right path. From a clean conda env, this is what you need to do

conda create --name maskrcnn_benchmark -y
conda activate maskrcnn_benchmark

# this installs the right pip and dependencies for the fresh python
conda install ipython pip

# maskrcnn_benchmark and coco api dependencies
pip install ninja yacs cython matplotlib tqdm opencv-python

# follow PyTorch installation in https://pytorch.org/get-started/locally/
# we give the instructions for CUDA 9.0
conda install -c pytorch pytorch-nightly torchvision cudatoolkit=9.0

export INSTALL_DIR=$PWD

# install pycocotools
cd $INSTALL_DIR
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install

# install cityscapesScripts
cd $INSTALL_DIR
git clone https://github.com/mcordts/cityscapesScripts.git
cd cityscapesScripts/
python setup.py build_ext install

# install apex
cd $INSTALL_DIR
git clone https://github.com/NVIDIA/apex.git
cd apex
python setup.py install --cuda_ext --cpp_ext

# install PyTorch Detection
cd $INSTALL_DIR
git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
cd maskrcnn-benchmark

# the following will install the lib with
# symbolic links, so that you can modify
# the files if you want and won't need to
# re-build it
python setup.py build develop


unset INSTALL_DIR

# or if you are on macOS
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop
三、Faster-ILOD

将maskrcnn环境装好后,将Faster-ILOD 相关代码覆盖到maskrcnn相关文件夹中 ,运行 python setup.py build develop 重新编译 或者直接下载Faster-ILOD代码。

四、遇到问题 1.git clone因为网络问题下载不下来

文件可以下载到本地,上传到服务器;
安装包也可以下载到本地,上传到服务器,pip install 文件路径 进行安装

2.RuntimeError: Error compiling objects for extension

pytorch版本不合适
本人cuda10.1 pytorch1.7,1
看解决方案后,将pytorch版本降为1.5 成功

CUDA 10.1
Pytorch 1.4.0
torchvision 0.5.0

更多解决方案可参考https://github.com/facebookresearch/maskrcnn-benchmark/issues/1236

3.RuntimeError: Output 0 of UnbindBackward is a view and its base or another view of its base has been modified inplace.
RuntimeError: Output 0 of UnbindBackward is a view and its base or another view of its base has been modified inplace. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.

参考: https://blog.csdn.net/Ginomica_xyx/article/details/120491859

知道问题原因是对self.bbox多次修改 ,第二次修改时,python不清楚是操作原始的self.bbox 还是修改之后的self.bbox。
知道问题所在,尝试解决问题:修改代码 将self.bbox 拷贝给一个参数 再对此参数进行操作(不可以);进行深拷贝 也不可以 。
查看相关问题,归根结底是pytorch1.7.0的bug。
将pytorch版本降为1.6.0 此问题解决

4.unable to execute ‘usr/local/cuda-10.0/bin/nvcc‘: No such file or directory

参考:
linux查看和修改PATH环境变量的方法

https://blog.csdn.net/qq_41251963/article/details/110120386
https://blog.csdn.net/tailonh/article/details/120322932
https://blog.csdn.net/G_inkk/article/details/124584873

5. error: cannot call member function ‘void std::basic_string<_CharT, _Traits, _Alloc>::

python setup.py build develop 重新编译是报错
RuntimeError: Error compiling objects for extension,往上查看错误原因是
/usr/include/c++/7/bits/basic_string.tcc:1067:16: error: cannot call member function ‘void std::basic_string<_CharT, _Traits, _Alloc>::_Rep
解决方法

参考:https://blog.csdn.net/weixin_45328592/article/details/114646355
https://blog.csdn.net/qq_29695701/article/details/118548238

sudo gedit /usr/include/c++/7/bits/basic_string.tcc

将

__p->_M_set_sharable()

改为

(*__p)._M_set_sharable()

即可。
若修改文件遇到问题:
‘readonly’ option is set (add ! to override)
当前用户没有权限,先sudo -i切换到root权限再进行修改 直接使用sudo vim 打开文件进行修改

参考
https://blog.csdn.net/cheng_feng_xiao_zhan/article/details/53391474

RuntimeError: Error compiling objects for extension
还有可能是下面的原因:

  • pytorch版本不匹配
  • cuda多版本切换的问题

解决:报错的路径里面多了一个冒号,说明是环境变量的设置有问题

sudo vim ~/.bashrc
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
改为
export CUDA_HOME=/usr/local/cuda

source ~/.bashrc

参考:
https://blog.csdn.net/loovelj/article/details/110490986
https://www.codeleading.com/article/95735054818/
https://blog.csdn.net/zt1091574181/article/details/113611468

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/926336.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号