Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Saad Jbabdi
CellCounting
Commits
1a2fb61b
Commit
1a2fb61b
authored
Sep 20, 2018
by
Saad Jbabdi
Browse files
Updates to CellDB
parent
6b18a3e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
CellCounting/models/train_model.py
View file @
1a2fb61b
#!/usr/bin/en
c
python
#!/usr/bin/en
v
python
# Train model for cell recognition
# Oiwi, 07/2018
...
...
@@ -8,8 +8,8 @@
# General
import
numpy
as
np
import
time
import
os
import
time
,
os
,
sys
import
argparse
# DL stuff
from
keras.models
import
Sequential
from
keras.layers.convolutional
import
Convolution2D
,
MaxPooling2D
...
...
@@ -21,7 +21,7 @@ from keras.preprocessing.image import ImageDataGenerator
# Other
import
pandas
as
pd
from
CellCounting.utils
import
db
import
argparse
# ------------------------------ DATA ------------------------------ #
def
prepare_data
(
celldb
,
args
):
...
...
@@ -200,6 +200,7 @@ def main():
print
(
'Preparing image database'
)
celldb
=
db
.
CellDB
()
celldb
.
load
(
args
.
data
)
print
(
celldb
)
celldb
.
equalise_classes
()
print
(
'Preparing and training model'
)
...
...
CellCounting/utils/db.py
View file @
1a2fb61b
...
...
@@ -123,3 +123,23 @@ class CellDB(object):
print
(
' '
)
print
(
'-----------------------------------------------'
)
return
# Check prediction against true classes
def
check_prediction_yn
(
self
,
labels
,
verbose
=
False
):
TP
=
((
self
.
cell_counts
>
0
)
&
(
labels
>
0
)).
sum
()
FP
=
((
self
.
cell_counts
==
0
)
&
(
labels
>
0
)).
sum
()
TN
=
((
self
.
cell_counts
==
0
)
&
(
labels
==
0
)).
sum
()
FN
=
((
self
.
cell_counts
>
0
)
&
(
labels
==
0
)).
sum
()
recall
=
TP
/
(
TP
+
FN
)
prec
=
TN
/
(
TN
+
FP
)
acc
=
(
TP
+
TN
)
/
(
TP
+
FP
+
TN
+
FN
)
if
verbose
:
print
(
'Accuracy = {:.2f}'
.
format
(
acc
*
100
))
print
(
'Precision = {:.2f}'
.
format
(
prec
*
100
))
print
(
'Recall = {:.2f}'
.
format
(
recall
*
100
))
return
prec
,
recall
,
acc
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment