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

Prototyped object classifier with segmentation

parent 5dc646d9
No related branches found
No related tags found
No related merge requests found
......@@ -106,3 +106,35 @@ class IlastikObjectClassifierFromPixelPredictionsModel(IlastikImageToImageModel)
[0, 1, 2, 3]
)
return InMemoryDataAccessor(data=yxcz), {'success': True}
class IlastikObjectClassifierFromSegmentationModel(IlastikImageToImageModel):
model_id = 'ilastik_object_classification_from_segmentation'
@staticmethod
def get_workflow():
from ilastik.workflows.objectClassification.objectClassificationWorkflow import ObjectClassificationWorkflowBinary
return ObjectClassificationWorkflowBinary
def infer(self, input_img: GenericImageDataAccessor, segmentation_img: GenericImageDataAccessor) -> (np.ndarray, dict):
assert segmentation_img.is_mask()
tagged_input_data = vigra.taggedView(input_img.data, 'yxcz')
tagged_seg_data = vigra.taggedView(segmentation_img.data, 'yxcz')
dsi = [
{
'Raw Data': self.PreloadedArrayDatasetInfo(preloaded_array=tagged_input_data),
'Segmentation Image': self.PreloadedArrayDatasetInfo(preloaded_array=tagged_seg_data),
}
]
obmaps = self.shell.workflow.batchProcessingApplet.run_export(dsi, export_to_array=True) # [z x h x w x n]
assert (len(obmaps) == 1, 'ilastik generated more than one object map')
yxcz = np.moveaxis(
obmaps[0],
[1, 2, 3, 0],
[0, 1, 2, 3]
)
return InMemoryDataAccessor(data=yxcz), {'success': True}
......@@ -199,3 +199,5 @@ class TestIlastikOverApi(TestServerBaseClass):
}
)
self.assertEqual(resp_infer.status_code, 200, resp_infer.content.decode())
# TODO: test IlastikObjectClassifierFromSegmentationModel when a test model is complete
\ No newline at end of file
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