-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Special handling for flow cytometer images (#41)
* add a stub function to normalise flow cytometer images * normalise the flow cytometer image. it's still greyscale * heavy-handed conversion to 3 band, will it work for display? * more test coverage, small bug related to model input data type
- Loading branch information
Showing
9 changed files
with
109 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cluster: | ||
n_clusters: 5 | ||
|
||
collection: untagged-images-lana | ||
collection: test-upload-alba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
|
||
from torch import Tensor | ||
import torch | ||
from PIL import Image | ||
from cyto_ml.models.utils import flat_embeddings | ||
from cyto_ml.data.image import load_image | ||
from cyto_ml.data.image import load_image, normalise_flowlr, prepare_image | ||
|
||
|
||
def test_embeddings(scivision_model, single_image): | ||
features = scivision_model(load_image(single_image)) | ||
def test_embeddings(resnet_model, single_image, greyscale_image): | ||
features = resnet_model(load_image(single_image)) | ||
|
||
assert isinstance(features, Tensor) | ||
assert isinstance(features, torch.Tensor) | ||
|
||
embeddings = flat_embeddings(features) | ||
|
||
assert len(embeddings) == features.size()[1] | ||
|
||
features = resnet_model(load_image(greyscale_image)) | ||
|
||
assert isinstance(features, torch.Tensor) | ||
|
||
embeddings = flat_embeddings(features) | ||
assert len(embeddings) == features.size()[1] | ||
|
||
|
||
def test_normalise_flowlr(greyscale_image): | ||
# Normalise first, hand the tensorize function an array | ||
image = normalise_flowlr(Image.open(greyscale_image)) | ||
prepared_image = prepare_image(image) | ||
|
||
assert torch.all((prepared_image >= 0.0) & (prepared_image <= 1.0)) | ||
|
||
# Do it all at once | ||
prepared_image = prepare_image(Image.open(greyscale_image)) | ||
|
||
assert torch.all((prepared_image >= 0.0) & (prepared_image <= 1.0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters