pytorch版efficientdet训练自己的数据集(zylo)

1、配置环境

# install requirements
pip install pycocotools numpy opencv-python tqdm tensorboard tensorboardX pyyaml webcolors
pip install torch==1.4.0
pip install torchvision==0.5.0

2、git源码

git clone https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch

3、准备数据集

本例用的数据集是 BIWI Walking Pedestrians dataset,首先将视频按帧转换成图像序列,然后用labelme标注,保存为json数据格式文件。

之后数据集要转换成coco格式,参考json转coco。

# your dataset structure should be like this
datasets/
    -your_project_name/
        -train_set_name/
            -*.jpg
        -val_set_name/
            -*.jpg
        -annotations
            -instances_{
   train_set_name}.json
            -instances_{
   val_set_name}.json

4、修改配置文件

修改coco.xml:

project_name: coco_people  # also the folder name of the dataset that under data_path folder
train_set: train #注意和COCO转化时,选择的年份一致
val_set: val
num_gpus: 1 # 0 means using cpu, 1-N means using gpus

# mean and std in RGB order, actually this part should remain unchanged as long as your dataset is similar to coco.
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]

# this is coco anchors, change it if necessary
anchors_scales: '[2 ** 0, 2 ** (1.0 / 3.0), 2 ** (2.0 / 3.0)]'#放大的倍数
anchors_ratios: '[(1.0, 1.0), (1.4, 0.7), (0.7, 1.4)]'#长边和短边的比例,一般都是成对出现的(乘积为1)

# objects from all labels from your dataset with the order from your annotations.
# its index must match your dataset's category_id.
# category_id is one_indexed,for example, index of 'people' here is 0, while category_id of is 1
obj_list: ['people'..]

修改train.py:

#主要需要修改的参数有compound_coef、batch_size、num_epochs、save_interval、lr、load_weights
def get_args():
    parser = argparse.ArgumentParser('Yet Another EfficientDet Pytorch: SOTA object detection network - Zylo117')
    
    parser.add_arg

你可能感兴趣的:(AI,python,pytorch,python)