def initialize():
    parser = argparse.ArgumentParser(description="Perceptual Metric")
    parser.add_argument("-f", "--filelog",
                        help="Output all logs to a daily log file instead of console.",
                        action="store_true")
    # parser.add_argument("-d", "--data",
    #                     help="Data file specified for running.",
    #                     nargs=1)
    args = vars(parser.parse_args())
    setup_logger(args["filelog"])
Exemple #2
0
def Train(cfg):
    os.environ['CUDA_DEVICES_ORDER'] = 'PCI_BUS_ID'
    os.environ['CUDA_VISIBLE_DEVICES'] = ','.join(
        [str(item) for item in cfg.TASK.GPUS])
    device = torch.device('cuda' if len(cfg.TASK.GPUS) > 0 else 'cpu')

    # init logger
    output_dir = os.path.join(cfg.TASK.OUTPUT_ROOT_DIR, cfg.TASK.NAME)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    logger = setup_logger(cfg.TASK.NAME, output_dir, distributed_rank=0)

    # data loader
    train_loader = MakeTrainLoader(
        os.path.join(cfg.DATA.ROOT_DIR, cfg.DATA.TRAIN_PATH),
        cfg.DATA.TRAIN_BATCH)
    num_images = len(train_loader.dataset)
    print('total train data: ', num_images)

    # model
    model = Net().to(device)
    # loss
    loss_funcs = nn.CrossEntropyLoss().to(device)
    # optimizer
    params = [p for n, p in model.named_parameters()]
    param_groups = [{'params': params, 'lr': 0.1}]
    # optimizer = optim.SGD(param_groups, momentum=0.9, weight_decay=5e-4)
    optimizer = optim.Adam(param_groups)
    # lr scheduler
    lr_scheduler = BuildLRScheduler(optimizer, [50, 100, 200], 0.1)

    # start train
    for epoch_idx in range(0, cfg.SOLVER.EPOCHS):
        logger.info('train epoch: {0}'.format(epoch_idx))
        TrainEpoch(epoch_idx, train_loader, model, loss_funcs, optimizer,
                   lr_scheduler, device, logger)
Exemple #3
0
from discord import Status

import configparser
from log import logger

from apps.morse_app import morse_cog
from apps.gw2_app import gw2_cog
from apps.music_app import music_cog
from apps.funny_app import fun_cog
from apps.events_app.events import WelcomeMember
from util import util
from os import environ


# Setup Logger
logger = logger.setup_logger()


# Configs object, see README for format
configs = configparser.ConfigParser()
configs.read("data/configs.ini")
# Bot object
bot = commands.Bot(command_prefix='?', description='A simple bot for discord')



@bot.event
async def on_ready():
    """ Remember """
    msg = util.welcome_console_msg(bot.user)
    print(msg)
            event.src_path
                path/to/observed/location(file|directory)
        """
        # Hit running application's URL to load data
        try:
            requests.get(self.url)
        except Exception as ex:
            logger.error("{}".format(ex))

    def on_created(self, event):
        self.process(event)


if __name__ == '__main__':
    # Logger setup
    logging.config.dictConfig(setup_logger())

    # Command Line Argument parser
    parser = argparse.ArgumentParser(
        description='Command Line Argument parser')
    parser.add_argument('--host',
                        default="localhost",
                        type=str,
                        help='Application host')
    parser.add_argument('-p',
                        '--port',
                        default=8000,
                        type=int,
                        help='Application port')
    args = parser.parse_args()