Windows系统下复现Trackformer

1.安装cuda和cudnn

注意不要用pytorch自带的免安装cuda和cudnn,因为在trackformer代码中需要调用CUDA_HOME,如果免安装,会导致CUDA_HOME为NONE,参考这篇博客,安装cuda和cudnn。

2.配置python环境

建议使用python3.7,我使用3.8的时候遇到一些版本问题,在github上trackformer的Issues栏中同样有人询问,用3.7和3.9均可复现,作者建议3.7版本。

conda create -n Trackformer python=3.7 -y

3.安装Pytorch

我的cuda版本是11.7。参考这篇博客安装各自对应版本。

4.下载项目

项目地址

5.配置环境和工具

(1)安装requirements.txt

pip install -r requirements.txt

报错显示failed building wheel for lapsolver

运行以下代码,安装cmake后再安装lapsolver

pip install cmake
pip install lapsolver==1.1.0

(2)安装pycocotools

pip install pycocotools

(3)安装gcc编译器

参考这篇博客

(4)安装ffmpeg

参考这篇博客

(5)安装MultiScaleDeformableAttention

python src/trackformer/models/ops/setup.py build --build-base=src/trackformer/models/ops/ install

(6)下载预训练文件

点击这里,下载trackformer_models_v1.zip文件,解压,将mot17_crowdhuman_deformable_multi_frame文件移动到Trackformer工程models文件夹下

6.将视频转换为图片

ffmpeg -i data/snakeboard/snakeboard.mp4 -vf fps=30 data/snakeboard/%06d.png

7.开始检测

python src/track.py with dataset_name=DEMO data_root_dir=data/snakeboard output_dir=data/snakeboard write_images=pretty

(1)报错及解决

报错a:ImportError: Bad git executable.

解决:点击进入git\cmd.py,在22行左右插入以下代码

os.environ['GIT_PYTHON_REFRESH'] = 'quiet'

报错b:NotImplementedError: cannot instantiate 'PosixPath' on your system

 

解决:作者是在Linux上进行训练的,不同操作系统处理路径的方式有差异,修改代码。

点击进入pathlib.py修改1030行左右的代码

    def __new__(cls, *args, **kwargs):
        # 源码
        # if cls is Path:
        #     cls = WindowsPath if os.name == 'nt' else PosixPath
        # self = cls._from_parts(args, init=False)
        # if not self._flavour.is_supported:
        #     raise NotImplementedError("cannot instantiate %r on your system"
        #                               % (cls.__name__,))
        # self._init()
        # return self
 
        # 修改
        if cls is Path:
            # cls = WindowsPath if os.name == 'nt' else PosixPath
            cls = WindowsPath
        self = cls._from_parts(args, init=False)
        # Windows doesn't support PosixPath
        if type(self) == PosixPath:
            cls = WindowsPath
            self = cls._from_parts(args, init=False)
        if not self._flavour.is_supported:
            raise NotImplementedError("cannot instantiate %r on your system"
                                      % (cls.__name__,))
        self._init()
        return self

(2)运行成功结果

参考文章:

http://t.csdnimg.cn/gFDN2

http://t.csdnimg.cn/fZDGJ

  • 17
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老实敦厚的成成

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值