def get_hw_center(json_path, h, w, scale): """ 从json格式中读取目标的宽高和中心点位置 json_path: json文件的路径 h: 原始图像的高度 w: 原始图像的宽度 scale; 特征图与原图的比例,centernet为1/4 """ myObject = [] with open(json_path, 'r', encoding='utf-8') as f: ret_dic = json.load(f) imgPath = ret_dic['path'] target_Obj['imgPath'] = imgPath object = (ret_dic['outputs']['object']) numObject = len(object) print(numObject) for i in range(0, numObject): obj = object[i]['bndbox'] xmin = obj['xmin'] ymin = obj['ymin'] xmax = obj['xmax'] ymax = obj['ymax'] obj_width = np.abs(xmax - xmin)*scale # 原图中目标的宽度,原版论文无需归一化 obj_height = np.abs(ymax - ymin)*scale # 原图中目标的高度,原版论文无需归一化 centerPoint = [(xmax+xmin)/2*scale, (ymax+ymin) / 2*scale] # 目标在特征图中的中心点座标 target_Obj['height'] = np.array(obj_height).copy() target_Obj['width'] = np.array(obj_width).copy() target_Obj['centerPoint'] = np.array(centerPoint).copy() myObject.append(target_Obj.copy()) return myObject
这一个可以多说一点,形变卷积可以学习到传统卷积无法学下到的长距离信息。
class L1Loss(nn.Module): """ L1 loss,论文证明,该loss要比smooth L1 loss要好! """ def __init__(self): super(L1Loss, self).__init__() def forward(self, pred, mask, target): numPoint = mask[:, 0, :, :].float().sum() # 目标点个数 loss = F.l1_loss(pred * mask, target * mask, reduction='elementwise_mean') return loss/(numPoint+1e-4)
好吧,先写到这里,下一步我会来更新超大影像的目标检测及相关工程应用上的精度 与效率如何,需要代码请加qq 1044625113。
用一句话来总结我的想法,只做有用的东西,不做灌水的东西!大家共勉!