Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
deepdraw
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
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
medai
software
deepdraw
Commits
7e544ab4
Commit
7e544ab4
authored
5 years ago
by
Tim Laibacher
Browse files
Options
Downloads
Patches
Plain Diff
Add more f1 to viz
parent
08e191d7
No related branches found
No related tags found
No related merge requests found
Pipeline
#31864
passed
5 years ago
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bob/ip/binseg/utils/FreeMono.ttf
+0
-0
0 additions, 0 deletions
bob/ip/binseg/utils/FreeMono.ttf
bob/ip/binseg/utils/plot.py
+22
-7
22 additions, 7 deletions
bob/ip/binseg/utils/plot.py
doc/covdresults.rst
+23
-23
23 additions, 23 deletions
doc/covdresults.rst
with
45 additions
and
30 deletions
bob/ip/binseg/utils/FreeMono.ttf
0 → 100644
+
0
−
0
View file @
7e544ab4
File added
This diff is collapsed.
Click to expand it.
bob/ip/binseg/utils/plot.py
+
22
−
7
View file @
7e544ab4
...
...
@@ -6,7 +6,7 @@ import os
import
csv
import
pandas
as
pd
import
PIL
from
PIL
import
Image
from
PIL
import
Image
,
ImageFont
,
ImageDraw
import
torchvision.transforms.functional
as
VF
import
torch
...
...
@@ -198,10 +198,10 @@ def plot_overview(outputfolders,title):
def
metricsviz
(
dataset
,
output_path
,
tp_color
=
(
128
,
128
,
128
)
,
fp_color
=
(
70
,
240
,
240
)
,
fn_color
=
(
245
,
130
,
48
)
):
,
tp_color
=
(
0
,
255
,
0
)
#
(128,128,128)
Gray
,
fp_color
=
(
0
,
0
,
255
)
#
(70, 240, 240)
Cyan
,
fn_color
=
(
255
,
0
,
0
)
#
(245, 130, 48)
Orange
,
overlayed
=
True
):
"""
Visualizes true positives, false positives and false negatives
Default colors TP: Gray, FP: Cyan, FN: Orange
...
...
@@ -253,6 +253,16 @@ def metricsviz(dataset
# paste together
tp_pil_colored
.
paste
(
fp_pil_colored
,
mask
=
fp_pil
)
tp_pil_colored
.
paste
(
fn_pil_colored
,
mask
=
fn_pil
)
if
overlayed
:
tp_pil_colored
=
PIL
.
Image
.
blend
(
img
,
tp_pil_colored
,
0.4
)
img_metrics
=
pd
.
read_csv
(
os
.
path
.
join
(
output_path
,
'
results
'
,
name
+
'
.csv
'
))
f1
=
img_metrics
[
'
f1_score
'
].
max
()
# add f1-score
fnt_size
=
tp_pil_colored
.
size
[
1
]
//
25
draw
=
ImageDraw
.
Draw
(
tp_pil_colored
)
fnt
=
ImageFont
.
truetype
(
'
FreeMono.ttf
'
,
fnt_size
)
draw
.
text
((
0
,
0
),
"
F1: {:.4f}
"
.
format
(
f1
),(
255
,
255
,
255
),
font
=
fnt
)
# save to disk
overlayed_path
=
os
.
path
.
join
(
output_path
,
'
tpfnfpviz
'
)
...
...
@@ -277,8 +287,8 @@ def overlay(dataset, output_path):
gt
=
sample
[
2
].
byte
()
# byte tensor
# read metrics
metrics
=
pd
.
read_csv
(
os
.
path
.
join
(
output_path
,
'
results
'
,
'
Metrics
.csv
'
))
optimal_threshold
=
metrics
[
'
threshold
'
][
metrics
[
'
f1_score
'
].
idx
max
()
]
#
metrics = pd.read_csv(os.path.join(output_path,'results',
name+'
.csv'))
#f1 = metrics['
f1_score'].max()
# read probability output
pred
=
Image
.
open
(
os
.
path
.
join
(
output_path
,
'
images
'
,
name
))
...
...
@@ -286,6 +296,11 @@ def overlay(dataset, output_path):
pred_green
=
PIL
.
ImageOps
.
colorize
(
pred
,
(
0
,
0
,
0
),
(
0
,
255
,
0
))
overlayed
=
PIL
.
Image
.
blend
(
img
,
pred_green
,
0.4
)
# add f1-score
#fnt_size = overlayed.size[1]//25
#draw = ImageDraw.Draw(overlayed)
#fnt = ImageFont.truetype('FreeMono.ttf', fnt_size)
#draw.text((0, 0),"F1: {:.4f}".format(f1),(255,255,255),font=fnt)
# save to disk
overlayed_path
=
os
.
path
.
join
(
output_path
,
'
overlayed
'
)
if
not
os
.
path
.
exists
(
overlayed_path
):
os
.
makedirs
(
overlayed_path
)
...
...
This diff is collapsed.
Click to expand it.
doc/covdresults.rst
+
23
−
23
View file @
7e544ab4
...
...
@@ -11,27 +11,27 @@ F1 Scores
F1 score together with standard deviation across test images.
+-------------------+--------+-----------------+---------+
| F1 score | DRIU | DRIU BN | M2U-Net |
+-------------------+--------+-----------------+---------+
| COVD-DRIVE | 0.7896 | 0.8000 (0.0182) | 0.7906 |
+-------------------+--------+-----------------+---------+
| COVD-DRIVE SSL | 0.7870 | 0.8020 (0.0179) | 0.7938 |
+-------------------+--------+-----------------+---------+
| COVD-STARE | 0.7979 | 0.8129 (0.0986) | 0.8120 |
+-------------------+--------+-----------------+---------+
| COVD-STARE SSL | 0.8062 | 0.8221 (0.0784) | 0.8222 |
+-------------------+--------+-----------------+---------+
| COVD-CHASEDB1 | 0.7979 | 0.7923 (0.0240) | 0.7898 |
+-------------------+--------+-----------------+---------+
| COVD-CHASEDB1 SSL | 0.7976 | 0.7992 (0.0235) | 0.8000 |
+-------------------+--------+-----------------+---------+
| COVD-HRF | 0.8013 | 0.8027 (0.0452) | 0.8036 |
+-------------------+--------+-----------------+---------+
| COVD-HRF SSL | 0.8002 | | 0.79
99
|
+-------------------+--------+-----------------+---------+
| COVD-IOSTAR | 0.7934 | 0.7763 (0.0311) | 0.7953 |
+-------------------+--------+-----------------+---------+
| COVD-IOSTAR SSL | 0.7995 | 0.7904 (0.0215) | 0.7868 |
+-------------------+--------+-----------------+---------+
+-------------------+--------
---------
+-----------------+---------
--------
+
| F1 score | DRIU
| DRIU BN | M2U-Net
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-DRIVE | 0.7896
(0.0178)
| 0.8000 (0.0182) | 0.7906
(0.0179)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-DRIVE SSL | 0.7870
(0.0176)
| 0.8020 (0.0179) | 0.7938
(0.0142)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-STARE | 0.7979
(0.1254)
| 0.8129 (0.0986) | 0.8120
(0.0457)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-STARE SSL | 0.8062
(0.1033)
| 0.8221 (0.0784) | 0.8222
(0.0441)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-CHASEDB1 | 0.7979
(0.0284)
| 0.7923 (0.0240) | 0.7898
(0.0236)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-CHASEDB1 SSL | 0.7976
(0.0242)
| 0.7992 (0.0235) | 0.8000
(0.0268)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-HRF | 0.8013
(0.0436)
| 0.8027 (0.0452) | 0.8036
(0.0442)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-HRF SSL | 0.8002
(0.0421)
| | 0.79
87 (0.0436)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-IOSTAR | 0.7934
(0.0206)
| 0.7763 (0.0311) | 0.7953
(0.0152)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
| COVD-IOSTAR SSL | 0.7995
(0.0174)
| 0.7904 (0.0215) | 0.7868
(0.0182)
|
+-------------------+--------
---------
+-----------------+---------
--------
+
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