目标跟踪MixFormer代码配置过程

论文地址:https://arxiv.org/abs/2203.11082

代码地址:https://github.com/MCG-NJU/MixFormer

将代码上传到服务器上(Linux系统),本地使用pycharm进行调试,在本地进行部署。

1.路径设置

1.1打开服务器终端,进入代码目录下,激活虚拟环境(切记!),输入

python tracking/create_default_local_file.py --workspace_dir . --data_dir ./data --save_dir .

报错如下

WARNING: You are using tensorboardX instead sis you have a too old pytorch version.
Traceback (most recent call last):
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/tracking/../lib/train/admin/tensorboard.py", line 4, in 
    from torch.utils.tensorboard import SummaryWriter
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/torch/utils/tensorboard/__init__.py", line 8, in 
    from .writer import FileWriter, SummaryWriter  # noqa F401
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/torch/utils/tensorboard/writer.py", line 10, in 
    from tensorboard.compat.proto.event_pb2 import SessionLog
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/tensorboard/compat/proto/event_pb2.py", line 8, in 
    from google.protobuf import descriptor as _descriptor
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 47, in 
    from google.protobuf.pyext import _message
ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/pyext/_message.cpython-37m-x86_64-linux-gnu.so)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tracking/create_default_local_file.py", line 4, in 
    from lib.train.admin import create_default_local_file_ITP_train
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/tracking/../lib/train/__init__.py", line 1, in 
    from .admin.multigpu import MultiGPU
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/tracking/../lib/train/admin/__init__.py", line 3, in 
    from .tensorboard import TensorboardWriter
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/tracking/../lib/train/admin/tensorboard.py", line 7, in 
    from tensorboardX import SummaryWriter
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/tensorboardX/__init__.py", line 5, in 
    from .torchvis import TorchVis
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/tensorboardX/torchvis.py", line 10, in 
    from .writer import SummaryWriter
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/tensorboardX/writer.py", line 16, in 
    from .comet_utils import CometLogger
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/tensorboardX/comet_utils.py", line 5, in 
    from google.protobuf.json_format import MessageToJson
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/json_format.py", line 54, in 
    from google.protobuf.internal import type_checkers
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/internal/type_checkers.py", line 51, in 
    from google.protobuf.internal import decoder
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/internal/decoder.py", line 87, in 
    from google.protobuf.internal import encoder
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/internal/encoder.py", line 71, in 
    from google.protobuf.internal import wire_format
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/internal/wire_format.py", line 36, in 
    from google.protobuf import descriptor
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 47, in 
    from google.protobuf.pyext import _message
ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/site-packages/google/protobuf/pyext/_message.cpython-37m-x86_64-linux-gnu.so)

不懂问什么出现这个问题, 

解决:在代码配置的地方添加参数,就能实现对lib/train/admin/local.py 和lib/test/evaluation/local.py的生成,其作用是设置训练数据和测试数据的路径,之后如果要修改数据路径也是在对应local.py文件中修改。目标跟踪MixFormer代码配置过程_第1张图片

记得设置你的项目路径

目标跟踪MixFormer代码配置过程_第2张图片

 模型放在 tracking/models/ 路径下

 2.测试部分

对数据集、训练模型(在GitHub中有)路径进行添加。

对不同数据集的测试命令,可以在  tracking/test_mixformer.sh  文件中找到,比如对于LaSOT数据集,使用如下命令

python tracking/test.py mixformer_online baseline --dataset lasot --threads 2 
--params__model mixformer_online_22k.pth.tar 

报错

{'model': 'mixformer_online_1k.pth.tar', 'max_score_decay': 1.0, 'vis_attn': 0}
Traceback (most recent call last):
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/tracking/test.py", line 72, in 
    main()
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/tracking/test.py", line 68, in main
    args.threads, num_gpus=args.num_gpus, tracker_params=tracker_params)
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/tracking/test.py", line 32, in run_tracker
    trackers = [Tracker(tracker_name, tracker_param, dataset_name, run_id, tracker_params=tracker_params)]
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/lib/test/evaluation/tracker.py", line 57, in __init__
    tracker_module = importlib.import_module('lib.test.tracker.{}'.format(self.name))
  File "/home/vot/votssd/anaconda3/envs/tracking/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in _call_with_frames_removed
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/lib/test/tracker/mixformer_online.py", line 7, in 
    from lib.models.mixformer import build_mixformer_online_score
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/lib/models/mixformer/__init__.py", line 1, in 
    from .mixformer import build_mixformer
  File "/home/vot/votssd/code/Wangjiaqi/MixFormer-main/lib/models/mixformer/mixformer.py", line 12, in 
    from einops import rearrange
ModuleNotFoundError: No module named 'einops'

在所部署的环境中,下载“einops”包

pip install einops

再次运行测试代码

3.训练部分

同样的, 在tracking/train_mixformer.sh也可以找到相应代码进行训练。  

注意:

  • --config和--script需要设置false,不然会一直寻求路径。(参考MixFormer目标跟踪CVPR2022(代码调试)_爱吃糖葫芦的大熊的博客-CSDN博客_mixformer)

你可能感兴趣的:(目标跟踪,人工智能,深度学习)