Ejemplo n.º 1
0
	img_count = 0
	outrange = len(tiCr.tile_inputs_all_complete) / tilesPerImg

	# use int to avoid TypeError: 'float' object cannot be interpreted as an integer
	for currOut in range( int(outrange) ): 
		batch_xs = []
		batch_ys = []
		for curr_tile in range(tilesPerImg):
			idx = currOut * tilesPerImg + curr_tile
			batch_xs.append(tiCr.tile_inputs_all_complete[idx])
			batch_ys.append(np.zeros((tileSizeHigh * tileSizeHigh), dtype='f'))

		resultTiles = y_pred.eval(feed_dict={x: batch_xs, y_true: batch_ys, keep_prob: 1.})

		tiCr.debugOutputPngsCrop(resultTiles, tileSizeHigh, simSizeHigh, test_path, \
			imageCounter=currOut, cut_output_to=tileSizeHiCrop, tiles_in_image=tilesPerImg)
		# optionally, output references
		#tiCr.debugOutputPngsCrop(batch_ys, tileSizeHigh, simSizeHigh, test_path+"_ref", imageCounter=currOut, cut_output_to=tileSizeHiCrop, tiles_in_image=tilesPerImg)
		img_count += 1

	print('Test finished, %d pngs written to %s.' % (img_count, test_path) )

# write summary to test overview
loaded_model = ''
if not loadModelTest == -1:
	loaded_model = ', Loaded %04d, %d' % (loadModelTest , loadModelNo)
with open(basePath + 'test_overview.txt', "a") as text_file:
	text_file.write(test_path[-10:-1] + ': {:.2f} min, {} Epochs, cost {:.4f}, {}'.format(training_duration, trainingEpochs, cost, " ") + loaded_model + '\n')


Ejemplo n.º 2
0
            break
        resultTiles = y_pred.eval(feed_dict={
            x: batch_xs,
            y_true: batch_ys,
            training: False
        })

        if brightenOutput > 0:
            for i in range(len(resultTiles)):
                resultTiles[i] *= brightenOutput
            for i in range(len(batch_ys)):
                batch_ys[i] *= brightenOutput
        tiCr.debugOutputPngsCrop(resultTiles,
                                 tileSizeHigh,
                                 simSizeHigh,
                                 test_path,
                                 imageCounter=currOut,
                                 cut_output_to=tileSizeHiCrop,
                                 tiles_in_image=tilesPerImg,
                                 name='output')
        tiCr.debugOutputPngsCrop(batch_ys,
                                 tileSizeHigh,
                                 simSizeHigh,
                                 test_path,
                                 imageCounter=currOut,
                                 cut_output_to=tileSizeHiCrop,
                                 tiles_in_image=tilesPerImg,
                                 name='expected_out')

        if outputInputs:
            if not useVelocities:
                tiCr.debugOutputPngsSingle(batch_xs,
Ejemplo n.º 3
0
	tdataSize = len(batch_xs)
	# for prediction, we have to get rid of the third spatial dim
	batch_xs = np.reshape( batch_xs, [tdataSize,tileSizeLow,tileSizeLow,  n_inputChannels] )
	batch_ys = np.reshape( batch_ys, [tdataSize,tileSizeHigh,tileSizeHigh,1 ] )

	resultTiles = model.predict( batch_xs )

	# now restore it...
	batch_xs = np.reshape( batch_xs, [tdataSize,1, tileSizeLow,tileSizeLow,  n_inputChannels] )
	batch_ys = np.reshape( batch_ys, [tdataSize,1, tileSizeHigh,tileSizeHigh,1 ] )
	resultTiles = np.reshape( resultTiles, [tdataSize,1, tileSizeHigh,tileSizeHigh,1 ] )

	# simply concat tiles into images...
	tileSizeHiCrop = upRes * cropTileSizeLow
	tilesPerImg = (simSizeHigh // tileSizeHiCrop) ** 2
	imgCnt = len(tiCr.tile_inputs_all_complete) / tilesPerImg
	tiCr.debugOutputPngsCrop(resultTiles, tileSizeHigh, simSizeHigh, test_path, imageCounter=0, cut_output_to=tileSizeHiCrop, \
		tiles_in_image=tilesPerImg, name='output')

	if outputInputs:
		tiCr.debugOutputPngsSingle(batch_xs,         tileSizeLow, simSizeLow, test_path, imageCounter=0, name='input', channel=0)
		if useVelocities: 
			tiCr.debugOutputPngsSingle(batch_xs,         tileSizeLow, simSizeLow, test_path, imageCounter=0, name='in_vel_x', channel=1)
			tiCr.debugOutputPngsSingle(batch_xs,         tileSizeLow, simSizeLow, test_path, imageCounter=0, name='in_vel_y', channel=2)

	print('Output finished, %d pngs written to %s.' % (imgCnt, test_path) )