Inference radtorch.inference
Inference
An Inference class creates a predictor object that utilizes a trained model to perform predictions over target image(s).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classifier |
ImageClassifier |
trained |
required |
use_best_model |
bool |
True to use the model with the lowest validation loss. |
True |
transform |
list |
Albumentations transformations. See Image Augmentation. See below. |
False |
device |
str |
Device to be used for training. Default: 'auto' which automtically detects GPU presence and uses it for feature extraction. Options: 'auto', 'cuda', 'cpu'. |
'auto' |
Using transform
By default, the Inference
class utilizes the transforms specified in the train
subset used to train the ImageClassifier
. When this is not available, it will try to utilize transforms of the valid
subset.
You can specify specific transforms as needed instead.
Methods
predict(self, img_path, top_predictions='all', human=True, display_image=False, cmap='gray')
Performs predictions using Inference
class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img_path |
str |
path to target image. |
required |
top_predictions |
int or str |
number of top predictions to return. Default = 'all' which returns all predictions. |
'all' |
human |
bool |
True to display predictions in human readable format. |
True |
display_image |
bool |
True to display the target image. |
False |
cmap |
string |
Name of Matplotlib color map to be used. See Matplotlib colormaps |
'gray' |
Returns:
Type | Description |
---|---|
(list) list of predictions if |