ExtremeNet训练自己的数据

ExtremeNet_250000.pkl下载链接:https://pan.baidu.com/s/1z4TmmC946D5k2vFIJ-ao5Q ,提取码:mnx8 

1. 数据准备 -- 根据自己的数据制作 coco annotations 类似的json文件

参考:https://blog.csdn.net/qq_26815239/article/details/89312881

 

2. 训练自己的数据,代码中需改动的地方

2.1 修改 tools/gen_coco_extreme_points.py

  • 更改相关路径为自己的路径:
SPLITS = ['train']
ANN_PATH = '../data/coco/annotations/instances_{}2017.json'
OUT_PATH = '../data/coco/annotations/instances_extreme_{}2017.json'
IMG_DIR = '/ssd/zhangting/crowd/data/'

ExtremeNet中貌似屏蔽了验证集的代码,所以我这里只生成train的json文件。

更改函数 _get_extreme_points,因为我的极点设置为,top和bottom分别取边的中点,left和right取4/5位置处,代码如下:

def _get_extreme_points(pts):
    """
    t: top, b: bottom, l: left, r: right, ep: extreme point
    :param pts: [ [tl_x, tl_y],
                  [tr_x, tr_y],
                  [br_x, br_y],
                  [bl_x, bl_y] ]
    :return:    [ [ept_x, ept_y],
                  [epl_x, epl_y],
                  [epb_x, epb_y],
                  [epr_x, epr_y] ]
    """
    ept_x = (pts[1, 0] - pts[0, 0])/2 + pts[0, 0]
    ept_y = pts[0, 1]
    epl_x = pts[0, 0]
    # left extreme point 4/5
    epl_y = (pts[3, 1] - pts[0, 1])*0.8 + pts[0, 1]
    epb_x = ept_x
    epb_y = pts[3, 1]
    epr_x = pts[1, 0]
    # left extreme point 4/5
    epr_y = epl_y

    tt = [ept_x, ept_y]
    ll = [epl_x, epl_y]
    bb = [epb_x, epb_y]
    rr = [epr_x, epr_y]

    return np.array([tt, ll, bb, rr])

 2.2 修改 db/coco_extreme.py

修改 _image_dir 为自己图片的路径

self._image_dir  = "/ssd/zhangting/crowd/data"

 修改类别id,我这里只有一类。

self._cat_ids = [1]

 2.3 修改ExtremeNet.json

修改类别数,我这里只有一类。注意,此处训练的时候不要改,测试时才改为自己需要的类别数量,否则报错。

"categories": 1

根据自己的需求设置 batch_size, max_iter, stepsize, snapshot, chunk_sizes。注chunk_size中的所有数加起来等于batch_size

"batch_size": 38,

"max_iter": 180000,
"stepsize": 144000,
"snapshot": 50000,

"chunk_sizes": [3, 5, 5, 5, 5, 5, 5],

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值