Image Classification

The parameters are the following:

type

object

properties

  • image_input

../common/image_input.yml

  • classes

Path to the file with detected classes

type

string

additionalProperties

False

The OpenAPI definition of the HTTP interface is the following:

swagger: "2.0"
info:
  description: "Image classification aiapp."
  version: "0.0.1"
  title: "Image Classification"
paths:
  /inference:
    post:
      summary: "Perform inference on image"
      description: ""
      consumes:
      - "image/jpeg"
      - "image/png"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "body"
        description: "Image to analyze"
        required: true
        schema:
          type: string
          format: binary
      responses:
        200:
          description: "Success"
          schema:
            "$ref": 'results.yml'

The C++ interface definition is the following:

///
/// Ai-app interface for image classification
///
/// \copyright 2018 NVISO SA. All rights reserved.
/// \license This project is released under the XXXXXX License.
///

#pragma once

#include "image_based.hpp"

namespace lpdnn {
namespace ai_app {

/// Image classification AiApp
class Image_classification : virtual public Image_based {
 public:
  struct Result {
    bool success{};
    std::vector<float> confidence;
  };

  /// Perform inference.
  virtual Result execute(const Image& input, const std::vector<lpdnn::ai_app::Blob>& additional_inputs) = 0;
  virtual Result execute(const Image& input) = 0;

  /// @return Names of classes
  virtual std::vector<std::string> classes() = 0;

  /// @return our aiapp class id
  const char* interface_name() const override { return ai_interface_name; }
  static constexpr char const* ai_interface_name = "com_bonseyes/interfaces#image_classification";
  using Ai_interface_class = Image_classification;
};

}  // namespace ai_app
}  // namespace lpdnn

The default JSON ground truth schema is the following:

Image Classification AI App ground truth

Index of the class to which the image belongs to

type

integer

The default JSON result serialization is the following:

Image Classification AI App Result

type

object

properties

  • success

type

boolean

  • confidence

type

array

items

type

number

additionalProperties

False