https://github.com/zonghaofan/pig-seg/tree/master/disk_segmentation

网络架构:

# coding:utf-8
import tensorflow as tf
import cv2
import numpy as np
import matplotlib.pyplot as pltimg = cv2.imread('./data/test.png')# cv2.imshow('1.jpg',img)
# cv2.waitKey(0)
img = cv2.resize(img, (1024, 1024))
img = np.array(img).astype(np.float32)
img = img[np.newaxis, ...]
print(img.shape)x_input = tf.placeholder(shape=[None, 1024, 1024, 3], dtype=tf.float32)# x=tf.random_normal(shape=[1,1024,1024,3],dtype=tf.float32)
n_filters = [8, 8]# name=1
def conv2d(x, n_filters, training, name, pool=True, activation=tf.nn.relu):with tf.variable_scope('layer{}'.format(name)):for index, filter in enumerate(n_filters):conv = tf.layers.conv2d(x, filter, (3, 3), strides=1, padding='same', activation=None,name='conv_{}'.format(index + 1))conv = tf.layers.batch_normalization(conv, training=training, name='bn_{}'.format(index + 1))conv = activation(conv, name='relu{}_{}'.format(name, index + 1))if pool is False:return convpool = tf.layers.max_pooling2d(conv, pool_size=(2, 2), strides=2, name='pool_{}'.format(name))return conv, pooldef upsampling_2d(tensor, name, size=(2, 2)):h_, w_, c_ = tensor.get_shape().as_list()[1:]h_multi, w_multi = sizeh = h_multi * h_w = w_multi * w_target = tf.image.resize_nearest_neighbor(tensor, size=(h, w), name='upsample_{}'.format(name))return targetdef upsampling_concat(input_A, input_B, name):upsampling = upsampling_2d(input_A, name=name, size=(2, 2))up_concat = tf.concat([upsampling, input_B], axis=-1, name='up_concat_{}'.format(name))return up_concatdef unet(input):#归一化 -1~1input=(input-127.5)/127.5conv1, pool1 = conv2d(input, [8, 8], training=True, name=1)print(conv1.shape)print(pool1.shape)conv2, pool2 = conv2d(pool1, [16, 16], training=True, name=2)print(conv2.shape)print(pool2.shape)conv3, pool3 = conv2d(pool2, [32, 32], training=True, name=3)print(conv3.shape)print(pool3.shape)conv4, pool4 = conv2d(pool3, [64, 64], training=True, name=4)print(conv4.shape)print(pool4.shape)conv5 = conv2d(pool4, [128, 128], training=True, pool=False, name=5)print(conv5.shape)up6 = upsampling_concat(conv5, conv4, name=6)print('up6', up6.shape)conv6 = conv2d(up6, [64, 64], training=True, pool=False, name=6)print(conv6.shape)up7 = upsampling_concat(conv6, conv3, name=7)print('up7', up7.shape)conv7 = conv2d(up7, [32, 32], training=True, pool=False, name=7)print(conv7.shape)up8 = upsampling_concat(conv7, conv2, name=8)print('up8', up8.shape)conv8 = conv2d(up8, [16, 16], training=True, pool=False, name=8)print(conv8.shape)up9 = upsampling_concat(conv8, conv1, name=9)print('up9', up9.shape)conv9 = conv2d(up9, [8, 8], training=True, pool=False, name=9)print(conv9.shape)final = tf.layers.conv2d(conv9, 1, (1, 1), name='final', activation=tf.nn.sigmoid, padding='same')print('final', final.shape)return finalif __name__ == '__main__':final=unet(x_input)with tf.Session() as sess:sess.run(tf.global_variables_initializer())y_final = sess.run(final, feed_dict={x_input: img})result = y_final[0, ...]print(result.shape)print(result[...,:10])# result=cv2.imread('./2.jpg')# result=cv2.resize(result,(640,640))# print(result)cv2.imshow('1.jpg', result)cv2.waitKey(0)

打印结果:这里打印值有小数,故直接imshow就是输出图,而如果imwrite,查看图片的值全是0,1,轮廓也能看清,只不过不是很清晰。

输入:

输出:截图没有完全

