# Path: options/options_test.py
# def add_general_arguments(parser):
# def parse(add_additional_arguments=None):
# 
# Path: util/util_print.py
# class bcolors:
#     HEADER = '\033[95m'
#     OKBLUE = '\033[94m'
#     OKGREEN = '\033[92m'
#     WARNING = '\033[93m'
#     FAIL = '\033[91m'
#     ENDC = '\033[0m'
#     BOLD = '\033[1m'
#     UNDERLINE = '\033[4m'
# 
# Path: loggers/loggers.py
# class BaseLogger(object):
# class _LogCumulator(BaseLogger):
# class ProgbarLogger(BaseLogger):
# class CsvLogger(BaseLogger):
# class BatchCsvLogger(BaseLogger):
# class ModelSaveLogger(BaseLogger):
# class TerminateOnNaN(BaseLogger):
# class TensorBoardLogger(BaseLogger):
# class HtmlLogger(BaseLogger):
# class ComposeLogger(BaseLogger):
#     def __init__(self):
#     def set_mute(self):
#     def on_train_begin(self):
#     def on_train_end(self):
#     def on_epoch_begin(self, epoch):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def set_params(self, params):
#     def set_model(self, model):
#     def train(self):
#     def eval(self):
#     def _set_unused_metric_mode(self, mode='none'):
#     def _allow_unused(self):
#     def __init__(self):
#     def on_epoch_begin(self, epoch):
#     def on_batch_end(self, batch, batch_log):
#     def get_epoch_log(self):
#     def __init__(self, count_mode='samples', allow_unused_fields='none', interval=10, no_accum=False):
#     def on_train_begin(self):
#     def on_epoch_begin(self, epoch):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def on_epoch_end(self, epoch, epoch_log):
#     def __init__(self, filename, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_train_end(self):
#     def __init__(self, filename, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def on_batch_end(self, batch, batch_log=None):
#     def on_train_end(self):
#     def __init__(self, filepath, period=1, save_optimizer=False, save_best=False, prev_best=None):
#     def on_train_begin(self):
#     def on_epoch_end(self, epoch, epoch_log):
#     def __init__(self):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def __init__(self, filepath, use_html_logger=False, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_train_end(self):
#     def __init__(self, summary_filepath, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def flush(self):
#     def on_epoch_begin(self, epoch):
#     def on_epoch_end(self, epoch, *args, **kargs):
#     def content_to_html(self):
#     def summary_to_html(self):
#     def __init__(self, loggers):
#     def get_tensorboard(self):
#     def get_html_logger(self):
#     def add_logger(self, logger):
#     def on_train_begin(self):
#     def on_train_end(self):
#     def on_epoch_begin(self, epoch):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def set_params(self, params):
#     def set_model(self, model):
#     def train(self):
#     def eval(self):


import os
import time
import torch
import datasets
import models
import util.util_loadlib as loadlib
from os.path import join
from shutil import rmtree
from tqdm import tqdm
from options import options_test
from util.util_print import str_error, str_stage, str_verbose
from loggers import loggers
from argparse import Namespace
opt_dict = torch.load(join(opt.checkpoint_path, 'opt.pt'))
opt_train = Namespace(**opt_dict)
opt_train.global_rank = 0
opt_train.output_dir = opt.output_dir
model = Model(opt_train, logger)
if hasattr(opt_train, 'midas'):
    opt.midas = opt_train.midas

# checkpoint_path
if opt.epoch < 0:
    net_file = join(opt.checkpoint_path, 'best.pt')
else:
    net_file = join(opt.checkpoint_path, 'nets', '%04d.pt' % opt.epoch)


###################################################
print(str_stage, "Setting up data loaders")
start_time = time.time()
Dataset = datasets.get_dataset(opt_train.dataset)
dataset = Dataset(opt_train, mode='vali', model=model)
dataloader = torch.utils.data.DataLoader(
    dataset,
    batch_size=opt.batch_size,
    num_workers=opt.workers,
    pin_memory=True,
    drop_last=False,
    shuffle=False
)
n_batches = len(dataloader)
dataiter = iter(dataloader)

