Skip to content

Commit

Permalink
Call detect_dimension_order and save to redis in both mesmer and segm…
Browse files Browse the repository at this point in the history
…entation.

Saved as Comma-separated string as "dim_order".
  • Loading branch information
willgraf committed May 10, 2021
1 parent cf57164 commit d6a8938
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redis_consumer/consumers/mesmer_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def _consume(self, redis_hash):
scale = hvals.get('scale', '')
scale = self.get_image_scale(scale, image, redis_hash)

# detect dimension order and add to redis
dim_order = self.detect_dimension_order(image, model_name, model_version)
self.update_key(redis_hash, {
'dim_order': ','.join(dim_order)
})

# Validate input image
if hvals.get('channels'):
channels = [int(c) for c in hvals.get('channels').split(',')]
Expand Down
1 change: 1 addition & 0 deletions redis_consumer/consumers/mesmer_consumer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test__consume(self, mocker, redis_client):
mocker.patch.object(consumer, 'get_grpc_app', lambda *x, **_: mock_app)
mocker.patch.object(consumer, 'get_image_scale', lambda *x, **_: 1)
mocker.patch.object(consumer, 'validate_model_input', lambda *x, **_: x[0])
mocker.patch.object(consumer, 'detect_dimension_order', lambda *x, **_: 'YXC')

test_hash = 'some hash'

Expand Down
1 change: 1 addition & 0 deletions redis_consumer/consumers/segmentation_consumer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def test__consume(self, mocker, redis_client):
mocker.patch.object(consumer, 'get_image_scale', lambda *x, **_: 1)
mocker.patch.object(consumer, 'get_image_label', lambda *x, **_: 1)
mocker.patch.object(consumer, 'validate_model_input', lambda *x, **_: True)
mocker.patch.object(consumer, 'detect_dimension_order', lambda *x, **_: 'YXC')

test_hash = 'some hash'

Expand Down

0 comments on commit d6a8938

Please sign in to comment.