unet实现区域分割相关推荐

  1. Unet网络实现叶子病虫害图像分割

    作者|李秋键 出品|AI科技大本营(ID:rgznai100) 智能化农业作为人工智能应用的重要领域,对较高的图像处理能力要求较高,其中图像分割作为图像处理方法在其中起着重要作用.图像分割是图像分析的 ...

  2. 基于U-Net+残差网络的语义分割缺陷检测

    一.介绍 基于深度学习的缺陷检测主要集中在场景识别.object detection等方法,近年来,推出了一系列优秀的语义分割模型,比如SegNet.FCN.U-Net等.语义分割模型被广泛的应用到场 ...

  3. Python基于改进Unet的新冠肺炎等级分割系统(源码&教程)

    1.研究背景 新冠肺炎给人类带来极大威胁,自动精确分割新冠肺炎CT图像感染区域可以辅助医生进行诊断治疗,但新冠肺炎的弥漫性感染.感染区域形状多变.与其他肺部组织极易混淆等给CT图像分割带来挑战.为此, ...

  4. 【计算机视觉】新冠肺炎COVID-19 CT影片阳性检测,感染区域分割,肺部分割,智慧医疗实践,医疗影像处理示例

    引言 新型冠状病毒肺炎(Corona Virus Disease 2019,COVID-19),简称"新冠肺炎",世界卫生组织命名为"2019冠状病毒病".截止 ...

  5. IterNet——迭代式U-Net变形

    IterNet 资源 1 数据集 2 数据增强方式 3 初始设置 4 比较范围 5 核心方法 6 源码 资源 文章代码:ITerNet 1 数据集 DRIVE:共40张,大小565✖584,具体介绍及 ...

  6. [深度学习论文笔记]Brain tumour segmentation using a triplanar ensemble of U-Nets 基于Unet三平面集成的脑肿瘤分割

    Brain tumour segmentation using a triplanar ensemble of U-Nets 基于U网络三平面集成的脑肿瘤分割 Published: May 2021 ...

  7. 修改中。。。。【AIChallenger 2018 】【眼底水肿病变区域分割】冠军解决方案

    内容完善中... 赛道:眼底水肿病变区域分割 队名:965728310 比赛地址:https://challenger.ai/competition/fl2018,答辩视频地址可关注官网最新动态 特别 ...

  8. FCN与U-Net语义分割算法

    FCN与U-Net语义分割算法 图像语义分割(Semantic Segmentation)是图像处理和是机器视觉技术中关于图像理解的重要一环,也是 AI 领域中一个重要的分支.语义分割即是对图像中每一 ...

  9. 基于FCN,U-Net的深度学习医学影像分割算法(细胞分割算法)以及传统算法分析

    本博文主要分析了基于传统计算机视觉的细胞分割算法和基于深度学习的细胞分割算法.主要针对医学影像分割算法.包括了FCN全卷积网络的细胞分割效果,U-Net细胞分割效果.查阅了采用深度学习分割医学影像的几 ...

最新文章

  1. 在云中利用开源软件进行开发以提高创新能力
  2. Java初学者需掌握的4大核心基础知识
  3. 计算机硬盘read,为你解答电脑开机提示a disk read error occurred怎么办
  4. 生活本该如此——莫言
  5. 分区和分片的区别_PHP: 分区和分片 - Manual
  6. bootstrap validator 提供了哪些验证函数
  7. 面向对象三节课,对象与权限修饰符,作业0918
  8. 网易2016游戏技术岗在线编程题(二)
  9. Idea2020版本设置编码格式
  10. Linux系统下matplotlib中文乱码解决办法
  11. python爬虫小案例
  12. 终于能在Linux下用firefox使用支付宝了!!!
  13. JPA--动态查询--Example
  14. CentOS 8.3.2011 镜像在PC上安装选择安装源时提示:设置基础软件仓库时出错
  15. 百度收录提交软件-百度批量收录提交入口工具免费
  16. Pytorch使用CPU
  17. 360 一个让人又爱又恨的公司
  18. 信息基础Homework4
  19. Rails permit params 接受Hash,Array
  20. 从旧金山到瑞典的开发者的福利

热门文章

  1. 全栈深度学习第3期: 怎样科学管理实验数据?
  2. C++很难学?这个ACM金牌大佬可不这么认为!
  3. 在传统Spring应用中使用spring-boot-actuator模块提供监控端点
  4. Probe:Android线上OOM问题定位组件
  5. 论文浅尝 - ICLR2020 | Pretrained Encyclopedia: 弱监督知识预训练语言模型
  6. 论文浅尝 | 面向时序知识图谱推理的循环事件网络
  7. Android官方开发文档Training系列课程中文版:多样屏幕之支持不同的屏幕尺寸
  8. ansible配置zabbix自动化安装和配置
  9. Node.js对MongoDB进行增删改查操作
  10. 杂项:TMT(数字媒体产业)