From eea5aeae5f38b7e244a48c88ac59820ab60baa17 Mon Sep 17 00:00:00 2001 From: cpavelchek Date: Fri, 26 Jun 2020 18:46:33 -0700 Subject: [PATCH] trying to debug --- redis_consumer/consumers/mibi_consumer.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/redis_consumer/consumers/mibi_consumer.py b/redis_consumer/consumers/mibi_consumer.py index afce214a..93ee77d5 100644 --- a/redis_consumer/consumers/mibi_consumer.py +++ b/redis_consumer/consumers/mibi_consumer.py @@ -108,8 +108,9 @@ def _consume(self, redis_hash): self.logger.debug('Image shape after scaling is: %s', image.shape) # Preprocess image - if image.ndim < 4: - image = np.expand_dims(image, 0) + # Image must be of shape (batch, x, y, channels), but scaling + # eliminates batch dim, so we recreate it here + image = np.expand_dims(image, 0) image = processing.phase_preprocess(image) image = np.squeeze(image) self.logger.debug('Shape after phase_preprocess is: %s', image.shape) @@ -118,7 +119,12 @@ def _consume(self, redis_hash): self.update_key(redis_hash, {'status': 'predicting'}) image = self.predict(image, model_name, model_version) - print('image type is: ', type(image)) + if isinstance(image, list): + print('Predictions are as list, length is: ', len(image)) + + else: + print('Predictions are instead type: ', type(image)) + print('Size of ', type(image), ' is: ', image.shape) # Post-process model results self.update_key(redis_hash, {'status': 'post-processing'}) @@ -126,7 +132,7 @@ def _consume(self, redis_hash): if len(image) == 4: image = np.squeeze(processing.deep_watershed_mibi(image)) else: - self.logger.warning('Output length was %s, should have been 4') + self.logger.warning('Output length was %s, expected 4') image = np.asarray(image) else: image = image