Scripting Trainable Weka Segmentation: apply classifier to all images in folder

Hi, I am new to weka and Image J and have run into some issues. I am trying to use the beanshell code on the Image J website to apply a classifier to images in a folder (Scripting the Trainable Weka Segmentation - ImageJ). Unfortunately, when I run it I get an error box that pops up saying “Could not apply classifier!”. The classifier works on its own when I try to run it using the GUI interface. Any suggestions is much appreciated.