thermography.classification package¶
This package contains the implementation of the module classification routines implemented for the thermography
package.
Subpackages¶
Submodules¶
thermography.classification.inference module¶
-
class
Inference
(checkpoint_dir: str, model_class: type, image_shape: numpy.ndarray, num_classes: int)[source]¶ Bases:
object
Class implementing the inference procedure to classify new images according to a preexisting moduel.
Example: classification_model = ThermoNet3x3 inference = Inference(checkpoint_dir, classification_model, img_shape, num_classes) img_list = [img_1, img_2, ...] # len(img_list) = N class_probabilities = inference.classify(img_list) # class_probabilities.shape = [N, num_classes]
Initializes the inference object by loading the weights of an already trained model.
Parameters: - checkpoint_dir – Directory of the checkpoint where the weights of the model are stored.
- model_class – Class associated to the stored weights. This class is used to build the
tf.graph
which will be used for the inference. - image_shape – Shape of the images fed to the classifier. The images passed to the
self.classify
function are resized according to this parameter. - num_classes – Number of classes predicted by the model.
Warning
The parameters must all be consistent with the preexisting weights!
-
classify
(image_list: list) → numpy.ndarray[source]¶ Classifies the image list passed as argument using the model loaded in
self.model
.Parameters: image_list – Python list of numpy arrays representing the images to be classified. All images are classified as a mini-batch. Returns: A numpy array of shape [len(image_list), self.num_classes] containing the class probability for each image passed as argument. Note
If the images contained in the input parameter are not of the same shape as the one store in
self.image_shape
, the input images are resized to fit the desired image shape.
-
model
¶ Returns the model being used for classification.