Skip to content
David Wood edited this page Apr 11, 2022 · 1 revision

Maximo Visual Inspection

Maximo Visual Inspection (MVI) is a cloud-based service to curate images and build image classification and object detection models. An MVIClassifier Java class has been implemented using the MVI REST APIs to make use of the image classification capabilities in MVI. Training includes

  1. Converting spectrograms to normalized PNG images
  2. Uploading labeled PNG images to MVI to create an instance-specific data set
  3. Training of an image classification ("cic") model on the created data set.
  4. The trained model is downloaded/exported into the instance for later upload/import.
  5. If/when classification is requested (perhaps after loading a saved MVI model), the trained model is imported if necessary and then deployed on the MVI server.
  6. When the JVM exits normally, the MVIClassifier will undeploy any deployed models and optionally, remove the trained model and data set.

Note: Care should be taken to avoid abnormally causing the JVM to exit (i.e. Ctl-C). In this case, the MVIClassifier is not given the chance to clean up the server (datasets, trained and/or deployed models). This can leave zombie data sets and trained and/or deployed models on the MVI server.

Usage

The MVI classifier instance is available as a model named mvi and can be used in the workbench or the CLI tools using this identifier. However, prior to using the MVI model you must indicate the REST endpoint for the MVI server using environment variables as follows:

  • VAPI_TOKEN - this contains an API key that can be obtained after logging into the MVI server with your assigned user id.
  • VAPI_BASE_URI - the full URI pointing to the base of the REST API at the MVI server.
  • VAPI_HOST - alternatively to VAPI_BASE_URI you may specify just the host name of the server. In the case, you may also set the port using the VAPI_PORT environment variable.

So, if the MVI server is at myserver.acme.com you can do the following

After having set up your environment variables, you may begin using the MVI server like any other model. For example

evaluate -model mvi -sounds mysounds -label somelabel

With the default model definition, training times seems to be about 20% of the total length of the training data. To log progress, you may add -Dmvi.client.verbose=true to your JAVA_OPTIONS environment variable.

Configuration

Configuration of the MVI model for workbench or CLI usage makes use of the JavaScript below to create the MVIClassifier instance. (Use the ls-models mvi to produce the listing below). The JavaScript enables the setting of feature extraction and processing as with other models, but also allows optional data augmentation and the ability to preserve the model and data sets for each MVIClassifier instance created. Initial investigation of noise and gaussian blur on the Yaskawa data did not show any benefit, but investigation with larger data sets might prove otherwise. Note that augmentation can significantly increase training times.

    var preserveModel=false
    var noiseCount=5
    var noiseMax=0
    var motionCount=5
    var motionMax=0
    var gaussianCount=5
    var gaussianMax=0
    var sharpnessCount=5
    var sharpnessMax=0
    // Feature parameters
    var fe;
    var fp = null;
    var resamplingRate=44100
    var minFreq=20
    var maxFreq=20000
    var windowSizeMsec=40
    var windowShiftMsec=windowSizeMsec * 50/100.0
    var featureLen=128
    var featureExtractor='LogMel'
    var normalizeProcessor='false'
    var deltaProcessor='false'
    // Define the feature extractor
    if (featureExtractor === 'FFT') {
      fe = new FFTFeatureExtractor(resamplingRate, minFreq, maxFreq, false, true, featureLen)
    } else if (featureExtractor === 'LogMel') {
        fe = new LogMelFeatureExtractor(resamplingRate, featureLen, minFreq, maxFreq, 0)
    } else {    // MFCC
      fe = new MFCCFeatureExtractor(resamplingRate, featureLen, minFreq, maxFreq, featureLen);
    }
    // Define the feature processor
    if (normalizeProcessor === 'true')
        fp = new NormalizingFeatureProcessor(true,true,true,true)
    if (deltaProcessor === 'true')  {
      var dfp = new DeltaFeatureProcessor(2,[1,1,1]);
        if (fp != null)
            fp = new PipelinedFeatureProcessor(fp,dfp)
        else
            fp = dfp
    }
    // Build the feature gram extractor
    var fge = new FeatureGramExtractor(windowSizeMsec, windowShiftMsec, fe, fp);
    // Finally, create the classifier
    // Expect VAPI_HOST, VAPI_TOKEN and VAPI_PORT if not using 443.
    var builder = new MVIClassifierBuilder()
    builder.setFeatureGramExtractor(fge)
          .setPreserveModel(preserveModel)
                // .setModelName(modelName)
    // The augmentation counts are currently ignored by MVI and always assume a value of 5 in the server.
    // So for now, use a non-zero max to control whether an augmentation is enabled.
    if (noiseMax > 0)
          builder.addNoise(noiseCount, noiseMax)
    if (motionMax > 0)
          builder.addMotionBlur(motionCount, motionMax)
    if (gaussianMax > 0)
          builder.addGaussianBlur(gaussianCount, gaussianMax)
    if (sharpnessMax > 0)
          builder.addSharpness(sharpnessCount, sharpnessMax)
     classifier = builder.build()
Clone this wiki locally