为各种图像来源提供接口的io数据处理模块,用于像素分类工具
项目描述
yapic_io
yapic_io
提供对任意大小图像集合的灵活数据绑定。
其目标是提供一个方便的图像数据接口,用于训练全卷积神经网络,以及自动处理训练分类器的预测数据输出。
yapic_io
被设计成一个方便的图像数据输入/输出接口,用于如Theano
或TensorFlow
之类的库。
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 查看哈希值)
关闭
yapic_io-0.2.7.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d8d3b99f75d737c158c6af8e230bb31b15f0d79f53a647e704c41ac5b6b697a5 |
|
MD5 | f73d5a5ee8fcff164f1eb7081e0cdfa3 |
|
BLAKE2b-256 | 0acaf5bfb2b6f8b21b26bb39ac60d38b699918310957d11416a2d7ec6f3415fb |
关闭
yapic_io-0.2.7-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 5b7b135905a95c815a68bdd38a3ad4be4da020a2a6adfdbf0d7029987912695c |
|
MD5 | 8e4b1cb41f368ea98b790a8868bc8519 |
|
BLAKE2b-256 | ace4303248da0a6d0fa0e82e6a1ae01d34455e88cc2f5a737ebde09cd334a0e8 |