Пример #1
0
recon = tf.squeeze(recon)

#########################################################################
# Start TF session (respecting OMP_NUM_THREADS)
nthr = os.getenv('OMP_NUM_THREADS')
if nthr is None:
    sess = tf.Session()
else:
    sess = tf.Session(config=tf.ConfigProto(
        intra_op_parallelism_threads=int(nthr)))
sess.run(tf.global_variables_initializer())

#########################################################################
# Load latest model
print("Restoring model from " + mfile)
ut.loadNet(mfile, model.weights, sess)
print("Done!")

mses, psnrs = [], []
for nm in open(VLIST, 'r'):
    nm = nm.strip()
    if 'foreman' in nm or 'Parrots' in nm:
        image = np.float32(imread(nm)[:, :, 0]) / 65535.
        h, w = image.shape[:2]
    else:
        image = np.float32(imread(nm)) / 255.
        h, w = image.shape

    h_pad, w_pad = (PSZ - h % PSZ) % PSZ, (PSZ - w % PSZ) % PSZ
    image = np.pad(image, ((0, h_pad), (0, w_pad)), 'constant')
Пример #2
0
nthr = os.getenv('OMP_NUM_THREADS')
if nthr is None:
    sess = tf.Session()
else:
    sess = tf.Session(config=tf.ConfigProto(
        intra_op_parallelism_threads=int(nthr)))
sess.run(tf.global_variables_initializer())

#########################################################################
# Load saved weights if any
if niter > 0:
    mfn = wts+"/iter_%06d.model.npz" % niter
    sfn = wts+"/iter_%06d.state.npz" % niter

    ut.mprint("Restoring model from " + mfn )
    ut.loadNet(mfn,model.weights,sess)
    ut.mprint("Restoring state from " + sfn )
    ut.loadAdam(sfn,opt,model.weights,sess)
    ut.mprint("Done!")

#########################################################################
# Main Training loop

stop=False
ut.mprint("Starting from Iteration %d" % niter)
sess.run(tset.fetchOp,feed_dict=tset.fdict())

while niter < MAXITER and not ut.stop:

    ## Validate model every so often
    if niter % VALFREQ == 0: