Skip to content

MODEL.N_CLASSES error with 2 training classes #124

@quantixed

Description

@quantixed

I am using BiaPy via CLI to do an Image Classification task. For 2D or 3D workflows, I can train BiaPy and make predictions when the number of subfolders in train/ and test/ is equal.

If I have 3 classes in training data and 3 subfolders of test data it works and I get results. However, if I drop to 2 training classes and 2 test I get an error.

ValueError: Found number of classes (2) and 'MODEL.N_CLASSES' (1) must match

although it says after Initializing Classification_Workflow that it has found 2 classes.

If I use 2 training classes and have only 1 test it doesn't work either but gives a different error:

ValueError: Found number of classes (1) and 'MODEL.N_CLASSES' (2) must match

in both cases, MODEL.N_CLASSES is specified as 2 in the yaml. This is testing with a 3D workflow, but I get the same error in the first case with 2D (I haven't tried the second). Also, I get similar errors whether DATA.TEST.LOAD_GT is set to True or False.

Is 2 training classes somehow unstable? Should I have 3 or more?

In my case I have two classes of interest (I could make 3 or maximally 4) for training. I have around 10 conditions for which I would like BiaPy to predict the classification. I understand that the number of train and test folders needs to be equal but what is the best way to go about this?

Finally, I am posting here because it seems like this is an issue. If it's more of a usage question, I am happy to repost on forum.image.sc! Thanks in advance!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions