예제 #1
0
파일: shallow.py 프로젝트: SamL98/TGSSalt
    parser.add_argument('-g', '--gray', dest='gray', action='store_true')
    parser.add_argument('-nm', '--norm', dest='normalize', action='store_true')
    parser.add_argument('-e', '--epochs', dest='epochs', type=int, default=50)
    parser.add_argument('-di', '--dice', dest='dice', action='store_true')
    parser.add_argument('-t', '--test', dest='test', action='store_true')
    parser.add_argument('-f', '--flip', dest='flip', action='store_true')
    parser.add_argument('-de',
                        '--denoise',
                        dest='denoise',
                        action='store_true')
    return parser.parse_args()


args = get_args()

u.set_gray(args.gray)
u.set_cs(args.cs)

# Load the data and add an axis to the end of y
# so that it is three-dimensional
X, y = u.ips()
y = np.expand_dims(y, axis=3)

if args.test:
    X, y = X[:100], y[:100]

if args.jcs and X.shape[-1] == 2:
    X = np.expand_dims(X[:, :, :, 1], axis=3)

if args.flip:
    X = np.append(X, [np.fliplr(x) for x in X], axis=0)
예제 #2
0
with open(join('models', args.ae_name, 'model.json')) as f:
    json = f.read()
ae = model_from_json(json)
ae.load_weights(join('models', args.ae_name, 'model.h5'))

last_layer = ae.layers[-1]
while not last_layer.name == "conv2d_10":
    ae.layers.pop()
    last_layer = ae.layers[-1]

for layer in ae.layers:
    layer.trainable = args.trainable

num_chan = ae.layers[0].input_shape[-1]
if num_chan == 3:
    u.set_gray(False)
    u.set_cs(False)
elif num_chan == 2:
    u.set_cs(True)
else:
    u.set_cs(False)
    u.set_gray(True)

# Load the data and add an axis to the end of y
# so that it is three-dimensional
X, y = u.ips()
y = np.expand_dims(y, axis=3)

name = args.name  # name of the model
dropout = args.dropout  # dropout to use in the U-Net
예제 #3
0
파일: pre.py 프로젝트: SamL98/TGSSalt
import util as u
import numpy as np

u.set_gray(True)

for _ in range(5):
    img = (u.rand_img() * 255).astype(np.uint8)
    sharpened = u.preprocess(img, sharpen=False, contrast=True)
    fully_processed = u.preprocess(img, sharpen=True, contrast=True)
    u.disp_imp(img / 255., sharpened / 255., fully_processed / 255.)
예제 #4
0
                    '--thresh',
                    dest='threshold',
                    type=float,
                    default=-1.0)
args = parser.parse_args()

name = args.name
with open(join('models', name, 'model.json')) as f:
    json = f.read()

model = model_from_json(json)
model.load_weights(join('models', name, 'model.h5'))

num_chan = model.layers[0].input_shape[-1]
if num_chan == 3:
    u.set_gray(False)
    u.set_cs(False)
elif num_chan == 2:
    u.set_cs(True)
else:
    u.set_cs(False)

ids = u.img_ids(train=True)
ids = np.random.choice(ids, args.num, replace=False)

X, y = u.ips(for_ids=ids)
if len(X.shape) == 3:
    X = np.expand_dims(X, axis=3)

u.unsilence()
print(X.shape, y.shape)