Story¶
In the current step we have 200 images from random classes and we need to classify them. The first step is to have a look at the images before checking which classes need to be set in the classification.
Ipyannotator uses an API to ensure easy access to the annotators. The next cell will import the Annotator
factory, that provides a simple function InputImage
to explore images.
from ipyannotator.mltypes import InputImage
from ipyannotator.annotator import Annotator
CIFAR-10 uses 32x32 px color images. The small size of the images makes the visualization difficult. Therefore, the fit_canvas
property will be used in the next cell to improve the visual appearance, displaying the image at the same size of the InputImage
.
input_ = InputImage(image_width=100, image_height=100, image_dir='images', fit_canvas=True)
/home/runner/work/ipyannotator/ipyannotator/ipyannotator/mltypes.py:82: UserWarning: Image size will be ignored since fit_canvas is activated
warnings.warn("Image size will be ignored since fit_canvas is activated")
To use the Annotator
factory, a simple pair of Input/Output
is used. Omitting the output, Ipyannotator will use NoOutput
as default. In this case, the user can only navigate across the input images and labels/classes are not displayed in the explore function.
Annotator(input_).explore()
As mentioned before, the Ipyannotator path setup provides some default names for the folders. These names can be changed using the Settings
property. The next cells demonstrates how to use the settings property to customize the folder structure.
from ipyannotator.base import Settings
settings = Settings(
project_path=Path('user_project'),
image_dir='images',
result_dir='batata'
)
anni = Annotator(input_, settings=settings)
anni.explore()
Once the user has gained an overview on the input image dataset, the user can define classes to label the images. Using OutputLabel
you can define the classes that will be used to label the images.
The class_labels
property at OutputLabel
allows an array of classes to be used in the classification. Since CIFAR-10 uses 10 classes, these are going to be used in the next cells.
from ipyannotator.mltypes import OutputLabel
output_ = OutputLabel(class_labels=classes)
anni = Annotator(input_, output_, settings)
anni.explore()
To create your own dataset you just have to call the create
step at the Annotator
factory. This step will allow users to associate the classes to a image.
anni.create()