Beanshell Error when using Weka Segmentation in Fiji

I am trying to run batch mode process on multiple frames using weka segmentation in fiji in order to perform image analysis on cells and track them each frame but I continue to get errors.

Beanshell Code:

#@ File (label="Input directory", description="Select the directory with input images", style="directory") inputDir
#@ File (label="Output directory", description="Select the output directory", style="directory") outputDir
#@ File (label="Weka model", description="Select the Weka model to apply") modelPath
#@ String(label="Result mode",choices={"Labels","Probabilities"}) resultMode

import trainableSegmentation.WekaSegmentation;
import trainableSegmentation.utils.Utils;
import ij.IJ;
import ij.ImagePlus;

// starting time
startTime = System.currentTimeMillis();

// caculate probabilities?
//getProbs = resultMode.equals( "Probabilities" );

// create segmentator
segmentator = new WekaSegmentation();
// load classifier
segmentator.loadClassifier( modelPath.getCanonicalPath() );

// get list of input images
listOfFiles = inputDir.listFiles();
for ( i = 0; i < listOfFiles.length; i++ )
    // process only files (do not go into sub-folders)
    if( listOfFiles[ i ].isFile() )
        // try to read file as image
        image = IJ.openImage( listOfFiles[i].getCanonicalPath() );
        if( image != null )
			print("image is not null")
            //IJ.setThreshold(71, 107);
            //IJ.setOption("BlackBackground", false);
            //"Convert to Mask");

            // apply classifier and get results (0 indicates number of threads is auto-detected)
            //result = segmentator.applyClassifier( image, 0, getProbs );
			println("classifier is applied");
            //result = segmentator.applyClassifier( image );

            //"Convert to Mask");
            //"Analyze Particles...", "  show=Outlines display clear");
            //saveAs("Results", inputDirectory+substring(filename, 0, lengthOf(filename)-4)+".csv");

            //if( !getProbs )
            // assign same LUT as in GUI
            //result.setLut( Utils.getGoldenAngleLUT() );

            // save result as TIFF in output folder
            outputFileName = listOfFiles[ i ].getName().replaceFirst('[.][^.]+$', "") + ".tif";
            //outFileName = "output.tif"
            new FileSaver( result ).saveAsTiff( outputDir.getPath() + File.separator + outputFileName );

            // force garbage collection (important for large images)
            result = null;
            image = null;
// print elapsed time
estimatedTime = System.currentTimeMillis() - startTime;
IJ.log( "** Finished processing folder in " + estimatedTime + " ms **" );

These are the errors that I continue to get.

Started new_groovy.groovy at Mon Apr 19 10:17:43 EDT 2021
groovy.lang.MissingPropertyException: No such property: result for class: Script23
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(
	at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(
	at org.scijava.plugins.scripting.groovy.GroovyScriptEngine.eval(
	at org.scijava.plugins.scripting.groovy.GroovyScriptEngine.eval(
	at javax.script.AbstractScriptEngine.eval(
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$