# renom_img.api.classification ¶

class  VGG11  ( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False )

VGG11 model.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. Pretrained weights have not been prepared for VGG-11 yet, so this must either be set to False, or to a user-defined string that specifies a local pretrained weights filename. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If true, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.vgg import VGG11
>>>
>>> class_map = ["dog", "cat"]
>>> model = VGG11(class_map, imsize=(224,224), load_pretrained_weight=False, train_whole_network=True)


Note

VGG11 does not currently have pretrained weights available, so you must use randomly initialized weights or provide user-trained weights. If you would like to initialize your model with ImageNet pretrained weights, please use VGG16, VGG19 or any ResNet/ResNeXt model in ReNom.

References

Karen Simonyan, Andrew Zisserman
Very Deep Convolutional Networks for Large-Scale Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for VGG11.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = VGG11(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to VGG11. Returns raw output of VGG11. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = VGG11(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of VGG11 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = VGG11(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  VGG16  ( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False )

VGG16 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int or tuple ) – Input image size. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.vgg import VGG16
>>>
>>> class_map = ["dog", "cat"]
>>> model = VGG16(class_map, imsize=(224,224), load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Karen Simonyan, Andrew Zisserman
Very Deep Convolutional Networks for Large-Scale Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for VGG16.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = VGG16(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to VGG16. Returns raw output of VGG16. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = VGG16(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of VGG16 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = VGG16(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  VGG19  ( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False )

VGG19 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.vgg import VGG19
>>>
>>> class_map = ["dog", "cat"]
>>> model = VGG19(class_map, imsize=(224,224), load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Karen Simonyan, Andrew Zisserman
Very Deep Convolutional Networks for Large-Scale Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for VGG19.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = VGG19(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to VGG19. Returns raw output of VGG19. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = VGG19(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of VGG19 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = VGG19(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  ResNet101  ( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False )

ResNet101 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. plateau ( bool ) – Specifies whether or not error plateau learning rate adjustment should be used. If True, learning rate is automatically decreased when training loss reaches a plateau. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.resnet import ResNet101
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet101(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for ResNet101.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = ResNet101(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to ResNet101. Returns raw output of ResNet101. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet101(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of ResNet101 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = ResNet101(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  ResNet152  ( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False )

ResNet152 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. plateau ( bool ) – Specifies whether or not error plateau learning rate adjustment should be used. If True, learning rate is automatically decreased when training loss reaches a plateau. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.resnet import ResNet152
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet152(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for ResNet152.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = ResNet152(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to ResNet152. Returns raw output of ResNet152. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet152(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of ResNet152 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = ResNet152(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  ResNet18  ( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False )

ResNet18 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. plateau ( bool ) – Specifies whether or not error plateau learning rate adjustment should be used. If True, learning rate is automatically decreased when training loss reaches a plateau. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.resnet import ResNet18
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet18(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for ResNet18.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = ResNet18(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to ResNet18. Returns raw output of ResNet18. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet18(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of ResNet18 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = ResNet18(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  ResNet34  ( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False )

ResNet34 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. plateau ( bool ) – Specifies whether or not error plateau learning rate adjustment should be used. If True, learning rate is automatically decreased when training loss reaches a plateau. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.resnet import ResNet34
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet34(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for ResNet34.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = ResNet34(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to ResNet34. Returns raw output of ResNet34. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet34(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of ResNet34 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = ResNet34(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  ResNet50  ( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False )

ResNet50 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. plateau ( bool ) – Specifies whether or not error plateau learning rate adjustment should be used. If True, learning rate is automatically decreased when training loss reaches a plateau. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.resnet import ResNet50
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet50(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition

 build_data  ( )

This function returns a function which creates input data and target data specified for ResNet50.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = ResNet50(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to ResNet50. Returns raw output of ResNet50. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNet50(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of ResNet50 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = ResNet50(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  ResNeXt101  ( class_map=None , imsize=(224 , 224) , cardinality=32 , plateau=False , load_pretrained_weight=False , train_whole_network=False )

ResNeXt101 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. cardinality ( int ) – Number of groups in group convolution layers (default = 32) plateau ( bool ) – Specifies whether or not error plateau learning rate adjustment should be used. If True, learning rate is automatically decreased when training loss reaches a plateau. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.resnext import ResNeXt101
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNeXt101(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, Kaiming He
Aggregated Residual Transformations for Deep Neural Networks

 build_data  ( )

This function returns a function which creates input data and target data specified for ResNeXt101.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = ResNeXt101(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to ResNeXt101. Returns raw output of ResNeXt101. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNeXt101(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of ResNeXt101 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = ResNeXt101(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  ResNeXt50  ( class_map=None , imsize=(224 , 224) , cardinality=32 , plateau=False , load_pretrained_weight=False , train_whole_network=False )

ResNeXt50 model.

If the argument load_pretrained_weight is True, pretrained weights will be downloaded. The pretrained weights were trained using ILSVRC2012.

 Parameters: class_map ( list , dict ) – List of class names. imsize ( int , tuple ) – Input image size. cardinality ( int ) – Number of groups in group convolution layers (default = 32) plateau ( bool ) – Specifies whether or not error plateau learning rate adjustment should be used. If True, learning rate is automatically decreased when training loss reaches a plateau. load_pretrained_weight ( bool , str ) – Argument specifying whether or not to load pretrained weight values. If True, pretrained weights will be downloaded to the current directory and loaded as the initial weight values. If a string is given, weight values will be loaded and initialized from the weights in the given file name. train_whole_network ( bool ) – Flag specifying whether to freeze or train the base layers of the model during training. If True, trains all layers of the model. If False, the convolutional base is frozen during training.

Example

>>> from renom_img.api.classification.resnext import ResNeXt50
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNeXt50(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)


Note

If the argument num_class is not equal to 1000, the last dense layer will be reset because the pretrained weight was trained on a 1000-class dataset.

References

Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, Kaiming He
Aggregated Residual Transformations for Deep Neural Networks

 build_data  ( )

This function returns a function which creates input data and target data specified for ResNeXt50.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = ResNeXt50(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to ResNeXt50. Returns raw output of ResNeXt50. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = ResNeXt50(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of ResNeXt50 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = ResNeXt50(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  DenseNet121  ( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False )

DenseNet121 Model

If the argument load_weight is True, pretrained weight will be downloaded. The pretrained weight is trained using ILSVRC2012.

 Parameters: class_map – Array of class names growth_rate ( int ) – Growth rate of the number of filters. imsize ( int or tuple ) – Input image size. train_whole_network ( bool ) – True if the overal model is trained.

Note

if the argument num_class is not 1000, last dense layer will be reset because the pretrained weight is trained on 1000 classification dataset.

References

Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf

 build_data  ( )

This function returns a function which creates input data and target data specified for DenseNet121.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = DenseNet121(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to DenseNet121. Returns raw output of DenseNet121. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = DenseNet121(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of DenseNet121 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = DenseNet121(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  DenseNet169  ( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False )

DenseNet169 Model

If the argument load_weight is True, pretrained weight will be downloaded. The pretrained weight is trained using ILSVRC2012.

 Parameters: class_map – Array of class names growth_rate ( int ) – Growth rate of the number of filters. imsize ( int or tuple ) – Input image size. train_whole_network ( bool ) – True if the overal model is trained.

Note

if the argument num_class is not 1000, last dense layer will be reset because the pretrained weight is trained on 1000 classification dataset.

References

Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf

 build_data  ( )

This function returns a function which creates input data and target data specified for DenseNet169.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = DenseNet169(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to DenseNet169. Returns raw output of DenseNet169. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = DenseNet169(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of DenseNet169 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = DenseNet169(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  DenseNet201  ( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False )

DenseNet201 Model

If the argument load_weight is True, pretrained weight will be downloaded. The pretrained weight is trained using ILSVRC2012.

 Parameters: class_map – Array of class names growth_rate ( int ) – Growth rate of the number of filters. load_weight ( bool ) – True if the pre-trained weight is loaded. imsize ( int or tuple ) – Input image size. train_whole_network ( bool ) – True if the overal model is trained.

Note

if the argument num_class is not 1000, last dense layer will be reset because the pretrained weight is trained on 1000 classification dataset.

References

Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf

 build_data  ( )

This function returns a function which creates input data and target data specified for DenseNet201.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = DenseNet201(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to DenseNet201. Returns raw output of DenseNet201. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = DenseNet201(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of DenseNet201 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = DenseNet201(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.

class  DenseNetC10  ( class_map=None , imsize=(32 , 32) , load_pretrained_weight=False , train_whole_network=False )

DenseNet Model prepared for CIFAR 10 dataset Densenet-BC k=12, depth=100 version

If the argument load_weight is True, pretrained weight will be downloaded. The pretrained weight is trained using CIFAR-10.

 Parameters: class_map – Array of class names growth_rate ( int ) – Growth rate of the number of filters. load_weight ( bool ) – True if the pre-trained weight is loaded. imsize ( int or tuple ) – Input image size. train_whole_network ( bool ) – True if the overal model is trained.

Note

if the argument num_class is not 1000, last dense layer will be reset because the pretrained weight is trained on 1000 classification dataset.

References

Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf

 build_data  ( )

This function returns a function which creates input data and target data specified for DenseNetC10.

 Returns: Returns function which creates input data and target data. (function)

Example

>>> builder = model.build_data()  # This will return function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 fit  ( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None )

This function performs training with the given data and hyperparameters.

 Parameters: train_img_path_list ( list ) – List of image paths. train_annotation_list ( list ) – List of annotations. valid_img_path_list ( list ) – List of image paths for validation. valid_annotation_list ( list ) – List of annotations for validation. epoch ( int ) – Number of training epochs. batch_size ( int ) – Batch size. augmentation ( Augmentation ) – Augmentation object. callback_end_epoch ( function ) – Given function will be called at the end of each epoch. Training loss list and validation loss list. (tuple)

Example

>>> train_img_path_list, train_annot_list = ... # Define train data
>>> valid_img_path_list, valid_annot_list = ... # Define validation data
>>> class_map = ... # Define class map
>>> model = DenseNetC10(class_map) # Specify any algorithm provided by ReNomIMG API here
>>> model.fit(
...     # Feeds image and annotation data
...     train_img_path_list,
...     train_annot_list,
...     valid_img_path_list,
...     valid_annot_list,
...     epoch=8,
...     batch_size=8)
>>>


The following arguments will be given to the function  callback_end_epoch  .

• epoch (int) - Current epoch number.
• model (Model) - Model object.
• avg_train_loss_list (list) - List of average train loss of each epoch.
• avg_valid_loss_list (list) - List of average valid loss of each epoch.
 forward  ( x )

Performs forward propagation. You can call this function using the  __call__  method.

 Parameters: x ( ndarray , Node ) – Input to DenseNetC10. Returns raw output of DenseNetC10. (Node)

Example

>>> import numpy as np
>>> x = np.random.rand(1, 3, 224, 224)
>>>
>>> class_map = ["dog", "cat"]
>>> model = DenseNetC10(class_map)
>>>
>>> y = model.forward(x) # Forward propagation.
>>> y = model(x)  # Same as above result.

 loss  ( x , y )

Loss function of DenseNetC10 algorithm.

 Parameters: x ( ndarray , Node ) – Output of model. y ( ndarray , Node ) – Target array. Loss between x and y. (Node)

Example

>>> builder = model.build_data()  # This will return a builder function.
>>> x, y = builder(image_path_list, annotation_list)
>>> z = model(x)
>>> loss = model.loss(z, y)

 predict  ( img_list , batch_size=1 , return_scores=False )

Perform prediction. Argument can be an image array, image path list or a image path.

 Parameters: img_list ( ndarray , list , string ) – Image array, image path list or image path. batch_size ( int ) – Batch size for processing input images. return_scores ( bool ) – Optional flag to return prediction scores for all classes when set to True. Default is False. List of predicted class for each image. Also returns array of all probability scores if return_scores is set to True. (array)
 preprocess  ( x )

Performs preprocessing for a given array.

 Parameters: x ( ndarray , Node ) – Image array for preprocessing.
 regularize  ( )

Adds a regularization term to the loss function.

Example

>>> x = numpy.random.rand(1, 3, 224, 224)  # Input image
>>> y = ...  # Ground-truth label
>>>
>>> class_map = ['cat', 'dog']
>>> model = DenseNetC10(class_map)
>>>
>>> z = model(x)  # Forward propagation
>>> loss = model.loss(z, y)  # Loss calculation
>>> reg_loss = loss + model.regularize()  # Add weight decay term.