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.io.FileSaver;
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() );
      	println(image);
        if( image != null )
        {
			print("image is not null")
            //IJ.run("8-bit");
            //IJ.setThreshold(71, 107);
            //IJ.setOption("BlackBackground", false);
            //IJ.run("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 );

            //IJ.run("8-bit");
            //IJ.setAutoThreshold("Default")
            //IJ.run("Convert to Mask");
            //IJ.run("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";
            println(outputFileName);
            //outFileName = "output.tif"
            new FileSaver( result ).saveAsTiff( outputDir.getPath() + File.separator + outputFileName );

            // force garbage collection (important for large images)
            result = null;
            image = null;
            System.gc();
        }
    }
}
// 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(ScriptBytecodeAdapter.java:65)
	at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:341)
	at Script23.run(Script23.groovy:61)
	at org.scijava.plugins.scripting.groovy.GroovyScriptEngine.eval(GroovyScriptEngine.java:303)
	at org.scijava.plugins.scripting.groovy.GroovyScriptEngine.eval(GroovyScriptEngine.java:122)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)