论文阅读《Local Similarity Pattern and Cost Self-Reassembling for Deep Stereo Matching Networks》

论文地址:https://ojs.aaai.org/index.php/AAAI/article/download/20056/19815
源码地址:https://github.com/SpadeLiu/Lac-GwcNet


概述

   基于CNN的立体匹配网络存在以下的不足:1) 卷积特征(CF)只学到了外观信息。2)由于卷积操作带有滤波作用,目前基于卷积的视差细化模块往往会产生过于平滑的结果。在这篇工作中,作者提出了两个模块来解决这些问题,首先,为深度立体匹配模型引入了一个成对的特征,名为LSP(Local Similarity Patern),通过探索邻域之间的信息来得到一个更具有判别性的匹配特征。其次,作者设计了一个 dynamic self-reassembling 视差增强策略,并将其应用于代价分布与视差图上。


模型架构

在这里插入图片描述

Local Similarity Pattern

  模型架构如图2所示,CF特征中包含丰富的外观特征而缺少结构特征。其原因在于卷积中学习到的权重不能很好地表示邻域关系,为了弥补这种不足&

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
Non-local Neural Networks (NLNet) 是一个用于图像和视频处理的深度学习模型,它在处理长距离的空间关系时表现出色。下面是一个使用 TensorFlow 2 实现的 NLNet 模型的示例代码: ```python import tensorflow as tf from tensorflow.keras.layers import Conv2D, BatchNormalization, Activation, Add, Input, Lambda, Concatenate from tensorflow.keras.models import Model from tensorflow.keras.regularizers import l2 def non_local_block(x, compression=2, mode='embedded_gaussian', reg=l2(0.)): ''' Non-local block with optional compression and different modes: - 'dot_product': dot product similarity (original paper) - 'embedded_gaussian': embedded Gaussian similarity (default) - 'concatenation': concatenation-based similarity (not recommended) ''' # Get input shape and channels input_shape = tf.shape(x) channels = input_shape[-1] # Define theta, phi, and g theta = Conv2D(channels // compression, 1, use_bias=False, kernel_regularizer=reg)(x) phi = Conv2D(channels // compression, 1, use_bias=False, kernel_regularizer=reg)(x) g = Conv2D(channels // compression, 1, use_bias=False, kernel_regularizer=reg)(x) # Reshape theta and phi to (N, H*W, C') theta = Lambda(lambda x: tf.reshape(x, (input_shape[0], -1, channels // compression)))(theta) phi = Lambda(lambda x: tf.reshape(x, (input_shape[0], -1, channels // compression)))(phi) # Compute similarity between theta and phi if mode == 'dot_product': similarity = Lambda(lambda x: tf.matmul(x[0], x[1], transpose_b=True))([theta, phi]) elif mode == 'embedded_gaussian': theta = Lambda(lambda x: tf.expand_dims(x, 2))(theta) phi = Lambda(lambda x: tf.expand_dims(x, 1))(phi) theta_phi = Add()([theta, phi]) f = Conv2D(1, 1, use_bias=False, kernel_regularizer=reg)(theta_phi) f = Activation('softmax')(f) similarity = Lambda(lambda x: tf.matmul(x[0], x[1]))([f, g]) elif mode == 'concatenation': theta_phi = Concatenate(axis=-1)([theta, phi]) h = Conv2D(channels // compression, 1, use_bias=False, kernel_regularizer=reg)(theta_phi) similarity = Lambda(lambda x: tf.matmul(x[0], x[1], transpose_b=True))([h, g]) # Reshape similarity to (N, H, W, C') similarity = Lambda(lambda x: tf.reshape(x, (input_shape[0], input_shape[1], input_shape[2], channels // compression)))(similarity) # Compute output y = Conv2D(channels, 1, use_bias=False, kernel_regularizer=reg)(similarity) y = Add()([y, x]) y = BatchNormalization()(y) y = Activation('relu')(y) return y def build_nlnet(input_shape, num_classes, num_blocks=5, compression=2, mode='embedded_gaussian', reg=l2(0.)): ''' Build NLNet model with optional number of blocks, compression, and mode. ''' # Define input inputs = Input(shape=input_shape) # Initial convolution x = Conv2D(64, 3, padding='same', use_bias=False, kernel_regularizer=reg)(inputs) x = BatchNormalization()(x) x = Activation('relu')(x) # Non-local blocks for i in range(num_blocks): x = non_local_block(x, compression=compression, mode=mode, reg=reg) # Final convolution and pooling x = Conv2D(128, 1, use_bias=False, kernel_regularizer=reg)(x) x = BatchNormalization()(x) x = Activation('relu')(x) x = Conv2D(num_classes, 1, use_bias=False, kernel_regularizer=reg)(x) x = BatchNormalization()(x) x = Activation('softmax')(x) x = Lambda(lambda x: tf.reduce_mean(x, axis=(1, 2)))(x) # Define model model = Model(inputs=inputs, outputs=x) return model ``` 此代码实现了一个用于图像分类的 NLNet 模型,其中包含多个非局部块。该模型使用可配置的压缩因子和模式,并支持 L2 正则化。要使用此代码,请调用 `build_nlnet()` 函数并传递输入形状、类别数以及其他可选参数。例如: ```python input_shape = (224, 224, 3) num_classes = 1000 model = build_nlnet(input_shape, num_classes, num_blocks=5, compression=2, mode='embedded_gaussian', reg=l2(0.0001)) ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CV科研随想录

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值