module ai.image_segmentation

Inheritance diagram of code_beatrix.ai.image_segmentation

Short summary

module code_beatrix.ai.image_segmentation

Extracts objects from an image based on deep learning.

source on GitHub

Classes

class

truncated documentation

DLImageSegmentation

Segments an image. Inspired from infer.py. …

Properties

property

truncated documentation

ModelFile

Returns the model file name.

Static Methods

staticmethod

truncated documentation

_new_size

Computes a new size.

Methods

method

truncated documentation

__init__

_load_image

Loads an image as a numpy.array.

_preprocess

Preprocesses the image before prediction.

plot

Displays the segmentation.

predict

Applies the model on features X.

Documentation

Extracts objects from an image based on deep learning.

source on GitHub

class code_beatrix.ai.image_segmentation.DLImageSegmentation(model='FCN8s', n_class=21, gpu=False, class_name=None, fLOG=None)[source]

Bases : code_beatrix.ai.dlbase.DeepLearningImage

Segments an image. Inspired from infer.py. See notebook Segmenter une image pixel à pixel.

source on GitHub

Paramètres
  • model – model name

  • n_class – number of classes

  • gpu – use gpu

  • class_name – class names

  • fLOG – logging function

List of known models:

  • 'FCN8s': image segmentation

source on GitHub

property ModelFile

Returns the model file name.

source on GitHub

__init__(model='FCN8s', n_class=21, gpu=False, class_name=None, fLOG=None)[source]
Paramètres
  • model – model name

  • n_class – number of classes

  • gpu – use gpu

  • class_name – class names

  • fLOG – logging function

List of known models:

  • 'FCN8s': image segmentation

source on GitHub

_load_image(img, resize=None)[source]

Loads an image as a numpy.array.

Paramètres
  • img – image

  • resize – resize the image before predicting, see _new_size

Renvoie

numpy.array

source on GitHub

static _new_size(old_size, new_size)[source]

Computes a new size.

Paramètres
  • old_size – current size

  • new_size – new desired size

Renvoie

new size

new_size can be of:

  • (int, int): this is the new size

  • (“max2”, int): this size is divided by 2 until the greater dimension is below a threshold

source on GitHub

_preprocess(feat, preprocess=True)[source]

Preprocesses the image before prediction.

Paramètres
  • feat – image (output of _load_image)

  • preprocess – applies some preprocessing or not

Renvoie

preprocessed image

source on GitHub

plot(img, pred)[source]

Displays the segmentation.

Paramètres

img – initial image

Renvoie

new image

source on GitHub

predict(img, resize=None)[source]

Applies the model on features X.

Paramètres
  • img – image

  • resize – resize the image before predicting, see _new_size

Renvoie

(image, prediction)

source on GitHub