Image Classifier

Import KOI 2 Library

from future import *
from koi2 import KOI2

Serial Initialization

koi = KOI2(tx, rx)

Initializes the serial connection to KOI.

Parameters:

tx: TX Pin, use P2 for Robotbit EDU

rx: RX Pin, use P12 for Robotbit EDU

Select Image Classifier Mode

koi.setModel(5)

Sets the KOI mode to Face Mask Detection.

Image Classifier Add Tag

koi.classifierAddTag(class)

Adds a sample into the image classifier model.

Parameters:

class: The name for the class.

Sample Code: Image Classfier Model Training

Get Image Classifier Results

Returns the result from the image classifier.

Get Similarity Value

Returns the similarity value of the image classifier result.

Save Image Classifier Model

Saves the classifier onto the location specified.

Parameters:

location: '/sd/' to save on SD card, '/flash/' to save on onboard memory.

json: file name, must end in '.json'

Load Image Classifier Model

Saves the classifier onto the location specified.

Parameters:

location: '/sd/' to save on SD card, '/flash/' to save on onboard memory.

json: file name, must end in '.json'

Set Target for Similarity Value to Most Similar Result

Sets the similarity value to return the similarity to the result with highest similarity.

Specify Target for Similarity Value

Sets the similarity value to return the similarity to the class specified.

Parameters:

class: The name for the class.

Reset Image Classifier

Reset the Image Classifier and clears the unsaved training results.

Sample Code: Image Classifier Model Load

Last updated