def make_config(experiment: sacred.Experiment) -> None: """Adds configs and named configs to `experiment`. The standard config parameters it defines are: - env_name (str): The environment name in the Gym registry of the rewards to compare. - x_reward_cfgs (Iterable[common_config.RewardCfg]): tuples of reward_type and reward_path for x-axis. - y_reward_cfgs (Iterable[common_config.RewardCfg]): tuples of reward_type and reward_path for y-axis. - log_root (str): the root directory to log; subdirectory path automatically constructed. - n_bootstrap (int): the number of bootstrap samples to take. - alpha (float): percentile confidence interval - aggregate_kinds (Iterable[str]): the type of aggregations to perform across seeds. Not used in `plot_return_heatmap` which only supports its own kind of bootstrapping. - heatmap_kwargs (dict): passed through to `analysis.compact_heatmaps`. - styles (Iterable[str]): styles to apply from `evaluating_rewards.analysis.stylesheets`. - save_kwargs (dict): passed through to `analysis.save_figs`. """ # pylint: disable=unused-variable,too-many-statements @experiment.config def default_config(): """Default configuration values.""" data_root = serialize.get_output_dir() # where models are read from log_root = serialize.get_output_dir() # where results are written to n_bootstrap = 1000 # number of bootstrap samples alpha = 95 # percentile confidence interval aggregate_kinds = ("bootstrap", "studentt", "sample") _ = locals() del _ @experiment.config def aggregate_fns(aggregate_kinds, n_bootstrap, alpha): """Make a mapping of aggregate functions of kinds `subset` with specified parameters. Used in scripts.distances.{epic,npec}; currently ignored by erc since it does not use multiple seeds and instead bootstraps over samples. """ aggregate_fns = {} if "bootstrap" in aggregate_kinds: aggregate_fns["bootstrap"] = functools.partial( bootstrap_ci, n_bootstrap=n_bootstrap, alpha=alpha) if "studentt" in aggregate_kinds: aggregate_fns["studentt"] = functools.partial(studentt_ci, alpha=alpha) if "sample" in aggregate_kinds: aggregate_fns["sample"] = sample_mean_sd @experiment.config def point_mass_as_default(): """Default to PointMass as environment so scripts work out-of-the-box.""" locals().update(**common_config.COMMON_CONFIGS["point_mass"]) for name, cfg in common_config.COMMON_CONFIGS.items(): experiment.add_named_config(name, cfg)
from tracktor.motion.model_reid import MotionModelReID from tracktor.motion.model_simple_reid import MotionModelSimpleReID from tracktor.motion.model_simple_reid_v2 import MotionModelSimpleReIDV2 from tracktor.motion.model_v3 import MotionModelV3 from tracktor.motion.vis_simple_reid import VisSimpleReID from tracktor.motion.refine_model import RefineModel from tracktor.reid.resnet import resnet50 from tracktor.utils import interpolate, plot_sequence, get_mot_accum, evaluate_mot_accums ex = Experiment() ex.add_config('experiments/cfgs/tracktor.yaml') # hacky workaround to load the corresponding configs and not having to hardcode paths here ex.add_config(ex.configurations[0]._conf['tracktor']['reid_config']) ex.add_named_config('oracle', 'experiments/cfgs/oracle_tracktor.yaml') @ex.automain def main(tracktor, reid, _config, _log, _run): sacred.commands.print_config(_run) # set all seeds torch.manual_seed(tracktor['seed']) torch.cuda.manual_seed(tracktor['seed']) np.random.seed(tracktor['seed']) torch.backends.cudnn.deterministic = True output_dir = osp.join(get_output_dir(tracktor['module_name']), tracktor['name']) sacred_config = osp.join(output_dir, 'sacred_config.yaml')
import torchvision import yaml from tqdm import tqdm import sacred from sacred import Experiment from tracktor.frcnn_fpn import FRCNN_FPN from tracktor.config import get_output_dir from tracktor.datasets.factory import Datasets from tracktor.oracle_tracker import OracleTracker from tracktor.tracker import Tracker from tracktor.reid.resnet import resnet50 from tracktor.utils import interpolate, plot_sequence, get_mot_accum, evaluate_mot_accums ex = Experiment() ex.add_config('experiments/cfgs/tracktor.yaml') ex.add_named_config('cfg1', 'experiments/cfgs/hp_search/cfg1.yaml') ex.add_named_config('cfg_caro_ws1', 'experiments/cfgs/hp_search/cfg_caro_ws1.yaml') ex.add_named_config('cfg_caro_ws2', 'experiments/cfgs/hp_search/cfg_caro_ws2.yaml') ex.add_named_config('cfg_caro_ws3', 'experiments/cfgs/hp_search/cfg_caro_ws3.yaml') ex.add_named_config('cfg_caro_local', 'experiments/cfgs/hp_search/cfg_caro_local.yaml') ########### DEFAULT################ # hacky workaround to load the corresponding configs and not having to har # dcode paths here ex.add_config(ex.configurations[0]._conf['tracktor']['reid_config']) ex.add_named_config('oracle', 'experiments/cfgs/oracle_tracktor.yaml')
from tracktor.frcnn_fpn import FRCNN_FPN from tracktor.config import get_output_dir from tracktor.datasets.factory import Datasets from tracktor.oracle_tracker import OracleTracker from tracktor.motion import Seq2Seq, CorrelationSeq2Seq, RelativeCorrelationModel from tracktor.tracker import Tracker from tracktor.reid.resnet import resnet50 from tracktor.utils import interpolate, plot_sequence, get_mot_accum, evaluate_mot_accums mm.lap.default_solver = 'lap' ex = Experiment() ex.add_config('experiments/cfgs/tracktor.yaml') # hacky workaround to load the corresponding configs and not having to hardcode paths here ex.add_config(ex.configurations[0]._conf['tracktor']['reid_config']) ex.add_named_config('oracle', 'experiments/cfgs/oracle_tracktor.yaml') ex.add_named_config('correlation_model', 'experiments/cfgs/correlation_model.yaml') ex.add_named_config('pos_model', 'experiments/cfgs/pos_model.yaml') ex.add_named_config('cva_model', 'experiments/cfgs/cva_model.yaml') @ex.automain def main(tracktor, reid, _config, _log, _run): sacred.commands.print_config(_run) # set all seeds torch.manual_seed(tracktor['seed']) torch.cuda.manual_seed(tracktor['seed']) np.random.seed(tracktor['seed']) torch.backends.cudnn.deterministic = True
num_env_steps = 100e6 eval_dir = "./results/video/{id}" loss_dir = "./results/loss/{id}" save_dir = "./results/trained_models/{id}" log_interval = 2000 save_interval = int(1e6) eval_interval = int(1e6) episodes_per_eval = 8 for conf in glob.glob("configs/*.yaml"): name = f"{Path(conf).stem}" ex.add_named_config(name, conf) def _squash_info(info): info = [i for i in info if i] new_info = {} keys = set([k for i in info for k in i.keys()]) keys.discard("TimeLimit.truncated") for key in keys: mean = np.mean([np.array(d[key]).sum() for d in info if key in d]) new_info[key] = mean return new_info @ex.capture def evaluate( agents,
help='bbox score threshold') args = parser.parse_args() return args device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') torch.cuda.set_device(0) print('Using device:', device) ex = Experiment() ex.add_config('tracking_wo_bnw/experiments/cfgs/tracktor.yaml') # hacky workaround to load the corresponding configs and not having to hardcode paths here ex.add_config(ex.configurations[0]._conf['tracktor']['reid_config']) ex.add_named_config('oracle', 'tracking_wo_bnw/experiments/cfgs/oracle_tracktor.yaml') tracktor = ex.configurations[0].__call__()['tracktor'] reid = ex.configurations[1].__call__()['reid'] # set all seeds torch.manual_seed(tracktor['seed']) torch.cuda.manual_seed(tracktor['seed']) np.random.seed(tracktor['seed']) torch.backends.cudnn.deterministic = True output_dir = tracktor['output_dir'] sacred_config = osp.join(output_dir, 'sacred_config.yaml') if not osp.exists(output_dir): os.makedirs(output_dir)
dt = 10 # how many steps to include in the last loss log_dir = 'debug_out' # directory to dump logs and debug plots net_path = None # path of to network file to initialize weights with # config to control run_from_file run_config = { 'usage': 'test', # what dataset to use {training, validation, test} 'batch_size': 100, 'rollout_steps': 10, 'debug_samples': [0, 1, 2], # sample ids to generate plots for (None, int, list) } ex.add_named_config('no_score', {'record_grouping_score': False}) ex.add_named_config('no_collisions', {'record_relational_loss': None}) @ex.capture def add_noise(data, noise): noise_type = noise['noise_type'] if noise_type in ['None', 'none', None]: return data n = torch.bernoulli(noise['prob'] * torch.ones(data.size())) p = 2 * torch.mul(data, n) corrupted = data + n - p # hacky way of implementing (data XOR n) return corrupted
finalvideo=12 if finalvideo==1: ex = Experiment() ex.add_config('C:/Users/EloiMartins/PycharmProjects/tracking_wo_bnw/experiments/cfgs/tracktor.yaml') # hacky workaround to load the corresponding configs and not having to hardcode paths here ex.add_config(ex.configurations[0]._conf['tracktor']['reid_config']) ex.add_named_config('oracle', 'C:/Users/EloiMartins/PycharmProjects/tracking_wo_bnw/experiments/cfgs/tracktor.yaml') @ex.automain def main(tracktor, reid, _config, _log, _run): sacred.commands.print_config(_run) # set all seeds torch.manual_seed(tracktor['seed']) torch.cuda.manual_seed(tracktor['seed']) np.random.seed(tracktor['seed']) torch.backends.cudnn.deterministic = True output_dir = osp.join(get_output_dir(tracktor['module_name']), tracktor['name']) sacred_config = osp.join(output_dir, 'sacred_config.yaml')
if context.epoch % context.cfg.tracktor_val_every == 0 and context.validate: with torch.no_grad(): metrics = { **metrics, **self.validate_tracktor(context.model, context.epoch) } return metrics ex = Experiment() ex.add_config('experiments/cfgs/tracktor.yaml') ex.add_config('experiments/cfgs/train_motion_im.yaml') ex.add_config(ex.configurations[0]._conf['tracktor']['reid_config']) ex.add_named_config('correlation_model', 'experiments/cfgs/correlation_model.yaml') ex.add_named_config('pos_model', 'experiments/cfgs/pos_model.yaml') @ex.automain def main(tracktor, reid, train, _config, _log, _run): # instantiate tracktor sacred.commands.print_config(_run) # set all seeds seed_everything(tracktor['seed']) output_dir = osp.abspath( osp.join(osp.dirname(__file__), '..', '..', 'output', 'motion', train['name'])) sacred_config = osp.join(output_dir, 'sacred_config.yaml')
from tracktor.frcnn_fpn import FRCNN_FPN from tracktor.frcnn_fpn_detectron2 import FRCNN_FPN_Detectron2 from tracktor.config import get_output_dir from tracktor.datasets.factory import Datasets from tracktor.oracle_tracker import OracleTracker from tracktor.tracker import Tracker from tracktor.reid.resnet import resnet50 from tracktor.utils import interpolate, plot_sequence, get_mot_accum, evaluate_mot_accums ex = Experiment() ex.add_config('experiments/cfgs/tracktor.yaml') # hacky workaround to load the corresponding configs and not having to hardcode paths here ex.add_config(ex.configurations[0]._conf['tracktor']['reid_config']) ex.add_named_config('oracle', 'experiments/cfgs/oracle_tracktor.yaml') ex.add_named_config( 'detectron2_coco_r50fpn1x_no_camera_no_reid', 'experiments/cfgs/tracktor_detectron2_r50fpn1x_coco_no_camera_no_reid.yaml' ) @ex.automain def main(tracktor, reid, _config, _log, _run): sacred.commands.print_config(_run) # set all seeds torch.manual_seed(tracktor['seed']) torch.cuda.manual_seed(tracktor['seed']) np.random.seed(tracktor['seed']) torch.backends.cudnn.deterministic = True