Skip to content
Snippets Groups Projects

Patch stack one channel

Merged Christopher Randolph Rhodes requested to merge patch_stack_one_channel into staging
3 files
+ 18
3
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -3,7 +3,7 @@ from math import floor
import numpy as np
from model_server.base.accessors import GenericImageDataAccessor, InMemoryDataAccessor
from model_server.base.accessors import GenericImageDataAccessor, InMemoryDataAccessor, PatchStack
class Model(ABC):
@@ -88,6 +88,16 @@ class InstanceSegmentationModel(ImageToImageModel):
if not img.shape == mask.shape:
raise InvalidInputImageError('Expect input image and mask to be the same shape')
def label_patch_stack(self, img: PatchStack, mask: PatchStack, **kwargs):
"""
Iterative over a patch stack, call inference on each patch
:return: PatchStack of same shape in input
"""
res_data = np.zeros(img.shape, dtype='uint16')
for i in range(0, img.count): # interpret as PYXCZ
res_data[i, :, :, :, :] = self.label_instance_class(img.iat(i), mask.iat(i), **kwargs).data
return PatchStack(res_data)
class DummySemanticSegmentationModel(SemanticSegmentationModel):
Loading