示例#1
0
from tf_SDUnet import unet, util, image_util, metrics
import numpy as np

data_provider = image_util.ImageDataProvider("DRIVE700/test/*",
                                             data_suffix="_test.tif",
                                             mask_suffix='_manual1.png',
                                             n_class=2)

net = unet.Unet(layers=4, features_root=8, channels=3, n_class=2)
test_x, test_y = data_provider(1)

prediction = net.predict("mode/drive100_0.92_700/model.ckpt", test_x)
prediction = util.crop_to_shape(prediction, (20, 584, 565, 2))

AUC_ROC = metrics.roc_Auc(prediction,
                          util.crop_to_shape(test_y, prediction.shape))
print("auc", AUC_ROC)
acc = metrics.acc(prediction, util.crop_to_shape(test_y, prediction.shape))
print("acc:", acc)
precision = metrics.precision(prediction,
                              util.crop_to_shape(test_y, prediction.shape))
print("ppv:", precision)
sen = metrics.sen(prediction, util.crop_to_shape(test_y, prediction.shape))
print("TPR:", sen)
TNR = metrics.TNR(prediction, util.crop_to_shape(test_y, prediction.shape))
print("tnr:", TNR)
f1 = metrics.f1score2(prediction, util.crop_to_shape(test_y, prediction.shape))
print("f1:", f1)

img = util.combine_img_prediction(test_x, test_y, prediction)
util.save_image(img, "19.jpg")
示例#2
0
from tf_SDUnet import unet, util, image_util

#preparing data loading
data_provider = image_util.ImageDataProvider("dataset2/train/*.jpg",
                                             data_suffix=".jpg",
                                             mask_suffix='_mask.png',
                                             n_class=2)
output_path = "out_put2"
#setup & training
net = unet.Unet(layers=6, features_root=16, channels=3, n_class=2)

trainer = unet.Trainer(net)
path = trainer.train(data_provider, output_path, training_iters=12, epochs=1)
test_x, test_y = data_provider(1)
print(test_x.shape)
prediction = net.predict(path, test_x)
print(prediction)
unet.error_rate(prediction, util.crop_to_shape(test_y, prediction.shape))
img = util.combine_img_prediction(test_x, test_y, prediction)
util.save_image(img, "voc_prediction.jpg")
示例#3
0
from tf_SDUnet import unet, util, image_util

import numpy as np

import os

data_provider2 = image_util.ImageDataProvider("TNBC/test/*.png",
                                              data_suffix=".png",
                                              mask_suffix='_mask.png',
                                              n_class=2)
data_provider = image_util.ImageDataProvider("Model_zoo/train_aug/train/*.png",
                                             data_suffix=".png",
                                             mask_suffix='_mask.png',
                                             n_class=2)
output_path = "TNBC2_CKPT"
net = unet.Unet(layers=4, features_root=6, channels=3, n_class=2)
trainer = unet.Trainer(net,
                       batch_size=8,
                       verification_batch_size=4,
                       optimizer="adam")
path = trainer.train(data_provider,
                     output_path,
                     keep_prob=0.8,
                     training_iters=32,
                     epochs=100,
                     display_step=2,
                     restore=True)
test_x, test_y = data_provider2(1)
prediction = net.predict(path, test_x)
error = unet.error_rate(prediction, util.crop_to_shape(test_y,
                                                       prediction.shape))
示例#4
0
from tf_SDUnet import unet, util, image_util, metrics

import numpy as np

import os
data_provider2 = image_util.ImageDataProvider("TNBC/Chase1100/test/*",
                                              data_suffix="R.jpg",
                                              mask_suffix='R_1stHO.png',
                                              n_class=2)

data_provider = image_util.ImageDataProvider("TNBC/Chase1100/train/*",
                                             data_suffix="L.jpg",
                                             mask_suffix='L_1stHO.png',
                                             n_class=2)
