Tag Archives: Target Tracking

[Solved] Model training Error: _pickle.PicklingError: Can’t pickle

How to Solve Model training Error: _pickle.Picklingerror: can’t pickle

 

1. Problem description

Recently, when learning the target tracking model of siamfc model, it is found that the following problems always occur during model training on window platform:

_pickle.PicklingError: Can’t pickle <class ‘pairwise.GenericDict’>: attribute lookup GenericDict on pairwise failed

See the following figure for details:

2. Solution

The main problem is that the code is written on Linux platform, test.py has no problem in actual operation, but train.py has problem in window platform, the main problem is on Dataloader, so we can modify this part of the code. The main problem lies in the Dataloader, so we can modify this part of the code. Or we can directly train and test the model under Linux with the source code.

The solution to this problem on Window platform is as follows:

Modify the original code from num_workers = 4 to num_workers = 0 and it will work as follows.

after the modification is completed, the operation effect is as follows:

Pysot installation and model testing

installation steps

– download the project file

https://github.com/STVIR/pysot.git

create conda environment

https://github.com/STVIR/pysot/blob/master/INSTALL.md

the second installation, manual configuration environment, the command is as follows, to add tsinghua source https://pypi.tuna.tsinghua.edu.cn/simple

conda create --name pysot python=3.7
conda activate pysot

conda install numpy
conda install pytorch=0.4.1 torchvision cuda90 -c pytorch
pip install opencv-python

pip install pyyaml yacs tqdm colorama matplotlib cython tensorboardX

# change dir to project

python setup.py build_ext --inplace

download model file

the baidu cloud https://github.com/STVIR/pysot/blob/master/MODEL_ZOO.md file download, only copy pysot/experiments in the file mode, PTH, not to replace the corresponding congfig. Yaml

configure the environment variable

export PYTHONPATH=/path/to/pysot:$PYTHONPATH

to export PYTHONPATH =/home/Cody/PycharmProjects/pysot: $PYTHONPATH

or use pycharm to configure

https://blog.csdn.net/sements/article/details/105495812/

demo run
Reference

https://blog.csdn.net/sements/article/details/105495812/

here use pycharm to run, select the corresponding Python compiler, and run -> Edit Configurations, set and select the running demo.py file, and add the running parameter

in paramters

–config .. /experiments/siamrpn_r50_l234_dwxcorr/config.yaml
–snapshot .. /experiments/siamrpn_r50_l234_dwxcorr/model.pth
–video ../demo/bag. Avi

effect display

Run demo.py, pop up the display box, select the area with the left mouse button and press enter to