예제 #1
0
    sess.run(tf.global_variables_initializer())
    saver.restore(sess, './model/S1_model_iter-0')
    print("Starting training......")
    for i in range(total_step):

        imgs, labels = sess.run([imgs_batch, landmarks_batch])
        sess.run(dan['S2_Optimizer'], feed_dict={x: imgs, y: labels})
        if (i % auc_step == 0 or i == (total_step - 1)):
            runTime = time.clock() - curTime
            curTime = time.clock()
            loss_s2 = dan['S2_Cost'].eval(feed_dict={x: imgs, y: labels})
            #r = dan['r'].eval(feed_dict={x:imgs,y:labels})
            print("step:%s   loss_s2:%.4f  Running time:%.2fs" %
                  (str(i).zfill(6), loss_s2, runTime))
        if (i % auc_step == 0 or i == (total_step - 1)):
            imgs_test, landmarks_test = loadTfrecords_t(tfrecordsTest, 1)
            errors_s2 = []
            for _ in range(100):
                imgsTest, landmarksTest = sess.run([imgs_test, landmarks_test])
                pred_s2 = sess.run(dan['S2_Ret'],
                                   feed_dict={
                                       x: imgsTest,
                                       y: landmarksTest
                                   })
                error_s2 = LandmarkError(pred_s2[0], landmarksTest[0])
                errors_s2.append(error_s2)
            AUCError(errors_s2, threshold, step=0.0001, showCurve=False)
            print(
                sess.run(dan['S2_Cost'],
                         feed_dict={
                             x: imgsTest,
예제 #2
0
    print("Starting training......")
    for i in range(total_step):

        imgs, labels = sess.run([imgs_batch, landmarks_batch])
        sess.run(dan['s1_optimizer'], feed_dict={x: imgs, y: labels})
        if (i % auc_step == 0 or i == (total_step - 1)):
            runTime = time.clock() - curTime
            curTime = time.clock()
            loss_s1 = dan['s1_cost'].eval(feed_dict={
                x: imgs,
                y: labels
            })  #,dan['S1_isTrain']:False,dan['S2_isTrain']:False})
            print("step:%s   loss_s1:%.6f  Running time:%.2fs" %
                  (str(i).zfill(6), loss_s1, runTime))
        if (i % auc_step == 0 or i == (total_step - 1)):
            imgs_test, landmarks_test = loadTfrecords_t(
                tfrecordsTest, batch_size)
            errors_s1 = []
            imgsTest, landmarksTest = sess.run([imgs_test, landmarks_test])
            pred_s1 = sess.run(dan['s1_landmarks'],
                               feed_dict={
                                   x: imgsTest,
                                   y: landmarksTest
                               })
            for i in range(batch_size):
                error_s1 = LandmarkError(pred_s1[i],
                                         landmarksTest[i],
                                         normalization=['diagonal'])
                errors_s1.append(error_s1)
            AUCError(errors_s1, threshold, step=0.0001, showCurve=False)
            print(
                sess.run(dan['s1_cost'],