output_path = "mode/CHASE100_0.92_1100"
net = unet.Unet(layers=4, features_root=8, channels=3, n_class=2)
trainer = unet.Trainer(net,
                       batch_size=4,
                       verification_batch_size=4,
                       optimizer="adam")
path = trainer.train(data_provider,
                     output_path,
                     keep_prob=0.92,
                     training_iters=48,
                     epochs=100,
                     display_step=2,
                     restore=False)
test_x, test_y = data_provider2(14)
prediction = net.predict(path, test_x)
#[batches, nx, ny, channels].
prediction = util.crop_to_shape(prediction, (14, 960, 999, 2))
示例#5
0
from tf_SDUnet import unet, util, image_util
data_provider2 = image_util.ImageDataProvider("TNBC/test/*.png",data_suffix=".png", mask_suffix='_mask.png', n_class=2)
#setup & training
net = unet.Unet(layers=4, features_root=6, channels=3, n_class=2)

test_x, test_y = data_provider2(25)

prediction = net.predict("TNBC2_CKPT/model.ckpt", test_x)

print(test_y)
error=unet.error_rate(prediction, util.crop_to_shape(test_y, prediction.shape))
print("test error:",error)
img = util.combine_img_prediction(test_x, test_y, prediction)
util.save_image(img, "TNBC_test13.jpg")
示例#6
0
from tf_SDUnet import image_gen, image_util, unet2, util
import numpy as np

#preparing data loading
# data_provider = image_util.ImageDataProvider("nuclei/*.png",data_suffix=".png", mask_suffix=' (2).png', n_class=2)
#
# data_provider = image_util.ImageDataProvider("data_set/train/*.tif",data_suffix=".tif", mask_suffix='_mask.tif', n_class=2)
data_provider2 = image_util.ImageDataProvider("test/*.tif",
                                              data_suffix=".tif",
                                              mask_suffix='_binary.tif',
                                              n_class=2)
#data_provider = image_util.ImageDataProvider("Tissue_images/*.tif",data_suffix=".tif", mask_suffix='_binary.tif', n_class=2)
data_provider = image_util.ImageDataProvider("tissue_aug/train/*.tif",
                                             data_suffix=".tif",
                                             mask_suffix='_binary.tif',
                                             n_class=2)
output_path = "out_put_skip_aug3_160"
#setup & training
net = unet2.Unet(layers=4, features_root=8, channels=3, n_class=2)
trainer = unet2.Trainer(net,
                        batch_size=4,
                        verification_batch_size=4,
                        optimizer="adam")
path = trainer.train(data_provider,
                     output_path,
                     keep_prob=0.8,
                     training_iters=124,
                     epochs=1,
                     display_step=2,
                     restore=True)
test_x, test_y = data_provider2(14)
示例#7
0
from tf_SDUnet import unet, util, image_util, stats_utils, layers
import tensorflow as tf
import numpy as np
DT = image_util.ImageDataProvider("test2/DT/*.tif",
                                  data_suffix=".tif",
                                  mask_suffix='_binary.tif',
                                  n_class=2,
                                  shuffle_data=False)
ST = image_util.ImageDataProvider("test2/ST/*.tif",
                                  data_suffix=".tif",
                                  mask_suffix='_binary.tif',
                                  n_class=2,
                                  shuffle_data=False)
ALL = image_util.ImageDataProvider("test2/all/*.tif",
                                   data_suffix=".tif",
                                   mask_suffix='_binary.tif',
                                   n_class=2,
                                   shuffle_data=False)
