跳转到主要内容

为各种图像来源提供接口的io数据处理模块,用于像素分类工具

项目描述

Build Status Documentation Status PyPI

yapic_io

yapic_io提供对任意大小图像集合的灵活数据绑定。

其目标是提供一个方便的图像数据接口,用于训练全卷积神经网络,以及自动处理训练分类器的预测数据输出。

yapic_io被设计成一个方便的图像数据输入/输出接口,用于如TheanoTensorFlow之类的库。

yapic_io处理以下训练/分类中存在的问题

  • 可以应用不同大小的z、x和y图像到相同的卷积网络。这是通过滑动窗口实现的。这些窗口的大小与卷积网络输入层的大小相对应。

  • 由于惰性数据加载,图像可以非常大。

  • 图像维度可以高达4D(多通道z堆栈),例如,生物图像所要求的。

  • 分类器训练内置数据增强。

  • 适用于稀疏标记的数据集:训练数据仅从存在标签的区域(随机)选择。

  • 通常,CNN的输入层比输出层大。因此,位于图像边缘的像素通常不会被分类。使用yapic_io也可以对边缘像素进行分类。这是通过对边缘区域的像素数据进行镜像实现的。因此,输出分类图像与源图像具有相同的尺寸,并且可以轻松叠加。

当前支持的图像标注平台

示例分类器

训练:

from yapic_io import TiffConnector, Dataset, TrainingBatch

#define data locations
pixel_image_dir = 'yapic_io/test_data/tiffconnector_1/im/*.tif'
label_image_dir = 'yapic_io/test_data/tiffconnector_1/labels/*.tif'
savepath = 'yapic_io/test_data/tmp/'


tpl_size = (1,5,4) # size of network output layer in zxy
padding = (0,2,2) # padding of network input layer in zxy, in respect to output layer

c = TiffConnector(pixel_image_dir, label_image_dir, savepath=savepath)
train_data = TrainingBatch(Dataset(c), tpl_size, padding_zxy=padding)

counter=0
for mini in train_data:
     weights = mini.weights
     #shape of weights is (6,3,1,5,4) : batchsize 6 , 3 label-classes, 1 z, 5 x, 4 y

     pixels = mini.pixels()
     # shape of pixels is (6,3,1,9,8) : 3 channels, 1 z, 9 x, 4 y (more xy due to padding)

     #here: apply training on mini.pixels and mini.weights (use theano, tensorflow...)
     my_train_function(pixels, weights)

     counter += 1
     if counter > 10: #m is infinite
         break

预测:

from yapic_io import TiffConnector, Dataset, PredictionBatch

#mock classification function
def classify(pixels, value):
    return np.ones(pixels.shape) * value

#define data loacations
pixel_image_dir = 'yapic_io/test_data/tiffconnector_1/im/*.tif'
label_image_dir = 'yapic_io/test_data/tiffconnector_1/labels/*.tif'
savepath = 'yapic_io/test_data/tmp/'

tpl_size = (1,5,4) # size of network output layer in zxy
padding = (0,2,2) # padding of network input layer in zxy, in respect to output layer

c = TiffConnector(pixel_image_dir, label_image_dir, savepath=savepath)
prediction_data = PredictionBatch(Dataset(c))
print(len(prediction_data)) #give the total number of templates that cover the whole bound tifffiles

#classify the whole bound dataset
counter = 0 #needed for mock data
for item in prediction_data:
    pixels_for_classifier = item.pixels() #input for classifier
    mock_classifier_result = classify(pixels, counter) #classifier output

    #pass classifier results for each class to data source
    item.put_probmap_data(mock_classifier_result)

    counter += 1 #counter for generation of mockdata

构建API文档

cd docs
sphinx-apidoc -o source ../yapic_io
make html

由DZNE(德国神经退行性疾病中心)的CRFS(核心研究设施)开发。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码发行版

yapic_io-0.2.7.tar.gz (42.5 kB 查看哈希值)

上传时间 源代码

构建发行版

yapic_io-0.2.7-py3-none-any.whl (46.3 kB 查看哈希值)

上传时间 Python 3

由以下提供支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面