资源简介
利用深度学习方法中的Unet网络进行彩色眼底图像中的视杯分割。
代码片段和文件信息
“““Fairly basic set of tools for real-time data augmentation on image data.
Can easily be extended to include new transformations
new preprocessing methods etc...
based on Keras code
Modified by He Xie 08/2016 Artem Sevastopolsky 10/2016
For image segmentation problem data augmentation.
Transform train img data and mask img data simultaneously and in the same fashion.
Omit flow from directory function.
“““
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
import re
from scipy import linalg
import scipy.ndimage as ndi
# from six.moves import range
import os
import threading
from keras import backend as K
def random_channel_shift(x intensity channel_index=0):
x = np.rollaxis(x channel_index 0)
min_x max_x = np.min(x) np.max(x)
channel_images = [np.clip(x_channel + np.random.uniform(-intensity intensity) min_x max_x)
for x_channel in x]
x = np.stack(channel_images axis=0)
x = np.rollaxis(x 0 channel_index+1)
return x
def transform_matrix_offset_center(matrix x y):
o_x = float(x) / 2 + 0.5
o_y = float(y) / 2 + 0.5
offset_matrix = np.array([[1 0 o_x] [0 1 o_y] [0 0 1]])
reset_matrix = np.array([[1 0 -o_x] [0 1 -o_y] [0 0 1]])
transform_matrix = np.dot(np.dot(offset_matrix matrix) reset_matrix)
return transform_matrix
def apply_transform(x transform_matrix channel_index=0 fill_mode=‘nearest‘ cval=0.):
x = np.rollaxis(x channel_index 0)
final_affine_matrix = transform_matrix[:2 :2]
final_offset = transform_matrix[:2 2]
channel_images = [ndi.interpolation.affine_transform(x_channel final_affine_matrix
final_offset order=0 mode=fill_mode cval=cval) for x_channel in x]
x = np.stack(channel_images axis=0)
x = np.rollaxis(x 0 channel_index+1)
return x
def flip_axis(x axis):
x = np.asarray(x).swapaxes(axis 0)
x = x[::-1 ...]
x = x.swapaxes(0 axis)
return x
def array_to_img(x dim_ordering=‘default‘ scale=True):
from PIL import Image
if dim_ordering == ‘default‘:
dim_ordering = K.image_dim_ordering()
if dim_ordering == ‘th‘:
x = x.transpose(1 2 0)
if scale:
x += max(-np.min(x) 0)
x /= np.max(x)
x *= 255
if x.shape[2] == 3:
# RGB
return Image.fromarray(x.astype(‘uint8‘) ‘RGB‘)
elif x.shape[2] == 1:
# grayscale
return Image.fromarray(x[: : 0].astype(‘uint8‘) ‘L‘)
else:
raise Exception(‘Unsupported channel number: ‘ x.shape[2])
def img_to_array(img dim_ordering=‘default‘):
if dim_ordering == ‘default‘:
dim_ordering = K.image_dim_ordering()
if dim_ordering not in [‘th‘ ‘tf‘]:
raise Exception(‘Unknown dim_ordering: ‘ dim_ordering)
# image has dim_ordering (height width channel)
- 上一篇:AlexNet深度神经网络
- 下一篇:百度迁徙数据爬取
相关资源
- Deep Learning Cookbook_ practical recipes to g
- 深度学习视频中的行为识别
- deep learning with python 中文版
- 吴恩达深度学习超参数调制完整程序
- 深度学习入门 基于python理论与实现
- Python-基于深度学习的语音增强使用
- 《深度学习Deep Learning with Python 2017》
- 深度学习进阶:自然语言处理
- 基于深度学习堆栈自动编码器模型的
- 深度学习入门:基于python的理论与实
- 吴恩达深度学习1-21-31-42-1编程作业线
- 基于Python的深度学习
- 安全帽检测detect.7z
- deep_learning_with_python.pdf(Jason Brownlee)
- 人脸识别python代码187268
- Make Your Own Neural Network - 搭建自己的神
- BrownLee Better Deep Learning
- python 直方图规定化代码
- 简单粗暴 TensorFlow
- 5. 深度学习中的目标检测 python代码实
- 深度学习入门:基于Python的理论与实
- Deep Learning from Scratch中文名:深度学习
- Deep Learning for Natural Language Processing.
- 字符型图片数字验证码识别完整过程
- Python深度学习122512
- 基于Tensorflow的人脸识别源码
- 中文情感分析python程序
- 基于深度学习Superpoint 的Python图像全景
- 《深度学习入门:基于Python的理论与
- Machine Learning with Python Cookbook.pdf
评论
共有 条评论