Loader Class

Loads image data.

Inheritance
nimbusml.internal.core.feature_extraction.image._loader.Loader
Loader
nimbusml.base_transform.BaseTransform
Loader
sklearn.base.TransformerMixin
Loader

Constructor

Loader(image_folder=None, columns=None, **params)

Parameters

Name Description
columns

a dictionary of key-value pairs, where key is the output column name and value is the input column name.

  • Multiple key-value pairs are allowed.

  • Input column type: string.

  • Output column type: Picture.

  • If the output column names are same as the input column names, then

simply specify columns as a list of strings.

The << operator can be used to set this value (see Column Operator)

For example

  • Loader(columns={'out1':'input1', 'out2':'input2'})

  • Loader() << {'out1':'input1', 'out2':'input2'}

For more details see Columns.

image_folder

Folder where to search for images.

params

Additional arguments sent to compute engine.

Examples


   ###############################################################################
   # Loader
   # Resizer
   # PixelExtractor
   # DnnFeaturizer
   # FastLinearBinaryClassifier
   import numpy as np
   import pandas
   from nimbusml import Pipeline
   from nimbusml.datasets.image import get_RevolutionAnalyticslogo, get_Microsoftlogo
   from nimbusml.feature_extraction.image import Loader, Resizer, PixelExtractor
   from nimbusml.linear_model import FastLinearBinaryClassifier

   data = pandas.DataFrame(data=dict(
       Path=[get_RevolutionAnalyticslogo(), get_Microsoftlogo()],
       Label=[True, False]))

   X = data[['Path']]
   y = data[['Label']]

   # define the training pipeline 
   pipeline = Pipeline([
       Loader(columns={'ImgPath': 'Path'}),
       Resizer(image_width=32, image_height=32,
               columns={'ImgResize': 'ImgPath'}),
       PixelExtractor(columns={'ImgPixels': 'ImgResize'}),
       FastLinearBinaryClassifier(feature='ImgPixels')
   ])

   # train
   pipeline.fit(X, y)

   # predict
   scores = pipeline.predict(X)
   print("Predicted Labels:", scores.PredictedLabel.values)
   # Predicted Labels : [True False]
   print("Accuracy:", np.mean(y.Label.values == scores.PredictedLabel.values))
   # Accuracy : 1

Remarks

Loader loads images from paths.

Methods

get_params

Get the parameters for this operator.

get_params

Get the parameters for this operator.

get_params(deep=False)

Parameters

Name Description
deep
Default value: False