<commit_before>#!/usr/bin/python

"""
    Author: <NAME> (<EMAIL>)
    Description: trains a generative model for stylizing an unseen image input with a particular style

    Args:
        train: path to image with style to learn
"""

import argparse
import generator
import logging
import os
import tensorflow as tf
import time
import trainer

# Model Hyper Params
CONTENT_LAYER = 'conv3_3'
STYLE_LAYERS = {'conv1_2': .25, 'conv2_2': .25, 'conv3_3': .25, 'conv4_3': .25}
EPOCHS = 250000
LEARNING_RATE = .0001
TRAINING_DIMS = {'height': 256, 'width': 256}

# Loss term weights
CONTENT_WEIGHT = 1.
STYLE_WEIGHT = 3.
TV_WEIGHT = .1

# Default image paths
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
DATA_DIR_PATH = DIR_PATH + '/../lib/images/train2014/'
TRAINED_MODELS_PATH = DIR_PATH + '/../lib/generators/'
TRAIN_PATH = None

# Logging params
PRINT_TRAINING_STATUS = True
PRINT_EVERY_N = 100

# Logging config
log_dir = DIR_PATH + '/../log/'
if not os.path.isdir(log_dir):
    os.makedirs(log_dir)
    print('Directory "%s" was created for logging.' % log_dir)
log_path = ''.join([log_dir, str(time.time()), '.log'])
logging.basicConfig(filename=log_path, level=logging.INFO)


# Parse arguments and assign them to their respective global variables
def parse_args():
    global TRAIN_PATH

    # Create flags and assign values to their respective variables
    parser = argparse.ArgumentParser()
    parser.add_argument('train', help="path to image with style to learn")
    args = parser.parse_args()
    TRAIN_PATH = os.path.abspath(args.train)


parse_args()
with tf.Session() as sess:
    with tf.variable_scope('generator'):
        gen = generator.Generator()
        t = trainer.Trainer(sess, gen, TRAIN_PATH, TRAINING_DIMS, PRINT_TRAINING_STATUS, PRINT_EVERY_N)
        t.train(EPOCHS, LEARNING_RATE, CONTENT_LAYER, CONTENT_WEIGHT, STYLE_LAYERS, STYLE_WEIGHT, TV_WEIGHT)
    sess.close()<commit_msg>now alerts user where the log is being printed<commit_after>#!/usr/bin/python

"""
    Author: <NAME> (<EMAIL>)
    Description: trains a generative model for stylizing an unseen image input with a particular style

    Args:
        train: path to image with style to learn
"""

import argparse
import generator
import logging
import os
import tensorflow as tf
import time
import trainer

# Model Hyper Params
CONTENT_LAYER = 'conv3_3'
STYLE_LAYERS = {'conv1_2': .25, 'conv2_2': .25, 'conv3_3': .25, 'conv4_3': .25}
EPOCHS = 250000
LEARNING_RATE = .0001
TRAINING_DIMS = {'height': 256, 'width': 256}

# Loss term weights
CONTENT_WEIGHT = 1.
STYLE_WEIGHT = 3.
TV_WEIGHT = .1

# Default image paths
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
DATA_DIR_PATH = DIR_PATH + '/../lib/images/train2014/'
TRAINED_MODELS_PATH = DIR_PATH + '/../lib/generators/'
TRAIN_PATH = None

# Logging params
PRINT_TRAINING_STATUS = True
PRINT_EVERY_N = 100

# Logging config
log_dir = DIR_PATH + '/../log/'
if not os.path.isdir(log_dir):
    os.makedirs(log_dir)
    print('Directory "%s" was created for logging.' % log_dir)
log_path = ''.join([log_dir, str(time.time()), '.log'])
logging.basicConfig(filename=log_path, level=logging.INFO)
print("Printing log to %s" % log_path)


# Parse arguments and assign them to their respective global variables
def parse_args():
    global TRAIN_PATH

    # Create flags and assign values to their respective variables
    parser = argparse.ArgumentParser()
    parser.add_argument('train', help="path to image with style to learn")
    args = parser.parse_args()
    TRAIN_PATH = os.path.abspath(args.train)


parse_args()
with tf.Session() as sess:
    with tf.variable_scope('generator'):
        gen = generator.Generator()
        t = trainer.Trainer(sess, gen, TRAIN_PATH, TRAINING_DIMS, PRINT_TRAINING_STATUS, PRINT_EVERY_N)
        t.train(EPOCHS, LEARNING_RATE, CONTENT_LAYER, CONTENT_WEIGHT, STYLE_LAYERS, STYLE_WEIGHT, TV_WEIGHT)
    sess.close()
{'fraction_non_alphanumeric': 0.11514841351074719, 'fraction_numerical': 0.022517911975435005, 'mean_word_length': 4.28958051420839, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1297829', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1337, 'n_words': 368}