return prediction def predict_batch_from_model(patches, model): """Predict which pixels are tumor. input: patch: `batch_size`x256x256x3, rgb image input: model: keras model output: prediction: 256x256x1, per-pixel tumor probability """ predictions = model.predict(patches) predictions = predictions[:, :, :, 1] return predictions train_generator = generate_tiles_fast(train_samples, 32, shuffle=False) validation_generator = generate_tiles_fast(validation_samples, 32, shuffle=False) train_steps = len(train_samples) // BATCH_SIZE validation_steps = len(validation_samples) // BATCH_SIZE #train_predictions = model.predict_generator(train_generator, steps= len(train_samples)//BATCH_SIZE) #validation_predictions = model.predict_generator(validation_generator, # steps= len(validation_samples)//BATCH_SIZE, # callbacks=[TQDMCallback()]) #print(validation_predictions.shape) #train_predictions = np.argmax(predictions, axis=-1) #multiple categories
def predict_batch_from_model(patches, model): """Predict which pixels are tumor. input: patch: `batch_size`x256x256x3, rgb image input: model: keras model output: prediction: 256x256x1, per-pixel tumor probability """ predictions = model.predict(patches) predictions = predictions[:, :, :, 1] return predictions train_generator = generate_tiles_fast(train_samples.sample(32, random_state=42), 32, shuffle=True) validation_generator = generate_tiles_fast(validation_samples.sample( 32, random_state=42), 32, shuffle=True) filepath = "fast-allsamples-keras-improvement-{epoch:02d}-{val_acc:.2f}.hdf" checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max') callbacks_list = [checkpoint] model.fit_generator(train_generator,