Anubis - Bachelor thesis project

Public Member Functions | Public Attributes | Private Member Functions | List of all members
computer_vision.Computer_vision Class Reference

brief Implements Tensorflow communication More...

Collaboration diagram for computer_vision.Computer_vision:

## Public Member Functions
def | __init__ (self, plot)
| Initialize object and its variables. More...
def | load_model (self, path)
| Load Keras model. More...
def | save_model (self, path)
| Save model to defined path. More...
def | train (self, epochs, train_vals, split, progress_flag, training_flag)
| Start training loaded model. More...
def | classify (self, frame, prediction_flag)
| Classify image using trained model. More...
def | process_dataset (self, path, process_perc, categories=[], process_flag=None, callback_flag=None)
| Prepare dataset to be used as input and desired output. More...

## Public Attributes
| model
| width
| height
| categories
| plot
| split
| busy
| x
| y
| training_data

## Private Member Functions
def | _create_training_data (self, path, categories, callback_flag, process_perc)
| Auxiliary method to resize all input data to the size of input of the loaded model. More...

## Detailed Description

brief Implements Tensorflow communication

Definition at line 24 of file computer_vision.py.

## Constructor & Destructor Documentation

## ◆ __init__()

def computer_vision.Computer_vision.__init__ | ( |  | self,
|  |  | plot
| ) |  |

Initialize object and its variables.

Parameters

  [in] | plot | The class needs to have a reference to the GUI object the classification results will be shown in.

Definition at line 26 of file computer_vision.py.

## Member Function Documentation

## ◆ _create_training_data()

def computer_vision.Computer_vision._create_training_data | ( |  | self,
|  |  | path,
|  |  | categories,
|  |  | callback_flag,
|  |  | process_perc
| ) |  |
| private

Auxiliary method to resize all input data to the size of input of the loaded model.

dimensions of the model are set.

Parameters

  [in] | path | Path to the dataset
  [in] | categories | Names of the individual folders containing data for different categories.
  [in] | callback_flag | Threading event telling the calling function to update progress based on the valu in process_perc
  [in] | process_perc | Reference to the progress variable in the calling function. Value should be read during callbacks

Returns
  True if loading is successful else False.

Definition at line 190 of file computer_vision.py.

## ◆ classify()

def computer_vision.Computer_vision.classify | ( |  | self,
|  |  | frame,
|  |  | prediction_flag
| ) |  |

Classify image using trained model.

This method does not change the behavior of the network but only uses it to make prediction about what is in the picture. The result is shown in the plot passed by reference in the init method.

Parameters

  [in] | frame | OpenCV image that the prediction will be done for.
  [in] | prediction_flag | Announces that the prediction was completed

Definition at line 113 of file computer_vision.py.

## ◆ load_model()

def computer_vision.Computer_vision.load_model | ( |  | self,
|  |  | path
| ) |  |

Load Keras model.

Model is loaded from the path and variables defining input dimensions of the model are set.

Parameters

  [in] | path | Path to the folder with saved model.

Returns
  True if loading is successful else False.

Definition at line 44 of file computer_vision.py.

## ◆ process_dataset()

def computer_vision.Computer_vision.process_dataset | ( |  | self,
|  |  | path,
|  |  | process_perc,
|  |  | categories = `[]`,
|  |  | process_flag = `None`,
|  |  | callback_flag = `None`
| ) |  |

Prepare dataset to be used as input and desired output.

The method will proceed only if a model is loaded and path is valid. dimensions of the model are set.

Parameters

  [in] | path | Path to the dataset
  [in] | process_perc | Reference to the progress variable in the calling function. Value should be read during callbacks
  [in] | categories | Names of the individual folders containing data for different categories.
  [in] | process_flag | When processing finishes the flag is raised.
  [in] | callback_flag | Threading event telling the calling function to update progress based on the valu in process_perc

Returns
  True if loading is successful else False.

Definition at line 150 of file computer_vision.py.

## ◆ save_model()

def computer_vision.Computer_vision.save_model | ( |  | self,
|  |  | path
| ) |  |

Save model to defined path.

Parameters

  [in] | path | Path to the folder where model will be saved.

Returns
  True if loading is successful else False.

Definition at line 68 of file computer_vision.py.

## ◆ train()

def computer_vision.Computer_vision.train | ( |  | self,
|  |  | epochs,
|  |  | train_vals,
|  |  | split,
|  |  | progress_flag,
|  |  | training_flag
| ) |  |

Start training loaded model.

If the object is not busy, the tensorflow/Keras training will start. During training the callback object will push current values of training variavles int the references passed in train_vals.

Parameters

  [in] | epochs | How many times should the dataset be introduced to the network.
  [in] | train_vals | Reference to variables used in callback to inform calling functions about training progress
  [in] | split | Fraction of dataset to be used as validation data (float).
  [in] | progress_flag | Signal to tell that it is time to update progress values
  [in] | training_flag | Used to announce finished training

Definition at line 79 of file computer_vision.py.

## Member Data Documentation

## ◆ busy

computer_vision.Computer_vision.busy

Definition at line 37 of file computer_vision.py.

## ◆ categories

computer_vision.Computer_vision.categories

Definition at line 34 of file computer_vision.py.

## ◆ height

computer_vision.Computer_vision.height

Definition at line 33 of file computer_vision.py.

## ◆ model

computer_vision.Computer_vision.model

Definition at line 31 of file computer_vision.py.

## ◆ plot

computer_vision.Computer_vision.plot

Definition at line 35 of file computer_vision.py.

## ◆ split

computer_vision.Computer_vision.split

Definition at line 36 of file computer_vision.py.

## ◆ training_data

computer_vision.Computer_vision.training_data

Definition at line 42 of file computer_vision.py.

## ◆ width

computer_vision.Computer_vision.width

Definition at line 32 of file computer_vision.py.

## ◆ x

computer_vision.Computer_vision.x

Definition at line 39 of file computer_vision.py.

## ◆ y

computer_vision.Computer_vision.y

Definition at line 40 of file computer_vision.py.

The documentation for this class was generated from the following file:

- computer_vision.py