[![Build](https://github.com/karolzak/keras-unet/workflows/Python%20package/badge.svg)](https://github.com/karolzak/keras-unet/actions?query=workflow%3A%22Python+package%22)
[![PyPI - version](https://img.shields.io/pypi/v/keras-unet.svg "PyPI version")](https://pypi.org/project/keras-unet/)
[![Downloads](https://pepy.tech/badge/keras-unet)](https://pepy.tech/project/keras-unet)
[![Downloads/Month](https://pepy.tech/badge/keras-unet/month)](https://pepy.tech/project/keras-unet/month)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/karolzak/keras-unet/blob/master/LICENSE)
<!-- ![Python versions](https://img.shields.io/pypi/pyversions/keras-unet "Supported Python versions") -->
**Share**:
[![Twitter URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Fgithub.com%2karolzak%2Fkeras-unet)](http://twitter.com/share?text=Check%20out%20Keras-Unet%20Python%20package%20which%20helps%20you%20to%20build%20image%20segmentation%20models%20in%20TF%20and%20Keras&url=https://github.com/karolzak/keras-unet/&hashtags=python,computervision,semanticsegmentation,unet,keras,tensorflow,deeplearning,ML,AI)
[![LinkedIn URL](https://raw.githubusercontent.com/karolzak/boxdetect/master/images/linkedin_share4.png)](http://www.linkedin.com/shareArticle?mini=true&url=https://github.com/karolzak/keras-unet&title=Keras%20UNet%20python%20package)
# About
Helper package with multiple U-Net implementations in Keras as well as useful utility tools helpful when working with image segmentation tasks
# Features:
- [x] U-Net models implemented in Keras
- [x] Vanilla U-Net implementation based on [the original paper](https://arxiv.org/pdf/1505.04597.pdf)
- [x] Customizable U-Net
- [x] U-Net optimized for satellite images based on [DeepSense.AI Kaggle competition entry](https://deepsense.ai/deep-learning-for-satellite-imagery-via-image-segmentation/)
- [x] Utility functions:
- [x] Plotting images and masks with overlay
- [x] Plotting images masks and predictions with overlay (prediction on top of original image)
- [x] Plotting training history for metrics and losses
- [x] Cropping smaller patches out of bigger image (e.g. satellite imagery) using sliding window technique (also with overlap if needed)
- [x] Plotting smaller patches to visualize the cropped big image
- [x] Reconstructing smaller patches back to a big image
- [x] Data augmentation helper function
- [x] Notebooks (examples):
- [x] Training custom U-Net for whale tails segmentation
- [ ] Semantic segmentation for satellite images
- [x] Semantic segmentation for medical images [ISBI challenge 2015](https://biomedicalimaging.org/2015/program/isbi-challenges/)
# Installation:
```bash
pip install git+https://github.com/karolzak/keras-unet
```
or
```bash
pip install keras-unet
```
# Usage examples:
- U-Net implementations in Keras:
- [Vanilla U-Net](#Vanilla-U-Net)
- [Customizable U-Net](#Customizable-U-Net)
- [U-Net for satellite images](#U-Net-for-satellite-images)
- Utils:
- [Plot training history](#Plot-training-history)
- [Plot images and segmentation masks](#Plot-images-and-segmentation-masks)
- [Get smaller patches/crops from bigger image](#Get-smaller-patches/crops-from-bigger-image)
- [Plot small patches into single big image](#Plot-small-patches-into-single-big-image)
- [Reconstruct a bigger image from smaller patches/crops](#Reconstruct-a-bigger-image-from-smaller-patches/crops)
<br>
### Vanilla U-Net
[Model scheme can be viewed here](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/vanilla_unet.png)
```python
from keras_unet.models import vanilla_unet
model = vanilla_unet(input_shape=(512, 512, 3))
```
[[back to usage examples]](#usage-examples)
<br>
### Customizable U-Net
[Model scheme can be viewed here](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/custom_unet.png)
```python
from keras_unet.models import custom_unet
model = 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]](#usage-examples)
<br>
### U-Net for satellite images
[Model scheme can be viewed here](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/satellite_unet.png)
```python
from keras_unet.models import satellite_unet
model = satellite_unet(input_shape=(512, 512, 3))
```
[[back to usage examples]](#usage-examples)
<br>
### Plot training history
```python
history = model.fit_generator(...)
from keras_unet.utils import plot_segm_history
plot_segm_history(
history, # required - keras training history object
metrics=['iou', 'val_iou'], # optional - metrics names to plot
losses=['loss', 'val_loss']) # optional - loss names to plot
```
Output:
![metric history](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/metric_history.png)
![loss history](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/loss_history.png)
[[back to usage examples]](#usage-examples)
<br>
### Plot images and segmentation masks
```python
from keras_unet.utils import plot_imgs
plot_imgs(
org_imgs=x_val, # required - original images
mask_imgs=y_val, # required - ground truth masks
pred_imgs=y_pred, # optional - predicted masks
nm_img_to_plot=9) # optional - number of images to plot
```
Output:
![plotted images, masks and predictions](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/plotted_imgs.png)
[[back to usage examples]](#usage-examples)
<br>
### Get smaller patches/crops from bigger image
```python
from PIL import Image
import numpy as np
from keras_unet.utils import get_patches
x = 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 cropped
size=100, # default is 256
stride=100) # default is 256
print("x_crops shape: ", str(x_crops.shape))
```
Output:
```output
x shape: (1000, 1000, 3)
x_crops shape: (100, 100, 100, 3)
```
[[back to usage examples]](#usage-examples)
<br>
### Plot small patches into single big image
```python
from keras_unet.utils import plot_patches
print("x_crops shape: ", str(x_crops.shape))
plot_patches(
img_arr=x_crops, # required - array of cropped out images
org_img_size=(1000, 1000), # required - original size of the image
stride=100) # use only if stride is different from patch size
```
Output:
```output
x_crops shape: (100, 100, 100, 3)
```
![plotted patches](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/plotted_patches.png)
[[back to usage examples]](#usage-examples)
<br>
### Reconstruct a bigger image from smaller patches/crops
```python
import matplotlib.pyplot as plt
from keras_unet.utils import reconstruct_from_patches
print("x_crops shape: ", str(x_crops.shape))
x_reconstructed = reconstruct_from_patches(
img_arr=x_crops, # required - array of cropped out images
org_img_size=(1000, 1000), # required - original size of the image
stride=100) # use only if stride is different from patch size
print("x_reconstructed shape: ", str(x_reconstructed.shape))
plt.figure(figsize=(10,10))
plt.imshow(x_reconstructed[0])
plt.show()
```
Output:
```output
x_crops shape: (100, 100, 100, 3)
x_reconstructed shape: (1, 1000, 1000, 3)
```
![reconstructed image](https://raw.githubusercontent.com/karolzak/keras-unet/master/docs/reconstructed_image.png)
[[back to usage examples]](#usage-examples)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
特征: 在 Keras 中实现的 U-Net 模型 基于原始论文的Vanilla U-Net 实现 可定制的 U-Net 基于DeepSense.AI Kaggle 竞赛条目针对卫星图像优化的 U-Net 实用功能: 使用叠加绘制图像和蒙版 使用叠加绘制图像掩码和预测(在原始图像之上进行预测) 绘制指标和损失的训练历史 使用滑动窗口技术从更大的图像(例如卫星图像)中裁剪出更小的块(如果需要也可以重叠) 绘制较小的补丁以可视化裁剪的大图像 将较小的补丁重建回大图像 数据增强辅助函数 笔记本(示例): 训练用于鲸尾分割的自定义 U-Net 卫星图像的语义分割 医学图像的语义分割ISBI Challenge 2015
资源推荐
资源详情
资源评论
收起资源包目录
在 Keras 中具有多个 U-Net 实现的帮助程序包以及在处理图像语义分割任务时有用的实用工具_python_代码_下载 (920个子文件)
.bumpversion.cfg 135B
.gitattributes 48B
.gitignore 1KB
kz-isbi-challenge.ipynb 8.11MB
kz-whale-tails.ipynb 2.12MB
sat_image_1.jpg 387KB
0041880bf.jpg 32KB
038b08ba9.jpg 30KB
0000e88ab.jpg 29KB
033734195.jpg 28KB
02b0efd14.jpg 28KB
0341a18ba.jpg 28KB
032adbd21.jpg 28KB
00d1615b1.jpg 27KB
0215715b6.jpg 27KB
01c941173.jpg 27KB
04153ce6d.jpg 27KB
03a5587fe.jpg 26KB
0052ce2f5.jpg 26KB
01cd70a58.jpg 26KB
0227a97f7.jpg 26KB
00d6cbcbf.jpg 26KB
03282d26c.jpg 25KB
0347973a7.jpg 25KB
026345181.jpg 25KB
028e0f415.jpg 25KB
01dc06663.jpg 25KB
0387e6dd7.jpg 25KB
00dcd026f.jpg 25KB
045bbb167.jpg 25KB
027f1594f.jpg 25KB
03b0bd5dd.jpg 25KB
00f5927ae.jpg 24KB
001c1ac5f.jpg 24KB
03cd2ba51.jpg 24KB
018b81a56.jpg 24KB
009431af0.jpg 24KB
047f23339.jpg 24KB
02d30c6e4.jpg 24KB
01396f4d1.jpg 23KB
0139248b7.jpg 23KB
01c9fe65c.jpg 23KB
0118a64b8.jpg 23KB
02c8a71de.jpg 23KB
018345b71.jpg 23KB
02e548fa4.jpg 23KB
01425e516.jpg 23KB
01bfc5ce9.jpg 23KB
01ec3759e.jpg 23KB
02a5af887.jpg 23KB
038c165c5.jpg 23KB
011258703.jpg 23KB
015a0c58d.jpg 23KB
02564ae05.jpg 23KB
04901bb01.jpg 23KB
00bc4dade.jpg 23KB
031b230c7.jpg 23KB
01eee7676.jpg 23KB
03471c92a.jpg 22KB
0489c432d.jpg 22KB
0264bd4b5.jpg 22KB
014c0deb5.jpg 22KB
02272f684.jpg 22KB
035917e70.jpg 22KB
04931bb7a.jpg 22KB
02773908c.jpg 22KB
044b2a2ae.jpg 22KB
0043da555.jpg 22KB
041c117be.jpg 22KB
017c8297e.jpg 22KB
00fee3975.jpg 22KB
03d41255d.jpg 22KB
00a70e649.jpg 22KB
00caa5c60.jpg 22KB
03976ceda.jpg 22KB
010a1f0eb.jpg 22KB
002f99f01.jpg 22KB
028bbb7af.jpg 21KB
03dcf5c8e.jpg 21KB
0197be7fd.jpg 21KB
016ac2f79.jpg 21KB
04900b886.jpg 21KB
00d641885.jpg 21KB
03bfcbcf4.jpg 21KB
00464ff65.jpg 21KB
01c602e06.jpg 21KB
04ba76e7a.jpg 21KB
046e37901.jpg 21KB
04b3ac13b.jpg 21KB
038ffb4ad.jpg 21KB
02c47bf28.jpg 21KB
0493ff477.jpg 21KB
019b53508.jpg 21KB
02dc197e1.jpg 21KB
048ab10a5.jpg 21KB
02568e465.jpg 21KB
027ec5a1d.jpg 21KB
02c389bcb.jpg 21KB
00a3dd76f.jpg 21KB
030628f8b.jpg 21KB
共 920 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9149
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功