This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ###################### unet ############################ | |
| from keras.models import Model | |
| from keras.layers import * | |
| def upsample_conv(filters, kernel_size, strides, padding): | |
| return Conv2DTranspose(filters, kernel_size, strides=strides, padding=padding) | |
| def upsample_simple(filters, kernel_size, strides, padding): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def mask_to_red(mask, img_size=1024): | |
| ''' | |
| Converts binary segmentation mask from white to red color. | |
| Also adds alpha channel to make black background transparent. | |
| ''' | |
| c1 = mask.reshape(img_size,img_size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_patches(img_arr, size=256, stride=256): | |
| ''' | |
| Takes single image or array of images and returns | |
| crops using sliding window method. | |
| If stride < size it will do overlapping. | |
| ''' | |
| # check size and stride | |
| if size % stride != 0: | |
| raise ValueError('size % stride must be equal 0') | |
NewerOlder