在keras中包含多个u-net实现的helper包,以及在处理图像分割任务时有用的实用工具

keras-unet的Python项目详细描述


关于

在keras中包含多个u-net实现的helper包,以及在处理图像分割任务时有用的实用工具

功能:

  • [X]在Keras中实现的U-net模型
  • [X]实用功能:
    • [X]使用覆盖图绘制图像和遮罩
    • [X]绘制图像蒙版和覆盖预测(原始图像上的预测)
    • [X]绘制度量和损失的培训历史记录
    • [X]使用滑动窗口技术从更大的图像(例如卫星图像)中裁剪更小的面片(如果需要,还可以重叠)
    • [X]绘制较小的面片以显示裁剪的大图像
    • [X]将较小的面片重建回大图像
    • [X]数据增强助手函数
  • [X]笔记本电脑(示例):
    • [X]针对鲸鱼尾巴分割的定制U形网培训
    • []卫星图像的语义分割
    • 医学图像的语义分割ISBI challenge 2015

安装:

pip install git+https://github.com/karolzak/keras-unet

pip install keras-unet

用法示例:


香草u形网

Model scheme can be viewed here

fromkeras_unet.modelsimportvanilla_unetmodel=vanilla_unet(input_shape=(512,512,3))

[back to usage examples]


可定制U-net

Model scheme can be viewed here

fromkeras_unet.modelsimportcustom_unetmodel=custom_unet(input_shape=(512,512,3),use_batch_norm=False,num_classes=1,filters=64,dropout=0.2,output_activation='sigmoid')

[back to usage examples]


卫星图像的u-net

Model scheme can be viewed here

fromkeras_unet.modelsimportsatellite_unetmodel=satellite_unet(input_shape=(512,512,3))

[back to usage examples]


绘制训练历史

history=model.fit_generator(...)fromkeras_unet.utilsimportplot_segm_historyplot_segm_history(history,# required - keras training history objectmetrics=['iou','val_iou'],# optional - metrics names to plotlosses=['loss','val_loss'])# optional - loss names to plot

输出:
metric historyloss history

[back to usage examples]


绘制图像和分割遮罩

fromkeras_unet.utilsimportplot_imgsplot_imgs(org_imgs=x_val,# required - original imagesmask_imgs=y_val,# required - ground truth maskspred_imgs=y_pred,# optional - predicted masksnm_img_to_plot=9)# optional - number of images to plot

输出:
plotted images, masks and predictions

[back to usage examples]


从较大的图像中获取较小的面片/作物

fromPILimportImageimportnumpyasnpfromkeras_unet.utilsimportget_patchesx=np.array(Image.open("../docs/sat_image_1.jpg"))print("x shape: ",str(x.shape))x_crops=get_patches(img_arr=x,# required - array of images to be croppedsize=100,# default is 256stride=100)# default is 256print("x_crops shape: ",str(x_crops.shape))

输出:

x shape:  (1000, 1000, 3)   
x_crops shape:  (100, 100, 100, 3)

[back to usage examples]


将小面片绘制成单个大图像

fromkeras_unet.utilsimportplot_patchesprint("x_crops shape: ",str(x_crops.shape))plot_patches(img_arr=x_crops,# required - array of cropped out imagesorg_img_size=(1000,1000),# required - original size of the imagestride=100)# use only if stride is different from patch size

输出:

x_crops shape:  (100, 100, 100, 3)

plotted patches

[back to usage examples]


从较小的斑块/作物重建较大的图像

importmatplotlib.pyplotaspltfromkeras_unet.utilsimportreconstruct_from_patchesprint("x_crops shape: ",str(x_crops.shape))x_reconstructed=reconstruct_from_patches(img_arr=x_crops,# required - array of cropped out imagesorg_img_size=(1000,1000),# required - original size of the imagestride=100)# use only if stride is different from patch sizeprint("x_reconstructed shape: ",str(x_reconstructed.shape))plt.figure(figsize=(10,10))plt.imshow(x_reconstructed[0])plt.show()

输出:

x_crops shape:  (100, 100, 100, 3)
x_reconstructed shape:  (1, 1000, 1000, 3)

reconstructed image

[back to usage examples]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java关闭应用程序按钮Listener   Java中的多线程同步在Java示例中的思考   java如何查看Tomcat正在使用/访问的JAR?   java My代码在调用垃圾收集器后不会终止   多线程Java连接线程池和connectionfactory?   java在运行时修改JAR文件   java Android:使用光标时引发IllegaleException   在Netbeans中测试不可执行库的java?   泛型在参数上强制子类Java类型   spring Java:继承与依赖注入“自动连线”   javascript如何解析这个xml元素   java打印特定序列中的数组   带有ProcessingTimeSessionWindow的java Apache Flink自定义触发器   java如何配置消息驱动的Bean应用程序和Glassfish来使用来自远程MessageBroker的消息?