net = unet.Unet(layers=4, features_root=8, channels=3, n_class=2)
test_x, test_y = DT(6)
model = "model/model_f8_0.88_flip_160/model.ckpt"
prediction = net.predict(model, test_x)
#
# pred=tf.cast(prediction, tf.float64)
# loss=stats_utils.get_dice(util.crop_to_shape(test_y, prediction.shape),prediction)
# init = tf.global_variables_initializer()
# with tf.Session() as sess:
#     # Initialize variables
#     sess.run(init)
#     print("loss",sess.run(loss))
print(
示例#8
0
from tf_SDUnet import unet, util, image_util,stats_utils,layers
import tensorflow as tf
import numpy as np
Single = image_util.ImageDataProvider("test2/single/*.tif",data_suffix=".tif", mask_suffix='_binary.tif', n_class=2,shuffle_data=False)
net = unet.Unet(layers=4, features_root=8, channels=3, n_class=2)
test_x, test_y =Single(1)
model="model/model_f8_0.88_flip_160/model.ckpt"
prediction = net.predict(model, test_x)
print("dice2:",stats_utils.get_dice_2(util.crop_to_shape(test_y, prediction.shape),prediction))
print("dice1",stats_utils.get_dice_1(util.crop_to_shape(test_y, prediction.shape),prediction))
print("f1:",unet.f1score2(prediction, util.crop_to_shape(test_y, prediction.shape)))
print("aji:",stats_utils.get_aji(util.crop_to_shape(test_y, prediction.shape),prediction))
print("aji+:",stats_utils.get_fast_aji(util.crop_to_shape(test_y, prediction.shape),prediction))

error=unet.error_rate(prediction, util.crop_to_shape(test_y, prediction.shape))
print("error:",error)
img = util.combine_img_prediction(test_x, test_y, prediction)
util.save_image(img, "result/5698.jpg")
示例#9
0
from tf_SDUnet import unet, util, image_util,metrics
import  numpy as np
import  EVA
data_provider2 = image_util.ImageDataProvider("STARE_NEW/test/*", data_suffix="_train.jpg", mask_suffix='_label.png',n_class=2)
net = unet.Unet(layers=4, features_root=8, channels=3, n_class=2)
test_x, test_y = data_provider2(1)

prediction = net.predict("mode/STARE100_40_0.93/model.ckpt", test_x)

print(prediction.shape)
prediction=util.crop_to_shape(prediction, (10,605,700,2))
print(prediction.shape)
print(prediction)


AUC_ROC = metrics.roc_Auc(prediction, util.crop_to_shape(test_y, prediction.shape))
print("auc",AUC_ROC)
acc=metrics.acc(prediction,util.crop_to_shape(test_y, prediction.shape))
print("acc:",acc)
precision=metrics.precision(prediction,util.crop_to_shape(test_y, prediction.shape))
print("ppv:",precision)
sen=metrics.sen(prediction,util.crop_to_shape(test_y, prediction.shape))
print("TPR:",sen)
TNR=metrics.TNR(prediction,util.crop_to_shape(test_y, prediction.shape))
print("tnr:",TNR)
f1=metrics.f1score2(prediction,util.crop_to_shape(test_y, prediction.shape))
print("f1:",f1)



#
示例#10
0
from tf_SDUnet import unet, util, image_util, F1test
import numpy as np
import tensorflow as tf

data_provider2 = image_util.ImageDataProvider("test/ST/*.tif",
                                              data_suffix=".tif",
                                              mask_suffix='_binary.tif',
                                              n_class=2,
                                              shuffle_data=False)

#setup & training
net = unet.Unet(layers=4, features_root=8, channels=3, n_class=2)

test_x, test_y = data_provider2(14)

prediction = net.predict("model_aug_f8_0.75_100/model.ckpt", test_x)

print(test_y)
error = unet.error_rate(prediction, util.crop_to_shape(test_y,
                                                       prediction.shape))
print("test error:", error)
f1 = unet.f1score2(prediction, util.crop_to_shape(test_y, prediction.shape))
# print(f1)
# y_pred = np.argmax(prediction, axis=3)[0]
# y_true = np.argmax(util.crop_to_shape(test_y, prediction.shape), axis=3)[0]
# precision=F1test.precision(y_true,y_pred)
#
# f1=F1test.f1score(y_true,y_pred)

print("f1", f1)