pad=2) ax.set_aspect('equal') xstr = np.arange(int(0.004 * 1720) + 1) x = np.linspace(0, 1720, int(0.004 * 1720) + 1) plt.yticks(x, xstr) plt.imshow((data[3]).T, cmap='Greys', vmin=-1, vmax=1, aspect='auto') plt.title('Residual', fontsize=14, pad=6) plt.show() print("Data with size: {}".format(segydata.shape)) chunked_datas = np.expand_dims( chunker.dimension_preprocess(deepcopy(masked_data)), -1) chunked_masks = np.expand_dims(chunker.dimension_preprocess(deepcopy(mask)), -1) pred_datas = model.predict([chunked_datas, chunked_masks]) chunked_datas = np.squeeze(chunked_datas) pred_datas = np.squeeze(pred_datas) reconstructed_data = chunker.dimension_postprocess(pred_datas, segydata) reconstructed_data = (reconstructed_data * 2 - 1.0) * np.max(abs(segydata_org)) miss_data = deepcopy(segydata_org) miss_data[mask == 0] = 0 plot_datas([ miss_data, segydata_org, reconstructed_data, reconstructed_data - segydata_org ])
generator, steps_per_epoch=2000, epochs=10, callbacks=[ TensorBoard( log_dir='./coco_2017_data/logs/single_image_test', write_graph=False ), ModelCheckpoint( './coco_2017_data/logs/single_image_test/coco_2017_weights.{epoch:02d}-{loss:.2f}.h5', monitor='loss', save_best_only=True, save_weights_only=True ), LambdaCallback( on_epoch_end=lambda epoch, logs: plot_sample_data( masked_img, model.predict( [ np.expand_dims(masked_img,0), np.expand_dims(mask,0) ] )[0] , img, middle_title='Prediction' ) ) ], )
#Generating samples output_plot = 'predicted_coco_dataset/predicted_rect_valset/' try: os.makedirs(output_plot) except OSError as e: if e.errno != errno.EEXIST: raise n = 0 for (masked, mask), ori, path in tqdm(test_generator): name = os.path.basename(path) print(path) #Run predictions for this batch of new_images pred_img = model.predict([masked, mask], batch_size=BATCH_SIZE) pred_time = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S') #Clear current output and display test images for i in range(len(ori)): #for i in range(len(images)): _, axes = plt.subplots(1, 2, figsize=(10, 5)) axes[0].imshow(masked[i, :, :, :]) axes[1].imshow(pred_img[i, :, :, :] * 1.) axes[0].set_title('Masked Image') axes[1].set_title('Predicted Image') axes[0].xaxis.set_major_formatter(NullFormatter()) axes[0].yaxis.set_major_formatter(NullFormatter()) axes[1].xaxis.set_major_formatter(NullFormatter()) axes[1].yaxis.set_major_formatter(NullFormatter())