Class BaseImageClassifier

All Implemented Interfaces:
ImageClassifier<Planar<GrayF32>>, ImageModelBase<Planar<GrayF32>>
Direct Known Subclasses:
ImageClassifierNiNImageNet, ImageClassifierResNet, ImageClassifierVggCifar10

public abstract class BaseImageClassifier extends Object implements ImageClassifier<Planar<GrayF32>>
Base class for ImageClassifiers which implements common elements
  • Field Details

    • network

      protected deepboof.graph.FunctionSequence<deepboof.tensors.Tensor_F32,deepboof.Function<deepboof.tensors.Tensor_F32>> network
    • categories

      protected List<String> categories
    • imageType

      protected ImageType<Planar<GrayF32>> imageType
    • massage

      protected ClipAndReduce<Planar<GrayF32>> massage
    • imageSize

      protected int imageSize
    • imageRgb

      protected Planar<GrayF32> imageRgb
    • tensorInput

      protected deepboof.tensors.Tensor_F32 tensorInput
    • tensorOutput

      protected deepboof.tensors.Tensor_F32 tensorOutput
    • categoryScores

      protected DogArray<ImageClassifier.Score> categoryScores
    • categoryBest

      protected int categoryBest
  • Constructor Details

    • BaseImageClassifier

      protected BaseImageClassifier(int imageSize)
  • Method Details

    • getInputType

      public ImageType<Planar<GrayF32>> getInputType()
      Description copied from interface: ImageModelBase
      Returns the type of input image
      Specified by:
      getInputType in interface ImageModelBase<Planar<GrayF32>>
      input image type
    • classify

      public void classify(Planar<GrayF32> image)
      The original implementation takes in an image then crops it randomly. This is primarily for training but is replicated here to reduce the number of differences
      Specified by:
      classify in interface ImageClassifier<Planar<GrayF32>>
      image - Image being processed. Must be RGB image. Pixel values must have values from 0 to 255.
    • preprocess

      protected Planar<GrayF32> preprocess(Planar<GrayF32> image)
      Massage the input image into a format recognized by the network
    • innerProcess

      protected void innerProcess(deepboof.tensors.Tensor_F32 tensorInput)
    • getBestResult

      public int getBestResult()
      Description copied from interface: ImageClassifier
      Returns the category which was the best fit.
      Specified by:
      getBestResult in interface ImageClassifier<Planar<GrayF32>>
      best fit category
    • getAllResults

      public List<ImageClassifier.Score> getAllResults()
      Description copied from interface: ImageClassifier
      Returns a list of all the likely categories for the image. What is likely is implementation dependent. Each category should be included at least once and might not be included at all.
      Specified by:
      getAllResults in interface ImageClassifier<Planar<GrayF32>>
      List of categories and scores
    • getCategories

      public List<String> getCategories()
      Description copied from interface: ImageClassifier
      Returns a list of all the possible categories that a scene can be classified as
      Specified by:
      getCategories in interface ImageClassifier<Planar<GrayF32>>
      Names of categories
    • getImageRgb

      public Planar<GrayF32> getImageRgb()