Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mednet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
medai
software
mednet
Commits
45f95973
Commit
45f95973
authored
1 year ago
by
Daniel CARRON
Browse files
Options
Downloads
Patches
Plain Diff
[test] Test loaded images against reference histograms
parent
05853dc7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!18
Update tests
,
!16
Make square centre-padding a model transform
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/test_indian.py
+28
-0
28 additions, 0 deletions
tests/test_indian.py
tests/test_montgomery.py
+28
-0
28 additions, 0 deletions
tests/test_montgomery.py
tests/test_shenzhen.py
+28
-0
28 additions, 0 deletions
tests/test_shenzhen.py
with
84 additions
and
0 deletions
tests/test_indian.py
+
28
−
0
View file @
45f95973
...
...
@@ -7,9 +7,12 @@ dataset A/dataset B) dataset.
"""
import
importlib
import
json
import
pytest
from
PIL
import
Image
def
id_function
(
val
):
if
isinstance
(
val
,
dict
):
...
...
@@ -95,3 +98,28 @@ def test_loading(database_checkers, name: str, dataset: str):
expected_num_labels
=
1
,
)
limit
-=
1
@pytest.mark.skip_if_rc_var_not_set
(
"
datadir.indian
"
)
def
test_loaded_image_quality
(
datadir
):
datamodule
=
importlib
.
import_module
(
"
.default
"
,
"
mednet.config.data.indian
"
).
datamodule
datamodule
.
model_transforms
=
[]
datamodule
.
setup
(
"
predict
"
)
loader
=
datamodule
.
splits
[
"
train
"
][
0
][
1
]
first_sample
=
datamodule
.
splits
[
"
train
"
][
0
][
0
][
0
]
image_data
=
loader
.
sample
(
first_sample
)[
0
].
numpy
()[
0
,
:,
:
]
# PIL expects grayscale to not have any leading dim
img
=
Image
.
fromarray
(
image_data
,
mode
=
"
L
"
)
histogram
=
img
.
histogram
()
reference_histogram_file
=
str
(
datadir
/
"
histogram_indian.json
"
)
with
open
(
reference_histogram_file
)
as
i_f
:
ref_histogram
=
json
.
load
(
i_f
)[
"
histogram
"
]
assert
histogram
==
ref_histogram
This diff is collapsed.
Click to expand it.
tests/test_montgomery.py
+
28
−
0
View file @
45f95973
...
...
@@ -4,9 +4,12 @@
"""
Tests for Montgomery dataset.
"""
import
importlib
import
json
import
pytest
from
PIL
import
Image
def
id_function
(
val
):
if
isinstance
(
val
,
dict
):
...
...
@@ -92,3 +95,28 @@ def test_loading(database_checkers, name: str, dataset: str):
expected_num_labels
=
1
,
)
limit
-=
1
@pytest.mark.skip_if_rc_var_not_set
(
"
datadir.montgomery
"
)
def
test_loaded_image_quality
(
datadir
):
datamodule
=
importlib
.
import_module
(
"
.default
"
,
"
mednet.config.data.montgomery
"
).
datamodule
datamodule
.
model_transforms
=
[]
datamodule
.
setup
(
"
predict
"
)
loader
=
datamodule
.
splits
[
"
train
"
][
0
][
1
]
first_sample
=
datamodule
.
splits
[
"
train
"
][
0
][
0
][
0
]
image_data
=
loader
.
sample
(
first_sample
)[
0
].
numpy
()[
0
,
:,
:
]
# PIL expects grayscale to not have any leading dim
img
=
Image
.
fromarray
(
image_data
,
mode
=
"
L
"
)
histogram
=
img
.
histogram
()
reference_histogram_file
=
str
(
datadir
/
"
histogram_montgomery.json
"
)
with
open
(
reference_histogram_file
)
as
i_f
:
ref_histogram
=
json
.
load
(
i_f
)[
"
histogram
"
]
assert
histogram
==
ref_histogram
This diff is collapsed.
Click to expand it.
tests/test_shenzhen.py
+
28
−
0
View file @
45f95973
...
...
@@ -4,9 +4,12 @@
"""
Tests for Shenzhen dataset.
"""
import
importlib
import
json
import
pytest
from
PIL
import
Image
def
id_function
(
val
):
if
isinstance
(
val
,
dict
):
...
...
@@ -92,3 +95,28 @@ def test_loading(database_checkers, name: str, dataset: str):
expected_num_labels
=
1
,
)
limit
-=
1
@pytest.mark.skip_if_rc_var_not_set
(
"
datadir.shenzhen
"
)
def
test_loaded_image_quality
(
datadir
):
datamodule
=
importlib
.
import_module
(
"
.default
"
,
"
mednet.config.data.shenzhen
"
).
datamodule
datamodule
.
model_transforms
=
[]
datamodule
.
setup
(
"
predict
"
)
loader
=
datamodule
.
splits
[
"
train
"
][
0
][
1
]
first_sample
=
datamodule
.
splits
[
"
train
"
][
0
][
0
][
0
]
image_data
=
loader
.
sample
(
first_sample
)[
0
].
numpy
()[
0
,
:,
:
]
# PIL expects grayscale to not have any leading dim
img
=
Image
.
fromarray
(
image_data
,
mode
=
"
L
"
)
histogram
=
img
.
histogram
()
reference_histogram_file
=
str
(
datadir
/
"
histogram_shenzhen.json
"
)
with
open
(
reference_histogram_file
)
as
i_f
:
ref_histogram
=
json
.
load
(
i_f
)[
"
histogram
"
]
assert
histogram
==
ref_histogram
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment