@@ -61,63 +61,20 @@ def output_specs(self) -> List[OutputTensor]:
6161 """
6262 ...
6363
64- # todo: replace all uses of properties below with 'input_specs' and 'output_specs'
65- @property
66- @abc .abstractmethod
67- def input_shape (self ) -> List [List [Tuple [str , int ]]]:
68- """
69- Named input dimensions
70- """
71- ...
72-
73- @property
74- @abc .abstractmethod
75- def output_axes (self ) -> List [Tuple [str , ...]]:
76- """
77- Output axes of this pipeline
78- Note: one character axes names
79- """
80- ...
81-
82- @property
83- @abc .abstractmethod
84- def output_shape (self ) -> List [Union [List [Tuple [str , float ]], NamedImplicitOutputShape ]]:
85- """
86- Named output dimensions. Either explicitly defined or implicitly in relation to an input
87- """
88- ...
89-
90- @property
91- @abc .abstractmethod
92- def halo (self ) -> List [List [Tuple [str , int ]]]:
93- """
94- Size of output borders that have unreliable data due to artifacts (after application of postprocessing)
95- """
96- ...
97-
9864
9965class _PredictionPipelineImpl (PredictionPipeline ):
10066 def __init__ (
10167 self ,
10268 * ,
10369 name : str ,
10470 bioimageio_model : Model ,
105- input_axes : Sequence [str ],
106- input_shape : Sequence [List [Tuple [str , int ]]],
107- output_axes : Sequence [str ],
108- output_shape : Sequence [Union [List [Tuple [str , int ]], NamedImplicitOutputShape ]],
109- halo : Sequence [List [Tuple [str , int ]]],
11071 preprocessing : Sequence [Transform ],
11172 model : ModelAdapter ,
11273 postprocessing : Sequence [Transform ],
11374 ) -> None :
11475 self ._name = name
11576 self ._input_specs = bioimageio_model .inputs
11677 self ._output_specs = bioimageio_model .outputs
117- self ._input_shape = input_shape
118- self ._output_axes = [tuple (axes ) for axes in output_axes ]
119- self ._output_shape = output_shape
120- self ._halo = halo
12178 self ._preprocessing = preprocessing
12279 self ._model : ModelAdapter = model
12380 self ._postprocessing = postprocessing
@@ -134,22 +91,6 @@ def input_specs(self):
13491 def output_specs (self ):
13592 return self ._output_specs
13693
137- @property
138- def input_shape (self ):
139- return self ._input_shape
140-
141- @property
142- def output_axes (self ):
143- return self ._output_axes
144-
145- @property
146- def output_shape (self ):
147- return self ._output_shape
148-
149- @property
150- def halo (self ):
151- return self ._halo
152-
15394 def predict (self , * input_tensors : xr .DataArray ) -> List [xr .DataArray ]:
15495 """Predict input_tensor with the model without applying pre/postprocessing."""
15596 return self ._model .forward (* input_tensors )
@@ -216,7 +157,6 @@ def create_prediction_pipeline(
216157 bioimageio_model = bioimageio_model , devices = devices , weight_format = weight_format
217158 )
218159
219- input_axes : List [str ] = []
220160 named_input_shape : List [List [Tuple [str , int ]]] = []
221161 preprocessing : List [Transform ] = []
222162 for ipt in bioimageio_model .inputs :
@@ -227,42 +167,20 @@ def create_prediction_pipeline(
227167 except AttributeError :
228168 input_shape = ipt .shape
229169
230- input_axes .append (ipt .axes )
231170 named_input_shape .append (list (zip (ipt .axes , input_shape )))
232171 preprocessing_spec = [] if ipt .preprocessing is missing else ipt .preprocessing .copy ()
233172 preprocessing .append (make_preprocessing (preprocessing_spec ))
234173
235- output_axes : List [str ] = []
236- named_output_shape : List [Union [List [Tuple [str , int ]], NamedImplicitOutputShape ]] = []
237174 named_halo : List [List [Tuple [str , int ]]] = []
238175 postprocessing : List [Transform ] = []
239176 for out in bioimageio_model .outputs :
240- output_axes .append (out .axes )
241- if isinstance (out .shape , list ): # explict output shape
242- named_output_shape .append (list (zip (out .axes , out .shape )))
243- elif isinstance (out .shape , ImplicitOutputShape ):
244- named_output_shape .append (
245- NamedImplicitOutputShape (
246- reference_input = out .shape .reference_tensor ,
247- scale = list (zip (out .axes , out .shape .scale )),
248- offset = list (zip (out .axes , out .shape .offset )),
249- )
250- )
251- else :
252- raise TypeError (f"Unexpected type for output shape: { type (out .shape )} " )
253-
254177 named_halo .append (list (zip (out .axes , out .halo or [0 for _ in out .axes ])))
255178 postprocessing_spec = [] if out .postprocessing is missing else out .postprocessing .copy ()
256179 postprocessing .append (make_postprocessing (postprocessing_spec ))
257180
258181 return _PredictionPipelineImpl (
259182 name = bioimageio_model .name ,
260183 bioimageio_model = bioimageio_model ,
261- input_axes = input_axes ,
262- input_shape = named_input_shape ,
263- output_axes = output_axes ,
264- output_shape = named_output_shape ,
265- halo = named_halo ,
266184 preprocessing = preprocessing ,
267185 model = model_adapter ,
268186 postprocessing = postprocessing ,
0 commit comments