Infer.NET user guide : Tutorials and examples
Image classifier exampleThis example shows how to build a two-class Bayes point machine and apply it to an image classification problem. (A robust, general purpose implementation of a Bayes point machine classifier is described here). The Bayes point machine is general and could be used in many different applications - that code is described in detail later. First we discuss the application. When you run the application, the first thing you see is a window containing around 3 dozen images, and along the top of the window, a green area and a red area to drag the images. The user drags one or more images to the good or bad areas - each time this happens, you are creating a good (green) or bad (red) label for the particular image. These labelled images serve as examples, and the application learns from these examples and provides an assessment of the goodness or badness of all the unlabelled images. How far to the left or right an unlabelled image appears is a measure of the degree to which the classifier thinks it is good or bad.
Here is example where three example images have been dragged to the green area, and three to the red area. Each time an image is dragged, the model is updated, and the unlabelled images shift around.
Here, the left-hand images tend to be faces, animals and grass, and the right hand side is concentrating on roundness, water, and buildings. The overall colour in the image is encoded in the features and will also have an effect on the classification. The features that are used to represent the images are described in the next section.
This sample code along with a Visual Studio solution can be found in the Samples\C#\ImageClassifier folder. The code files are in the ImageClassifier subfolder, and are as follows:
There are also several data files which are contained in the
Images subfolder. These are: