前言
由于笔者项目经验欠缺,在本文章代码复现时遇到诸多问题,多数问题在网上查阅并无法第一时间找到原因。并且由于文章和其研究方向较新,网络上复现过程记录几乎没有,故记录复现过程,或许能够帮助到有需求的人,主要供自己翻看。(笔者并不专业,在该领域也并未入门,有问题请指教)
论文
代码
环境搭建
笔者在服务器上搭建环境并实现代码,由于一些错误和原因(尚未解决),项目中的requirements.txt无法有效地使用conda搭建环境,因此直接使用pip安装需要的包。
运行环境:
python == 3.9(3.10以上版本会有问题)
pytorch == 2.0.1
CUDA ==11.7
Cython == 3.0.11
detectron2 == 0.6
numpy == 1.23.5
scikit-learn == 0.21.3 (sklearn多次遇到版本问题)
scipy == 1.10.0
Installation
git clone https://github.com/cvlab-stonybrook/HAT.git
cd HAT
Install Detectron2:
git clone https://github.com/facebookresearch/detectron2.git
python -m pip install -e detectron2
Install MSDeformableAttn:
cd ./hat/pixel_decoder/ops
sh make.sh
笔者按给出的命令初始化并无报错,但后续出现了一些问题(不明原因报错),可以先尝试进行下面的步骤,若后续有问题再考虑下面的备选步骤,直接导入该包的源项目并初始化。
git clone https://github.com/fundamentalvision/deformable-detr
导入项目后,进入项目,按照README.md文件进行初始化
pip install -r requirements.txt
cd ./models/ops
sh ./make.sh
Download pretrained model weights (ResNet-50 and Deformable Transformer) with the following python code
if not os.path.exists("./pretrained_models/"):
os.mkdir('./pretrained_models')
print('downloading pretrained model weights...')
url = f"http://vision.cs.stonybrook.edu/~cvlab_download/HAT/pretrained_models/M2F_R50_MSDeformAttnPixelDecoder.pkl"
wget.download(url, 'pretrained_models/')
url = f"http://vision.cs.stonybrook.edu/~cvlab_download/HAT/pretrained_models/M2F_R50.pkl"
wget.download(url, 'pretrained_models/')
建立一个python文件,import必要的包,将上述