Closed nickvazz closed 2 years ago
https://stackoverflow.com/questions/31877353/overlay-an-image-segmentation-with-numpy-and-matplotlib
fig, ax = plt.subplots(ncols=1, figsize=(15,10))
ax.imshow(img/256 + mask.reshape(mask.shape[0], mask.shape[1], 1).astype(float))
plt.show()
this is a way to iterate through the segmentations in the training loop
from tensorflow import keras
import numpy as np
from tensorflow.keras.preprocessing.image import load_img
class OxfordPets(keras.utils.Sequence):
"""Helper to iterate over the data (as Numpy arrays)."""
def __init__(self, batch_size, img_size, input_img_paths, target_img_paths):
self.batch_size = batch_size
self.img_size = img_size
self.input_img_paths = input_img_paths
self.target_img_paths = target_img_paths
def __len__(self):
return len(self.target_img_paths) // self.batch_size
def __getitem__(self, idx):
"""Returns tuple (input, target) correspond to batch #idx."""
i = idx * self.batch_size
batch_input_img_paths = self.input_img_paths[i : i + self.batch_size]
batch_target_img_paths = self.target_img_paths[i : i + self.batch_size]
x = np.zeros((self.batch_size,) + self.img_size + (3,), dtype="float32")
for j, path in enumerate(batch_input_img_paths):
img = load_img(path, target_size=self.img_size)
x[j] = img
y = np.zeros((self.batch_size,) + self.img_size + (1,), dtype="uint8")
for j, path in enumerate(batch_target_img_paths):
img = load_img(path, target_size=self.img_size, color_mode="grayscale")
y[j] = np.expand_dims(img, 2)
# Ground truth labels are 1, 2, 3. Subtract one to make them 0, 1, 2:
y[j] -= 1
return x, y
https://scikit-image.org/docs/stable/auto_examples/transform/plot_rescale.html
https://albumentations.ai
https://aditi-mittal.medium.com/introduction-to-u-net-and-res-net-for-image-segmentation-9afcb432ee2f
https://keras.io/examples/vision/retinanet/
https://towardsdatascience.com/master-the-coco-dataset-for-semantic-image-segmentation-part-1-of-2-732712631047
https://voxel51.com/docs/fiftyone/api/fiftyone.core.labels.htmlhighlight=bounding%20box#fiftyone.core.labels.Detection.bounding_box
https://voxel51.com/docs/fiftyone/recipes/image_deduplication.html?highlight=keras
https://towardsdatascience.com/an-overview-of-resnet-and-its-variants-5281e2f56035
https://keras.io/examples/vision/retinanet/#computing-pairwise-intersection-over-union-iou
https://github.com/matterport/Mask_RCNN
https://aditi-mittal.medium.com/introduction-to-u-net-and-res-net-for-image-segmentation-9afcb432ee2f