Multi-Threaded Weka segmentation

Hi,

I am trying to segment a folder full of movies and Weka has give me excellent results. However, it seems to slow down when instead of get the probability maps manually, I use a script. This is the code:

from ij import IJ, ImagePlus
from ij.plugin import Duplicator, ImageCalculator
from ij.io import FileSaver, DirectoryChooser
from trainableSegmentation import WekaSegmentation
from imagescience.feature import Edges
from imagescience.image import Image as FJimage
import time
import os

# Load classifier
weka = WekaSegmentation()
weka.loadClassifier( modelPath.getCanonicalPath() )

for f in inputDir.listFiles():

	print(f.getName())
	imp = IJ.openImage(os.path.join(inputDir.getCanonicalPath(), f.getName()))
	# Transformations
	IJ.run(imp, "Gaussian Blur...", "sigma=1 stack");
	IJ.run(imp, "FeatureJ Edges", "compute smoothing=1.0 lower=[] higher=[]")
	IJ.run(imp, "8-bit", "")
	edges = IJ.getImage() 

	# Classify image
	start_time = time.time()
	
	result = weka.applyClassifier( edges, 8, True )
	result = result.getProcessor().duplicate()
	result = ImagePlus("Bacteria_Prob_map", result)

	Final = ImageCalculator().run("Divide create 32-bit stack", imp, result)
	print(time.time() - start_time)

	outputFileName = "Test" + "_CELLS.tiff"  
	FileSaver(Final).saveAsTiff(outputFolder.getPath() + "/"+ outputFileName)
	IJ.run(Final, "Close All", "")

I suspect the problem is related with the number of cores as the log window shows:

Creating features for slice n...
Filtering feature stack by selected attributes...
Classifying slice n in 1 thread(s)...
Classifying whole image data took: 11699ms

I also tried setting the core number to 0, that is, auto-detect, but the result is the same. Any idea why with the user interface window is faster than running as script?

Thank you