Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in load_classifier in most recent version 3.3.2 vs 3.3.1 #74

Closed
TylerJang opened this issue May 18, 2022 · 16 comments · Fixed by #81
Closed

Issue in load_classifier in most recent version 3.3.2 vs 3.3.1 #74

TylerJang opened this issue May 18, 2022 · 16 comments · Fixed by #81
Assignees

Comments

@TylerJang
Copy link

TylerJang commented May 18, 2022

Hi,

During the most recent version update, we have noticed that using load_classifier in the provided example Beanshell code from https://imagej.net/plugins/tws/scripting titled Example: apply classifier to all images in folder no longer works. Going to an older version of TWS, such as 3.3.1, fixes the issue and we notice that the version this error consistently occurs is in the most recent version 3.3.2.

When the following code executes, it returns the pop-up dialog warning "Could not apply Classifier!" for each image.

segmentator.loadClassifier( modelPath.getCanonicalPath() ); ... result = segmentator.applyClassifier(image, tilesPerDim, 0, true);

We suspect that the issue is in loading the classifier, but the error window is generated when applying the classifier.

We are using ImageJ version v1.53q through the Fiji distribution on Windows 10/Windows 7.

Thank you for your time.

@tkataras
Copy link

To provide a bit more visual context for this issue, this is the popup error dialogue box:
image

The log output at time of error looks like this:
image

the Imagej macro Window error report:

Started run tws on folder.bsh at Wed May 18 13:34:28 PDT 2022
Sourced file: inline evaluation of: ``     import trainableSegmentation.WekaSegmentation; import trainableSegmentation . . . '' : Method Invocation segmentator.applyClassifier : at Line: 34 : in file: inline evaluation of: ``     import trainableSegmentation.WekaSegmentation; import trainableSegmentation . . . '' : segmentator .applyClassifier ( image , 0 , getProbs ) 


Target exception: java.lang.NullPointerException

and the FIJI console window:
image

Thank you again for your time.

@Katie-Sparx
Copy link

Hi, I am having the exact same issue. Does anyone know of a workaround?

@TylerJang
Copy link
Author

Our solution was to revert to version 3.3.1 of TWS which fixed it for us has consistently been fine since we made that change.

@Katie-Sparx
Copy link

Within ImageJ, how do you revert back to the previous version? - sorry, I'm a bit new to this.

@TylerJang
Copy link
Author

You can uninstall and reinstall ImageJ to an older version. I don't believe you can do it within the application itself naturally since it is changing the version of ImageJ itself. I believe this is the version we reverted to https://downloads.imagej.net/fiji/archive/20201104-1356/

@iarganda iarganda self-assigned this Mar 10, 2023
@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/scripting-trainable-weka-segmentation-apply-classifier-to-all-images-in-folder/53153/7

@mlt
Copy link
Contributor

mlt commented Jan 23, 2024

This fixes it for me. Perhaps it should/could be cleaned up as I don't think it is the right place for this. It just makes it work.

diff --git a/src/main/java/trainableSegmentation/WekaSegmentation.java b/src/main/java/trainableSegmentation/WekaSegmentation.java
index 306feae..efd8f3a 100644
--- a/src/main/java/trainableSegmentation/WekaSegmentation.java
+++ b/src/main/java/trainableSegmentation/WekaSegmentation.java
@@ -7443,7 +7443,7 @@ public class WekaSegmentation {
 	public void setFeaturesDirty()
 	{
 		updateFeatures = true;
-		if( isProcessing3D )
+		if( isProcessing3D ||  null == featureStackArray)
 			return;
 		// Set feature stacks belonging to slices with traces
 		// to be updated during training and not test

mlt added a commit to mlt/Trainable_Segmentation that referenced this issue Jan 24, 2024
mlt added a commit to mlt/Trainable_Segmentation that referenced this issue Jan 24, 2024
while loading a classifier

This fixes fiji#74
@phisanti
Copy link

@mlt Does it mean that we have to do our own compile of trainable weka or will it be released as new jar soon?

@mlt
Copy link
Contributor

mlt commented Jan 28, 2024

I don't know. I'm just a fellow user and not a project member. It is pretty easy to build the jar file with Maven though.

@phisanti
Copy link

@mlt, if your code manages to solve the issue, would you mind opening a PR, and then I can try to contact Ignazio for the merge? Or I can also try to open the PR. I am also happy to open the PR if you let me know the changes.

@phisanti
Copy link

Maybe @iarganda can chip in, since the fix for the bug is quite simple and it seems already implemented?

@iarganda
Copy link
Collaborator

iarganda commented Jan 29, 2024 via email

mlt added a commit to mlt/Trainable_Segmentation that referenced this issue Jan 30, 2024
mlt added a commit to mlt/Trainable_Segmentation that referenced this issue Jan 30, 2024
while loading a classifier

This fixes fiji#74
@phisanti
Copy link

phisanti commented Feb 1, 2024

@iarganda let us know when you push the PR and the update is available in the update manager

@phisanti
Copy link

phisanti commented Feb 8, 2024

@iarganda, I have just tested (see https://github.com/phisanti/Trainable_Segmentation) the solution proposed by user @mlt and it seems to work fine. Maybe merging the PR #81 will close the issue and then it can be pushed at the imageJ update site so everyone can benefit from it.

@mlt
Copy link
Contributor

mlt commented Feb 8, 2024

What is the situation with PMML in TWS? Is it used by anyone? I have not seen that capability advertised anywhere. How would one produce PMML given TWS generated features?
I mean I can clean up the code further while at it. Alternatively, I can make the patch less invasive. It is just some code duplication that bothers me along with JUnit testing that uses file system (hence 6ac35bb but I'm not sure whether to keep temporary file use with JUnit).

mlt added a commit to mlt/Trainable_Segmentation that referenced this issue Feb 16, 2024
mlt added a commit to mlt/Trainable_Segmentation that referenced this issue Feb 16, 2024
while loading a classifier

This fixes fiji#74
@phisanti
Copy link

@iarganda, the user @mlt, and I already tested that the code changes work and opened PR. It would be helpful if you could accept the changes; that way, my colleagues can install the Weka plugin directly from the ImageJ plugin hub instead of downloading the version from my Git Hub. We understand that you, like everyone, have limited time to dedicate to open-source projects. If it is so, you have the option to give admin rights to other users. That will help keep the project alive, which otherwise might fade away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants