示例#1
0
def main():
    args = make_args()
    with open(args.cfg_path, 'r') as handle:
        options_yaml = yaml.load(handle)
    update_values(options_yaml, vars(args))

    # set random seed to cpu and gpu
    if args.seed:
        torch.manual_seed(args.seed)
        if args.use_cuda:
            torch.cuda.manual_seed(args.seed)

    try:
        threadpool = ThreadPool(args.batch_size)
    except Exception as e:
        print(e)
        exit(1)

    Train(args, threadpool)
    def __init__(self, opts):
        super().__init__()
        with open("./" + opts.cfg_path_tl, 'r') as handle:
            self.options_yaml_tl = yaml.load(handle)
        update_values(self.options_yaml_tl, vars(opts))
        self.mean = np.array([0.408, 0.447, 0.470],
                             dtype=np.float32).reshape(1, 1, 3)
        self.std = np.array([0.289, 0.274, 0.278],
                            dtype=np.float32).reshape(1, 1, 3)
        self.max_per_image = 100

        self.opt = opts
        self.net_inp_height, self.net_inp_width = self.opt.height, self.opt.width
        self.net_out_height, self.net_out_width = self.net_inp_height // 4, self.net_inp_width // 4
        self.num_classes = len(self.opt.classes_names)

        self.m_obj_engine = self.load_engine()
        self.detection_inputs, self.detection_outputs, self.detection_bindings, self.detection_stream = allocate_buffers(
            self.m_obj_engine)
        self.detection_context = self.m_obj_engine.create_execution_context()
示例#3
0
from torch import autograd
from torch.autograd import Variable

from models.gdan import CVAE, Generator, Discriminator, Regressor
from utils.config_gdan import parser
from utils.data_factory import DataManager
from utils.utils import load_data, update_values, get_negative_samples
from utils.logger import Logger, log_args

args = parser.parse_args()

# if yaml config exists, load and override default ones
if args.config is not None:
    with open(args.config, 'r') as fin:
        options_yaml = yaml.load(fin)
    update_values(options_yaml, vars(args))

data_dir = Path(args.data_root)
cub_dir = data_dir / Path(args.data_name)
att_path = cub_dir / Path('att_splits.mat')
res_path = cub_dir / Path('res101.mat')

save_dir = Path(args.ckpt_dir)
if not save_dir.is_dir():
    save_dir.mkdir(parents=True)

result_dir = Path(args.result)
if not result_dir.is_dir():
    result_dir.mkdir(parents=True)

result_path = save_dir / Path('gdan_loss.txt')
示例#4
0
def main():
    args = make_args()
    with open(args.cfg_path, 'r') as handle:
        options_yaml = yaml.load(handle)
    update_values(options_yaml, vars(args))
    detect_img_test(yolo_detect(args))