当前位置: 首页 > 工具软件 > PySOT > 使用案例 >

Pysot训练自己的数据集

江阳羽
2023-12-01

数据集预处理操作:Pysot训练自己数据集前的预处理_Vesper0412的博客-CSDN博客

Pysot源码地址:https://github.com/STVIR/pysot

1、linux系统激活环境

conda activate pytorch=1.5.1

2、更改数据集参数

文件地址:pysot-master/pysot/core/config.py

将原参数更改为:

__C.DATASET.NAMES = ['MY']

__C.DATASET.MY = CN()
__C.DATASET.MY.ROOT = '/crop511'#绝对路径
__C.DATASET.MY.ANNO = '/train.json'#绝对路径
__C.DATASET.MY.FRAME_RANGE = 100
__C.DATASET.MY.NUM_USE = 100000  # repeat until reach NUM_USE

文件地址:pysot-master/pysot/datasets/dataset.py

class SubDataset(object):
    def __init__(self, name, root, anno, frame_range, num_use, start_idx):
        cur_path = os.path.dirname(os.path.realpath(__file__))
        self.name = name
        # self.root = os.path.join(cur_path, '../../', root)
        #self.anno = os.path.join(cur_path, '../../', anno)
        self.root = root
        self.anno = anno

 文件地址:pysot-master/experiments/siamrpn_r50_l234_dwxcorr_8gpu/config.yaml

DATASET:
    NAMES: 
#    - 'VID'
#    - 'YOUTUBEBB'
#    - 'COCO'
#    - 'DET'
    - 'MY'

3、加载预训练模型

文件地址:pysot-master/pysot/core/config.py

#绝对路径
__C.TRAIN.PRETRAINED = '/pysot-master/experiments/siamrpn_r50_l234_dwxcorr/model.pth'

4、取消预训练backbone

文件地址:pysot-master/experiments/siamrpn_r50_l234_dwxcorr_8gpu/config.yaml

第一行内容改成第二行内容

 PRETRAINED: 'pretrained_models/resnet50.model'
 PRETRAINED: ''

5、run

路径:pysot-master/experiments/siamrpn_r50_l234_dwxcorr_8gpu

用了三块GPU


CUDA_VISIBLE_DEVICES=0,1,2
python -m torch.distributed.launch \
    --nproc_per_node=3 \
    --master_port=2333 \
    ../../tools/train.py --cfg config.yaml

6.resume

文件地址:pysot-master/experiments/siamrpn_r50_l234_dwxcorr_8gpu/config.yaml

TRAIN:
    EPOCH: 20
    START_EPOCH: 0
    BATCH_SIZE: 28
    BASE_LR: 0.005
    CLS_WEIGHT: 1.0
    LOC_WEIGHT: 1.2
    RESUME: ''#添加checkpoint.pth的绝对路径

 类似资料: