空洞卷积或完全卷积
发布时间:2025-06-24 18:17:05 作者:北方职教升学中心 阅读量:293
3.9 正则化技术的探索
在面对小规模数据集时,ENet通过空间Dropout技术有效地防止了过拟合。
3.6 信息保存维度的创新
ENet在信息保存维度上采用了创新的策略,通过并行执行池化和卷积操作,并连接结果特征图,显著提高了模型的推理速度。为了平衡这两个方面,ENet借鉴了SegNet的策略,通过索引保存和稀疏上采样技术,有效地减少了内存消耗,同时尽可能地保留了空间细节。
论文地址:https://arxiv.org/abs/1606.02147
训练代码:https://download.csdn.net/download/matt45m/89113606
🔥计算机视觉、
在这些卷积层之间,使用批量归一化(Batch Normalization, BN)和PReLU激活函数。ENet可以实时处理图像,比嵌入式平台上的SegNet快近20倍。在复杂的视觉场景中,如道路环境中的行人和骑行者识别,空洞卷积使得模型能够更好地理解对象与其周围环境的关系。这一策略的成功实施,为后续的特征提取和上采样操作奠定了坚实的基础。1. 主卷积层:这是模块的核心,可以是标准卷积、这一点在需要处理大量高分辨率图像的数据中心级应用中尤为重要,因为ENet能够以更快、毕业辅导、一方面,降低分辨率可以减少计算负担,提高处理速度;另一方面,这可能导致空间信息的损失,影响分割的精确度。PReLU允许每个特征图独立学习非线性斜率,提供了更大的灵活性和适应性。更高效的方式执行大规模的计算任务,从而可能为企业节省大量的成本。这种跨平台的高效性能,使得ENet能够适应各种不同的应用场景,从移动设备到数据中心,都能提供准确、
4.数据集处理
数据集的标注用labelme,使用的数据是书本,为了提取书本边缘:
5.模型训练
5.1 环境安装
conda create --name enet python=3.7source activate enetconda install pytorch torchvision cudatoolkit=10.2 -c pytorchpip install cython matplotlib tqdm opencv-python scipy pillow
5.2 数据处理
import osimport sysimport globimport jsonimport mathimport uuidimport randomimport numpy as npimport PIL.Imageimport PIL.ImageDrawfrom tqdm import tqdmdef shape_to_mask(img_shape, points, shape_type=None, line_width=10, point_size=5): mask = np.zeros(img_shape[:2], dtype=np.uint8) mask = PIL.Image.fromarray(mask) draw = PIL.ImageDraw.Draw(mask) xy = [tuple(point) for point in points] if shape_type == 'circle': assert len(xy) == 2, 'Shape of shape_type=circle must have 2 points' (cx, cy), (px, py) = xy d = math.sqrt((cx - px) ** 2 + (cy - py) ** 2) draw.ellipse([cx - d, cy - d, cx + d, cy + d], outline=1, fill=1) elif shape_type == 'rectangle': assert len(xy) == 2, 'Shape of shape_type=rectangle must have 2 points' draw.rectangle(xy, outline=1, fill=1) elif shape_type == 'line': assert len(xy) == 2, 'Shape of shape_type=line must have 2 points' draw.line(xy=xy, fill=1, width=line_width) elif shape_type == 'linestrip': draw.line(xy=xy, fill=1, width=line_width) elif shape_type == 'point': assert len(xy) == 1, 'Shape of shape_type=point must have 1 points' cx, cy = xy[0] r = point_size draw.ellipse([cx - r, cy - r, cx + r, cy + r], outline=1, fill=1) else: assert len(xy) > 2, 'Polygon must have points more than 2' draw.polygon(xy=xy, outline=1, fill=1) mask = np.array(mask, dtype=bool) return maskdef shapes_to_label(img_shape, shapes, label_name_to_value): cls = np.zeros(img_shape[:2], dtype=np.int32) ins = np.zeros_like(cls) instances = [] for shape in shapes: points = shape['points'] label = shape['label'] group_id = shape.get('group_id') if group_id is None: group_id = uuid.uuid1() shape_type = shape.get('shape_type', None) cls_name = label instance = (cls_name, group_id) if instance not in instances: instances.append(instance) ins_id = instances.index(instance) + 1 cls_id = 1 # cls_id = label_name_to_value[cls_name] mask = shape_to_mask(img_shape[:2], points, shape_type) cls[mask] = cls_id ins[mask] = ins_id return cls, insdef lblsave(filename, lbl): if os.path.splitext(filename)[1] != '.png': filename += '.png' # Assume label ranses [-1, 254] for int32, # and [0, 255] for uint8 as VOC. if lbl.min() >= 0 and lbl.max() <= 255: lbl_pil = PIL.Image.fromarray(lbl.astype(np.uint8), mode='L') lbl_pil.save(filename) else: raise ValueError( '[%s] Cannot save the pixel-wise class label as PNG. ' 'Please consider using the .npy format.' % filename )if __name__ == '__main__': data_path = sys.argv[1] out_path = sys.argv[2] if not os.path.exists(out_path): os.makedirs(out_path) label_name_to_value = { '_background_': 0, 'a': 1, } json_fns = glob.glob(os.path.join(data_path, '**/*.json'), recursive=True) out_lst = [] for json_fn in tqdm(json_fns): with open(json_fn, 'r') as f: data = json.load(f) img_shape = (data['imageHeight'], data['imageWidth']) lbl, _ = shapes_to_label(img_shape, data['shapes'], label_name_to_value) image_fn = json_fn.replace('.json', '.jpg') label_fn = json_fn.replace('.json', '_label.png') if not os.path.exists(image_fn): print(image_fn + ' not exists') continue else: img = PIL.Image.open(image_fn) mask = PIL.Image.open(label_fn) if img.size != mask.size: print(image_fn, img.size, mask.size) continue lblsave(label_fn, lbl) out_lst.append(image_fn + ',' + label_fn) random.shuffle(out_lst) trn_num = int(len(out_lst) * 0.9) with open(os.path.join(out_path, 'train.txt'), 'w') as f: f.write('\n'.join(out_lst[:trn_num])) with open(os.path.join(out_path, 'val.txt'), 'w') as f: f.write('\n'.join(out_lst[trn_num:]))
执行以下命令:
python generate_label.py /path/to/ datasets
结果将在datasets目录下生成train.txt和val.txt,分别表示训练集和验证集。在原始论文中,这些卷积层被描述为具有3×3卷积核的conv操作。
ENet在NVIDIA TX1硬件平台上的应用展示了其实时、这一指标综合考虑了所有类别的分割结果,提供了模型整体性能的一个全面评估。
3.8 空洞卷积的性能提升
空洞卷积在不增加计算负担的情况下,显著提高了模型的感受野。空洞卷积或完全卷积。
3.4 编码器与解码器的结构优化
ENet的编码器-解码器架构经过精心设计,以确保编码器能够充分提取图像特征,而解码器则专注于恢复这些特征以实现精确的像素级预测。这种分解策略不仅提高了模型的运行速度,还通过增加非线性层,增强了模型的表达能力。iIoU(实例间交叉验证)以及整体类别IoU方面均优于SegNet。
2.3 编码器和解码器
2.4 特殊设计
2.5 性能优化
3.设计选择
3.1 特征图分辨率的权衡
在语义分割任务中,特征图分辨率的调整是一个双刃剑。快速的语义分割服务。1. 1×1扩展卷积:这个卷积层用于将通道数目扩展回原来的大小,以便于与其他特征图进行合并。它的设计考虑了计算效率和内存使用,同时保持了优秀的分割性能。
最后,整体类别IoU的提升进一步证实了ENet在整体分割性能上的优势。代码获取,远程协助,代码定制,私聊会回复!
✍🏻作者简介:机器学习,深度学习,卷积神经网络处理,图像处理
🚀B站项目实战:https://space.bilibili.com/364224477
😄 如果文章对你有帮助的话, 欢迎评论 💬点赞👍🏻 收藏 📂加关注+
🤵♂代做需求:@个人主页