コード例 #1
0
# configure args
from opts import *
from opts import dataset_mean, dataset_std  # set them in opts

modelFns = {
    'unet': Models.VanillaUnet.VanillaUnet,
    'segnet': Models.Segnet.Segnet,
    'vgg_unet': Models.VGGUnet.VGGUnet,
    'vgg_unet2': Models.VGGUnet.VGGUnet2,
    'fcn8': Models.FCN8.FCN8,
    'fcn32': Models.FCN32.FCN32,
    'crfunet': Models.CRFunet.CRFunet
}

# save and compute metrics
vis = VIS(save_path=opt.checkpoint_path)

# configuration session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
''' Users define data loader (with train and test) '''
img_shape = [opt.imSize, opt.imSize]
label_classes = vis.palette_info()
train_generator, train_samples = dataLoader(opt.data_path + '/train/',
                                            opt.batch_size,
                                            img_shape,
                                            label_classes,
                                            mean=dataset_mean,
                                            std=dataset_std)
test_generator, test_samples = dataLoader(opt.data_path + '/val/',
コード例 #2
0
np.random.seed(SEED)
import tensorflow as tf

tf.set_random_seed(SEED)

import os, shutil, glob
from skimage import transform, io
from model import UNet
from utils import VIS, mean_IU
# configure args
from opts import *
import cv2

# save and compute metrics
vis = VIS(save_path=opt.checkpoint_path)
print('num_class = %d' % opt.num_class)

# configuration session
config = tf.ConfigProto(
    device_count={'GPU': 0}
)
# config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

img_shape = [280, 500]  # Resized to be the same.

# define input holders
train_list = glob.glob(opt.data_path + '/train/img/0/*.png')
train_num = len(train_list)
test_list = glob.glob(opt.data_path + '/val/img/0/*.png')
コード例 #3
0
import tensorflow as tf
import os, sys
import numpy as np
import scipy.misc as misc
from model import UNet
from utils import dice_coef, dice_coef_loss
from loader import dataLoader, deprocess, dataLoaderNp
from PIL import Image
from utils import VIS, mean_IU

# configure args
from opts import *
from opts import dataset_mean, dataset_std  # set them in opts

vis = VIS(save_path=opt.load_from_checkpoint, is_train=False)

# configuration session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

# define data loader
img_shape = [233, 369]  #img_shape = [opt.imSize, opt.imSize]
test_generator, test_samples = dataLoaderNp(opt.data_path, 1, train_mode=False)
# define model, the last dimension is the channel
label = tf.placeholder(tf.int32, shape=[None] + img_shape)
with tf.name_scope('unet'):
    model = UNet().create_model(img_shape=img_shape + [3],
                                num_class=opt.num_class)
    img = model.input
コード例 #4
0
# configure args
from opts import *
from opts import dataset_mean, dataset_std  # set them in opts

modelFns = {
    'unet': Models.VanillaUnet.VanillaUnet,
    'segnet': Models.Segnet.Segnet,
    'vgg_unet': Models.VGGUnet.VGGUnet,
    'vgg_unet2': Models.VGGUnet.VGGUnet2,
    'fcn8': Models.FCN8.FCN8,
    'fcn32': Models.FCN32.FCN32,
    'crfunet': Models.CRFunet.CRFunet
}

vis = VIS(save_path=opt.load_from_checkpoint)

# configuration session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

# define data loader
img_shape = [opt.imSize, opt.imSize]
label_classes = vis.palette_info()
print('++++++++++++++++++++++++class')
print(label_classes)
test_generator, test_samples = dataLoader(opt.data_path + '/val/',
                                          1,
                                          img_shape,
                                          label_classes,
コード例 #5
0
from keras import backend as K
import tensorflow as tf
import os, sys
import numpy as np
import scipy.misc as misc
from model import UNet
from utils import dice_coef, dice_coef_loss
from loader import dataLoader, folderLoader
from PIL import Image
from utils import VIS, mean_IU

# configure args
from opts import *
# assert(opt.load_from_checkpoint != '')
# assert(opt.batch_size == 1)
vis = VIS(save_path=opt.load_from_checkpoint)

# configuration session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
K.set_session(sess)
K.set_learning_phase(0)

# define data loader
test_generator, test_samples = folderLoader(opt.data_path)

# define model, the last dimension is the channel
img_shape = (opt.imSize, opt.imSize, 3)
# img = tf.placeholder(tf.float32, shape=img_shape)
label = tf.placeholder(tf.int32, shape=(None, opt.imSize, opt.imSize))
コード例 #6
0
import os, sys
import numpy as np
import scipy.misc as misc
from model import UNet
from utils import dice_coef, dice_coef_loss
from loader import dataLoader, folderLoader
from PIL import Image
from utils import VIS, mean_IU
import cv2
# configure args
from opts import *
# assert(opt.load_from_checkpoint != '')
# assert(opt.batch_size == 1)
from matplotlib import pyplot as plt
#vis = VIS(save_path=opt.load_from_checkpoint)
vis = VIS(save_path='./trainlog')
# configuration session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

# define data loader
img_shape = [opt.imHeight, opt.imWidth]
test_generator, test_samples = folderLoader(opt.data_path, imSize=img_shape)

# define model, the last dimension is the channel
label = tf.placeholder(tf.int32, shape=[None] + img_shape)
with tf.name_scope('unet'):
    model = UNet().create_model(img_shape=img_shape + [3],
                                num_class=opt.num_class)
    img = model.input