Basic image classification

This example shows pipeline for basic image classification

Coplete source code for example can be found in programs.image_processing.basic_image_classification.

Imports that will be used

import pathlib
PATH = pathlib.Path(__file__).parent.resolve()

from utca.implementation.tasks import TransformersImageClassification
from utca.implementation.datasources.image import ImageRead

Pipeline

pipeline = (
    ImageRead() | TransformersImageClassification()
)

ImageRead is used to open image file.

For image classification used TransformersImageClassification.

For more, see:

ImageTransformersImageClassification

Run program

result = pipeline.run({
    "path_to_file": f"{PATH}/test.jpg"
})

Inputs

  • "path_to_file": path that directs to a file that should be in programs.image_processing.basic_image_classification. This is an image of German Shepherd Dog.

Results

The results should look like this:

{
    'path_to_file': '{PATH}/programs/image_processing/basic_image_classification/test.jpg',
    'image': <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1080x1080 at 0x7D6189900B80>, 
    'label': (
        'German shepherd, German shepherd dog, German police dog, alsatian',
        0.9983240962028503
    )
}

Last updated