コード例 #1
0
ファイル: app.py プロジェクト: torypayne/WCLranks
def guild_list():
	guild_name = request.args.get("guild").title()
	guild_server = request.args.get("server").title()
	guild_region = request.args.get("region").upper()
	guild_id_string = guild_name+"_"+guild_server+"_"+guild_region
	redis_guild = r.hgetall(guild_id_string)
	if model.is_empty(redis_guild) == True:
		guild = model.logs_new_guild(guild_name, guild_server, guild_region)
	else:
		# print redis_guild
		guild = {}
		guild["guild_name"] = redis_guild["guild_name"]
		guild["guild_server"] = redis_guild["guild_server"]
		guild["guild_region"] = redis_guild["guild_region"]
		guild["logs"] = eval(redis_guild["logs"])
	return render_template("guild_list.html", guild=guild)
コード例 #2
0
ファイル: app.py プロジェクト: zhoufan170/WCLranks
def guild_list():
    guild_name = request.args.get("guild").title()
    guild_server = request.args.get("server").title()
    guild_region = request.args.get("region").upper()
    guild_id_string = guild_name + "_" + guild_server + "_" + guild_region
    redis_guild = r.hgetall(guild_id_string)
    if model.is_empty(redis_guild) == True:
        guild = model.logs_new_guild(guild_name, guild_server, guild_region)
    else:
        # print redis_guild
        guild = {}
        guild["guild_name"] = redis_guild["guild_name"]
        guild["guild_server"] = redis_guild["guild_server"]
        guild["guild_region"] = redis_guild["guild_region"]
        guild["logs"] = eval(redis_guild["logs"])
    return render_template("guild_list.html", guild=guild)
コード例 #3
0
ファイル: tests.py プロジェクト: torypayne/make-it-short
	def test_most_popular_empty(self):
		popular = model.most_popular()
		self.assertFalse(model.is_empty(popular[1]["url"]))
コード例 #4
0
ファイル: tests.py プロジェクト: torypayne/make-it-short
	def test_recently_shortened(self):
		recent = model.recently_shortened()
		self.assertFalse(model.is_empty(recent))
コード例 #5
0
ファイル: tests.py プロジェクト: torypayne/make-it-short
	def test_empty(self):
		self.assertTrue(model.is_empty(self.empty))
		self.assertFalse(model.is_empty(self.code))
コード例 #6
0
def main():
    training_images, training_labels, test_images, test_labels = md.Load_Data(
        mat)

    if REMOVE_EMPTY:
        empty_idx = md.is_empty(training_images, training_labels)
        images_transform = np.delete(training_images, empty_idx, 0)
        labels_transform = np.delete(training_labels, empty_idx, 0)
        training_data = md.GetData(images_transform, labels_transform)
    else:
        training_data = md.GetData(training_images, training_labels)

    test_data = md.GetData(test_images, test_labels)

    g = tf.Graph()
    with g.as_default():

        images = tf.placeholder(tf.float32, [BATCH_SIZE, 256, 256, 1])
        labels = tf.placeholder(tf.int64, [BATCH_SIZE, 256, 256])
        is_training = tf.placeholder(tf.bool)

        if AUGMENT_IMAGE:
            images, labels = md.image_augmentation(images, labels)

        logits = md.inference(images, is_training)

        loss = md.loss_calc(logits=logits, labels=labels)

        train_op, global_step = md.training(loss=loss, learning_rate=1e-04)

        accuracy = md.evaluation(logits=logits, labels=labels)

        dice = md.get_dice(logits=logits, labels=labels)

        summary = tf.summary.merge_all()

        init = tf.global_variables_initializer()

        saver = tf.train.Saver(
            [x for x in tf.global_variables() if 'Adam' not in x.name])

        sm = tf.train.SessionManager()

        with sm.prepare_session("",
                                init_op=init,
                                saver=saver,
                                checkpoint_dir=LOG_DIR) as sess:

            sess.run(
                tf.variables_initializer(
                    [x for x in tf.global_variables() if 'Adam' in x.name]))

            train_writer = tf.summary.FileWriter(LOG_DIR + "/Train",
                                                 sess.graph)
            test_writer = tf.summary.FileWriter(LOG_DIR + "/Test")

            global_step_value, = sess.run([global_step])

            print("Last trained iteration was: ", global_step_value)

            for step in range(global_step_value + 1,
                              global_step_value + MAX_STEPS + 1):

                print("Iteration: ", step)

                images_batch, labels_batch = training_data.next_batch(
                    BATCH_SIZE)

                train_feed_dict = {
                    images: images_batch,
                    labels: labels_batch,
                    is_training: True
                }

                train_dice_value, _, train_loss_value, train_accuracy_value, train_summary_str = sess.run(
                    [dice, train_op, loss, accuracy, summary],
                    feed_dict=train_feed_dict)

                if step % SAVE_INTERVAL == 0:

                    print("Train Loss: ", train_loss_value)
                    print("Train accuracy: ", train_accuracy_value)
                    print("Train dice: ", train_dice_value)
                    train_writer.add_summary(train_summary_str, step)
                    train_writer.flush()

                    images_batch, labels_batch = test_data.next_batch(
                        BATCH_SIZE)

                    test_feed_dict = {
                        images: images_batch,
                        labels: labels_batch,
                        is_training: False
                    }

                    test_dice_value, test_loss_value, test_accuracy_value, test_summary_str = sess.run(
                        [dice, loss, accuracy, summary],
                        feed_dict=test_feed_dict)

                    print("Test Loss: ", test_loss_value)
                    print("Test accuracy: ", test_accuracy_value)
                    print("Test dice: ", test_dice_value)
                    test_writer.add_summary(test_summary_str, step)
                    test_writer.flush()

                    saver.save(sess, CHECKPOINT_FL, global_step=step)
                    print("Session Saved")
                    print("================")