# Path: options/options_test.py
# def add_general_arguments(parser):
# def parse(add_additional_arguments=None):
# 
# Path: util/util_print.py
# class bcolors:
#     HEADER = '\033[95m'
#     OKBLUE = '\033[94m'
#     OKGREEN = '\033[92m'
#     WARNING = '\033[93m'
#     FAIL = '\033[91m'
#     ENDC = '\033[0m'
#     BOLD = '\033[1m'
#     UNDERLINE = '\033[4m'
# 
# Path: loggers/loggers.py
# class BaseLogger(object):
# class _LogCumulator(BaseLogger):
# class ProgbarLogger(BaseLogger):
# class CsvLogger(BaseLogger):
# class BatchCsvLogger(BaseLogger):
# class ModelSaveLogger(BaseLogger):
# class TerminateOnNaN(BaseLogger):
# class TensorBoardLogger(BaseLogger):
# class HtmlLogger(BaseLogger):
# class ComposeLogger(BaseLogger):
#     def __init__(self):
#     def set_mute(self):
#     def on_train_begin(self):
#     def on_train_end(self):
#     def on_epoch_begin(self, epoch):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def set_params(self, params):
#     def set_model(self, model):
#     def train(self):
#     def eval(self):
#     def _set_unused_metric_mode(self, mode='none'):
#     def _allow_unused(self):
#     def __init__(self):
#     def on_epoch_begin(self, epoch):
#     def on_batch_end(self, batch, batch_log):
#     def get_epoch_log(self):
#     def __init__(self, count_mode='samples', allow_unused_fields='none', interval=10, no_accum=False):
#     def on_train_begin(self):
#     def on_epoch_begin(self, epoch):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def on_epoch_end(self, epoch, epoch_log):
#     def __init__(self, filename, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_train_end(self):
#     def __init__(self, filename, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def on_batch_end(self, batch, batch_log=None):
#     def on_train_end(self):
#     def __init__(self, filepath, period=1, save_optimizer=False, save_best=False, prev_best=None):
#     def on_train_begin(self):
#     def on_epoch_end(self, epoch, epoch_log):
#     def __init__(self):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def __init__(self, filepath, use_html_logger=False, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_train_end(self):
#     def __init__(self, summary_filepath, allow_unused_fields='none'):
#     def on_train_begin(self):
#     def flush(self):
#     def on_epoch_begin(self, epoch):
#     def on_epoch_end(self, epoch, *args, **kargs):
#     def content_to_html(self):
#     def summary_to_html(self):
#     def __init__(self, loggers):
#     def get_tensorboard(self):
#     def get_html_logger(self):
#     def add_logger(self, logger):
#     def on_train_begin(self):
#     def on_train_end(self):
#     def on_epoch_begin(self, epoch):
#     def on_epoch_end(self, epoch, epoch_log):
#     def on_batch_begin(self, batch):
#     def on_batch_end(self, batch, batch_log):
#     def set_params(self, params):
#     def set_model(self, model):
#     def train(self):
#     def eval(self):


# Path: test.py
import os
import time
import torch
import datasets
import models
import util.util_loadlib as loadlib
from os.path import join
from shutil import rmtree
from tqdm import tqdm
from options import options_test
from util.util_print import str_error, str_stage, str_verbose
from loggers import loggers
from argparse import Namespace

opt_dict = torch.load(join(opt.checkpoint_path, 'opt.pt'))
opt_train = Namespace(**opt_dict)
opt_train.global_rank = 0
opt_train.output_dir = opt.output_dir
model = Model(opt_train, logger)
if hasattr(opt_train, 'midas'):
    opt.midas = opt_train.midas

# checkpoint_path
if opt.epoch < 0:
    net_file = join(opt.checkpoint_path, 'best.pt')
else:
    net_file = join(opt.checkpoint_path, 'nets', '%04d.pt' % opt.epoch)


###################################################
print(str_stage, "Setting up data loaders")
start_time = time.time()
Dataset = datasets.get_dataset(opt_train.dataset)
dataset = Dataset(opt_train, mode='vali', model=model)
dataloader = torch.utils.data.DataLoader(
    dataset,
    batch_size=opt.batch_size,
    num_workers=opt.workers,
    pin_memory=True,
    drop_last=False,
    shuffle=False
)
n_batches = len(dataloader)
dataiter = iter(dataloader)

print(str_verbose, "Time spent in data IO initialization: %.2fs" %