glasses = np.load("{0}/{1}".format(path, FgImgPath))

# prepare model saver/summary writer
saver_GP = tf.train.Saver(var_list=varsGP)

print(util.toYellow("======= EVALUATION START ======="))
timeStart = time.time()
# start session
tfConfig = tf.ConfigProto(allow_soft_placement=True)
tfConfig.gpu_options.allow_growth = True
with tf.Session(config=tfConfig) as sess:
    sess.run(tf.global_variables_initializer())
    util.restoreModel(opt, sess, saver_GP, opt.loadGP, "GP")
    print(util.toMagenta("start evaluation..."))

    # create directories for test image output
    os.makedirs("eval_{0}".format(opt.loadGP), exist_ok=True)
    testImage = util.imread(opt.loadImage)
    if testImage.shape[2] == 4:
        testImage = testImage[:, :, :3]
    batch = data.makeBatchEval(opt, testImage, glasses, PH)
    runList = [imageCompAll[0], imageCompAll[-1]]
    ic0, icf = sess.run(runList, feed_dict=batch)
    for b in range(opt.batchSize):
        util.imsave("eval_{0}/image_g{1}_input.png".format(opt.loadGP, b),
                    ic0[b])
        util.imsave("eval_{0}/image_g{1}_output.png".format(opt.loadGP, b),
                    icf[b])

print(util.toYellow("======= EVALUATION DONE ======="))
예제 #2
0
print(util.toYellow("======= EVALUATION START ======="))
timeStart = time.time()
# start session
tfConfig = tf.ConfigProto(allow_soft_placement=True)
tfConfig.gpu_options.allow_growth = True
with tf.Session(config=tfConfig) as sess:
    sess.run(tf.global_variables_initializer())
    util.restoreModel(opt, sess, saver_GP, opt.loadGP, "GP")
    print(util.toMagenta("start evaluation..."))

    # create directories for test image output
    os.makedirs("eval_{0}".format(opt.loadGP), exist_ok=True)
    testImage = util.imread(opt.loadImage)

    # resize input image size to 128*128
    import cv2
    testImage = cv2.resize(testImage, dsize=(128, 128))
    # end of resize code

    batch = data.makeBatchEval(opt, testImage, bags, PH)
    runList = [imageCompAll[0], imageCompAll[-1]]
    ic0, icf = sess.run(runList, feed_dict=batch)
    for b in range(opt.batchSize):
        util.imsave("eval_{0}/image_g{1}_input.png".format(opt.loadGP, b),
                    ic0[b])
        util.imsave("eval_{0}/image_g{1}_output.png".format(opt.loadGP, b),
                    icf[b])

print(util.toYellow("======= EVALUATION DONE ======="))
예제 #3
0
	varsGP = [v for v in tf.global_variables() if "geometric" in v.name]

# load data
print(util.toMagenta("loading test data..."))
testData = data.load(opt,test=True)

# prepare model saver/summary writer
saver_GP = tf.train.Saver(var_list=varsGP)

print(util.toYellow("======= EVALUATION START ======="))
timeStart = time.time()
# start session
tfConfig = tf.ConfigProto(allow_soft_placement=True)
tfConfig.gpu_options.allow_growth = True
with tf.Session(config=tfConfig) as sess:
	sess.run(tf.global_variables_initializer())
	util.restoreModel(opt,sess,saver_GP,opt.loadGP,"GP")
	print(util.toMagenta("start evaluation..."))

	# create directories for test image output
	os.makedirs("eval_{0}".format(opt.loadGP),exist_ok=True)
	runList = [imageCompAll[0],imageCompAll[-1]]
	testIdx = [43]
	for i in testIdx:
		batch = data.makeBatchEval(opt,testData,i,PH)
		ic0,icf = sess.run(runList,feed_dict=batch)
		util.imsave("eval_{0}/image{1}_input.png".format(opt.loadGP,i),ic0[0])
		util.imsave("eval_{0}/image{1}_output.png".format(opt.loadGP,i),icf[0])

print(util.toYellow("======= EVALUATION DONE ======="))