Skip to content
Snippets Groups Projects
Commit a6e13287 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Ilastik pixel classifier calls batch mode for performance reasons; removed...

Ilastik pixel classifier calls batch mode for performance reasons; removed handling of ilastik.applets.featureSelection.opFeatureSelection.FeatureSelectionConstraintError; unsure if this remains a risk
parent 50d37fc0
No related branches found
No related tags found
No related merge requests found
......@@ -148,17 +148,16 @@ class IlastikPixelClassifierModel(IlastikModel, SemanticSegmentationModel):
"""
Iterative over a patch stack, call inference separately on each cropped patch
"""
from ilastik.applets.featureSelection.opFeatureSelection import FeatureSelectionConstraintError
nc = len(self.labels)
data = np.zeros((img.count, *img.hw, nc, img.nz), dtype=float) # interpret as PYXCZ
for i in range(0, img.count):
sl = img.get_slice_at(i)
try:
data[i][sl[0], sl[1], :, sl[3]] = self.infer(img.iat(i, crop=True)).data
except FeatureSelectionConstraintError: # occurs occasionally on small patches
continue
return PatchStack(data)
dsi = [
{
'Raw Data': self.PreloadedArrayDatasetInfo(
preloaded_array=vigra.taggedView(patch, 'yxcz'))
} for patch in img.get_list()
]
pxmaps = self.shell.workflow.batchProcessingApplet.run_export(dsi, export_to_array=True) # [z x h x w x n]
yxcz = [np.moveaxis(pm, [1, 2, 3, 0], [0, 1, 2, 3]) for pm in pxmaps]
return PatchStack(yxcz)
def label_pixel_class(self, img: GenericImageDataAccessor, **kwargs):
pxmap = self.infer(img)
......
......@@ -144,7 +144,7 @@ class TestIlastikPixelClassification(unittest.TestCase):
self.assertEqual(mask.count, acc.count)
pxmap = self.model.infer_patch_stack(acc)
self.assertEqual(pxmap.dtype, float)
self.assertEqual(pxmap.dtype, 'float32')
self.assertEqual(pxmap.chroma, len(self.model.labels))
self.assertEqual(pxmap.hw, acc.hw)
self.assertEqual(pxmap.nz, acc.nz)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment