Commit 1a2fb61b authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

Updates to CellDB

parent 6b18a3e4
#!/usr/bin/enc python
#!/usr/bin/env 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')
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment