コード例 #1
0
def do_run(filepath,
           dataA_path,
           dataB_path,
           checkpoint_resume_path=None,
           epoch=0):
    name = filepath.split('/')[-1].replace('.py', '')
    config = loadconfig(filepath)

    print("\nRunning " + name + "\n")

    if not os.path.exists("runs"):
        os.mkdir("runs")

    checkpoints_dir = os.path.join("runs", name, "checkpoints")
    logs_dir = os.path.join("runs", name, "logs")

    if checkpoint_resume_path is None:
        os.mkdir(os.path.join("runs", name))
        os.mkdir(checkpoints_dir)
        shutil.copy2(filepath, os.path.join("runs", name, "config.py"))

    model = CycleGANBase(config,
                         dataA_path,
                         dataB_path,
                         logs_dir,
                         checkpoints_dir,
                         checkpoint_resume_path,
                         epoch=epoch)
    model.train()
    model.reset_session()
コード例 #2
0
ファイル: user_interface.py プロジェクト: S3DEV/utils
    def __init__(self):
        """
        Initialise the class.

        PURPOSE:
        This constructor initialises colorama, which enables the user
        to print coloured text to the CLI. It also reads the config
        file, which is used throughout the class.

        COLORAMA BACKGROUND:
        Colorama is initialised here to 'strip ANSI characters from
        stdout and convert them into the equivalent win32 calls'; per
        Jonathan Hartley, author of Colorama.

        The Win32 console (excluding *some* versions of Win10) does not
        support ANSI escape sequences, and therefore simply printing
        the escape sequence to the native Win CLI with the text does
        not work.  So we use Colorama for the low-level win32 work.
        """

        # COLORAMA INITIALISATION
        colourinit()

        # SET LOCATION OF THE UI CONFIG FILE EXPLICITLY (SHOULD WORK FOR WIN AND LINUX)
        ui_config_file = os.path.join(
            os.path.realpath(os.path.dirname(__file__)),
            'user_interface_config.json')
        # LOAD CONFIG FILE
        self._cfg = config.loadconfig(filename=ui_config_file)

        # BUILD REFERENCE DICTS OF COLORAMA FORE / BACK / STYLE
        self._fore = self._build_color_dict(class_=Fore)
        self._back = self._build_color_dict(class_=Back)
        self._style = self._build_color_dict(class_=Style)
コード例 #3
0
ファイル: test_config.py プロジェクト: S3DEV/utils
    def test_config_defaults(self):

        #PULL IN CONFIG
        conf = config.loadconfig(filename=self._file, devmode=True)

        #RUN TESTS
        self.assertTrue(self._test_general(conf))
コード例 #4
0
ファイル: test_config.py プロジェクト: S3DEV/utils
    def test_config_fullpath(self):

        #PULL IN CONFIG
        conf = config.loadconfig(filename=os.path.join(self._path, self._file),
                                 devmode=True)

        #RUN TESTS
        self.assertTrue(self._test_general(conf))
コード例 #5
0
def do_run(filepath, dataset_path, extension=""):
    name = filepath.split('/')[-1].replace('.py', '') + extension
    config = loadconfig(filepath)

    print("\nRunning "+name+"\n")

    os.mkdir("./runs/" + name)
    shutil.copy2(filepath, './runs/' + name + "/rcgan_config.py")
    checkpoints_dir = "./runs/" + name + "/checkpoints/"
    logs_dir = "./runs/" + name + "/logs/"

    run(config, dataset_path, logs_dir, checkpoints_dir, checkpoints=True)
コード例 #6
0
import sys
import time
import numpy as np
import tensorflow as tf
from tensorflow.contrib import slim

import utils.config as conf
from utils.tf_flags import load_east_flag_parameters

fp_config = sys.argv[1]
conf.loadconfig(fp_config)

load_east_flag_parameters()
FLAGS = tf.app.flags.FLAGS

import model
import icdar

gpus = list(range(len(FLAGS.gpu_list.split(','))))


def tower_loss(images,
               score_maps,
               geo_maps,
               training_masks,
               reuse_variables=None):
    # Build inference graph
    with tf.variable_scope(tf.get_variable_scope(), reuse=reuse_variables):
        f_score, f_geometry = model.model(images, is_training=True)

    model_loss = model.loss(score_maps, f_score, geo_maps, f_geometry,
コード例 #7
0
ファイル: user_interface.py プロジェクト: S3DEV/utils
    def __init__(self,
                 name=None,
                 version=None,
                 desc=None,
                 info=None,
                 chars=72,
                 ribbon='-',
                 fore='white',
                 back='black',
                 style='bright'):
        """
        Display program info to the CLI at the start of a program.

        DESIGN:
        In short, if the 'info' parameter is left as None, a default
        banner is generated using the values passed into the name,
        version and desc parameters.

        The string templates used for the banner layout may be
        configured in the UI config file.

        Additional configuration is available through the other
        parameters, which are all defined in the PARAMETERS section
        below.

        Also, the title of the console window is updated to show the
        program's name and version, if all of the following criteria
        are met:
            - Windows OS
            - name parameter is not None
            - version parameter is not None

        BASIC PARAMETERS:
        - name
        Name of your program.
        - version
        The version number of your program.
        - desc
        Description of what your program is all about.

        INFO PARAMETER:
        - info
        The info parameter is used to generate a completely customised
        banner.  Basically, whatever key/value pairs you pass in, are
        what will be printed in the banner.

        This parameter accepts a list of dictionaries.  For example:
        info = [{'Program':'bob_the_great'},
                {'Version':'2.0.3'},
                {'':''},
                {'Description':'Gives proof why Bob is great.'},
                {'Comments':'Some more reasons Bob is so great.'}]

        This info parameter would be parsed into:
        ----------------------------------------------------------------
         Program          :    bob_the_great
         Version          :    2.0.3

         Description      :    Gives proof why Bob is great.
         Comments         :    Some more reasons Bob is so great.
        ----------------------------------------------------------------

        CONFIG PARAMETERS:
        - chars
        In the number of characters, the size of the buffer used for
        the background colour, and the length of the ribbon.
        - ribbon
        The character(s) to use for the ribbon.
        If multiple characters are passed into this parameter, these
        characters will be repeated until the length of the 'chars'
        parameter is met.
        - fore
        Text colour.  The eight basic colour names are accepted as
        strings.
        - back
        Background colour.  The eight basic colour names are accepted
        as strings.
        - style
        Brightness of the text/background.  Accepted strings:
            - dim
            - bright (default)
            - normal

        USE:
        import utils.user_interface as ui
        ui.PrintBanner(name='bob_the_great', version='2.0.3',
                       desc='Gives proof why Bob is so great.',
                       chars=55, ribbon='~-', fore='yellow',
                       back='black', style='bright')

        Will print this:
        ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
         Program        :    bob_the_great
         Version        :    2.0.3

         Description    :    Gives proof why Bob is so great.
        ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
        """

        # SET LOCATION OF THE UI CONFIG FILE EXPLICITLY
        conf_file = os.path.join(os.path.realpath(os.path.dirname(__file__)),
                                 'user_interface_config.json')

        # INITIALISE
        self._name = name
        self._version = version
        self._desc = desc
        self._info = info
        self._chars = chars
        self._ribbon = ribbon * (chars / len(ribbon))
        self._fore = fore
        self._back = back
        self._style = style
        self._to_print = []
        self._blank = ''
        self._spaces = ' ' * 4
        self._pad = 15
        self._adtl = 4
        self._cfg = config.loadconfig(conf_file)
        self._ui = UserInterface()

        # PRINT PROGRAM INFO BANNER
        self._print_prog_banner()

        # UPDATE CONSOLE WINDOW TITLE
        self._update_console_title()