Exemplo n.º 1
0
def main():
    parser = OptionParser([
        SceneOps(),
        AlgorithmOps(),
        MetricOps(),
        VisualizationOps(),
        OverwriteOps(),
        MetaAlgorithmOps(default=[])
    ])
    scenes, algorithms, metrics, with_vis, add_to_existing, meta_algorithms, compute_meta_algos = parser.parse_args(
    )

    # delay import to speed up usage response
    from toolkit import settings
    from toolkit.algorithms import MetaAlgorithm
    from toolkit.evaluations import submission_evaluation
    from toolkit.utils import misc

    if compute_meta_algos and meta_algorithms:
        MetaAlgorithm.prepare_meta_algorithms(meta_algorithms, algorithms,
                                              scenes)

    algorithms += meta_algorithms

    for algorithm in algorithms:
        evaluation_output_path = op.join(settings.ALGO_EVAL_PATH,
                                         algorithm.get_name())
        algorithm_input_path = misc.get_path_to_algo_data(algorithm)
        submission_evaluation.evaluate(
            scenes=scenes,
            metrics=metrics,
            visualize=with_vis,
            evaluation_output_path=evaluation_output_path,
            algorithm_input_path=algorithm_input_path,
            add_to_existing_results=add_to_existing)
Exemplo n.º 2
0
def main():
    parser = OptionParser([SceneOps(), AlgorithmOps(with_gt=True), MetaAlgorithmOps(default=[])])
    scenes, algorithms, meta_algorithms, compute_meta_algos = parser.parse_args()

    # delay imports to speed up usage response
    from toolkit import settings
    from toolkit.algorithms import MetaAlgorithm
    from toolkit.utils import log, misc, point_cloud

    if compute_meta_algos and meta_algorithms:
        MetaAlgorithm.prepare_meta_algorithms(meta_algorithms, algorithms, scenes)

    algorithms += meta_algorithms

    for scene in scenes:
        center_view = scene.get_center_view()

        for algorithm in algorithms:
            if algorithm.get_name() == "gt":
                disp_map = scene.get_gt()
            else:
                disp_map = misc.get_algo_result(algorithm, scene)

            log.info("Creating point cloud for scene '%s' with '%s' disparity map." %
                     (scene.get_name(), algorithm.get_name()))

            pc = point_cloud.convert(scene, disp_map, center_view)

            file_name = "%s_%s.ply" % (scene.get_name(), algorithm.get_name())
            file_path = op.join(settings.EVAL_PATH, "point_clouds", file_name)
            log.info("Saving point cloud to: %s" % file_path)
            point_cloud.save(pc, file_path)
Exemplo n.º 3
0
def main():
    parser = OptionParser([
        AlgorithmOps(),
        SceneOps(),
        MetaAlgorithmOps(with_load_argument=False)
    ])
    algorithms, scenes, meta_algorithms = parser.parse_args()

    from toolkit.algorithms import MetaAlgorithm
    MetaAlgorithm.prepare_meta_algorithms(meta_algorithms, algorithms, scenes)
Exemplo n.º 4
0
def main():
    parser = OptionParser([SceneOps(), AlgorithmOps(), MetaAlgorithmOps(default=[])])
    scenes, algorithms, meta_algorithms, compute_meta_algos = parser.parse_args()

    # delay imports to speed up usage response
    from toolkit.algorithms import MetaAlgorithm
    from toolkit.evaluations import bad_pix_series

    if compute_meta_algos and meta_algorithms:
        MetaAlgorithm.prepare_meta_algorithms(meta_algorithms, algorithms, scenes)

    bad_pix_series.plot(algorithms+meta_algorithms, scenes)
def main():
    parser = OptionParser([SceneOps(), AlgorithmOps(), MetricOps(), MetaAlgorithmOps(default=[])])
    scenes, algorithms, metrics, meta_algorithms, compute_meta_algos = parser.parse_args()

    # delay imports to speed up usage response
    from toolkit.algorithms import MetaAlgorithm
    from toolkit.evaluations import metric_overviews

    if compute_meta_algos and meta_algorithms:
        MetaAlgorithm.prepare_meta_algorithms(meta_algorithms, algorithms, scenes)

    metric_overviews.plot_general_overview(algorithms+meta_algorithms, scenes, metrics)
Exemplo n.º 6
0
def main():
    parser = OptionParser([SceneOps(), AlgorithmOps(), MetaAlgorithmOps()])
    scenes, algorithms, meta_algorithms, compute_meta_algos = parser.parse_args(
    )

    # delay imports to speed up usage response
    from toolkit.algorithms import MetaAlgorithm
    from toolkit.evaluations import meta_algo_comparisons

    if compute_meta_algos and meta_algorithms:
        MetaAlgorithm.prepare_meta_algorithms(meta_algorithms, algorithms,
                                              scenes)

    for meta_algorithm in meta_algorithms:
        meta_algo_comparisons.plot(algorithms, scenes, meta_algorithm)
Exemplo n.º 7
0
    def __call__(self, parser, namespace, values, option_string=None):
        from toolkit.utils import misc
        from toolkit.algorithms import Algorithm, MetaAlgorithm

        ignore = [a.get_name() for a in MetaAlgorithm.get_meta_algorithms()]
        available_algo_names = [
            a for a in misc.get_available_algo_names() if a not in ignore
        ]

        if not values:
            # use given default or all available algorithms
            if self.default_algo_names is not None:
                algo_names = [
                    a for a in self.default_algo_names
                    if a in available_algo_names
                ]
            else:
                algo_names = available_algo_names
        else:
            # otherwise: check if selected algorithms exist
            algo_names = []
            for algo_name in values:
                if algo_name not in available_algo_names and algo_name != "gt":
                    parser.error("Could not find algorithm for: %s.\n  "
                                 "Available options are: %s." %
                                 (algo_name, ", ".join(available_algo_names)))
                else:
                    algo_names.append(algo_name)

        # create algorithm objects
        algorithms = Algorithm.initialize_algorithms(algo_names)

        # save result in action destination
        setattr(namespace, self.dest, algorithms)
def main():
    parser = OptionParser(
        [AlgorithmOps(),
         SceneOps(), MetaAlgorithmOps(default=[])])
    algorithms, scenes, meta_algorithms, compute_meta_algos = parser.parse_args(
    )

    # delay imports to speed up usage response
    from toolkit.algorithms import MetaAlgorithm
    from toolkit.evaluations import pairwise_algo_comparisons

    if compute_meta_algos and meta_algorithms:
        MetaAlgorithm.prepare_meta_algorithms(meta_algorithms, algorithms,
                                              scenes)

    pairwise_algo_comparisons.plot_pairwise_comparisons(
        algorithms + meta_algorithms, scenes)
Exemplo n.º 9
0
    def add_arguments(self, parser):
        from toolkit.algorithms import MetaAlgorithm

        # prepare algorithm options
        algorithms_by_name = {
            algo.get_name().replace("per_pix_", ""): algo
            for algo in MetaAlgorithm.get_meta_algorithms()
        }
        meta_algorithm_keys = sorted(algorithms_by_name.keys())

        if self.default is None:
            self.default = meta_algorithm_keys

        # prepare help text
        option_text = ", ".join(meta_algorithm_keys)
        default_text = " ".join(
            self.default) if self.default else "no meta algorithm"

        # add arguments
        actions = list()
        actions.append(
            parser.add_argument("-p",
                                dest="meta_algorithms",
                                action=MetaAlgorithmAction,
                                algorithms_by_name=algorithms_by_name,
                                default_algo_names=self.default,
                                type=str,
                                nargs="+",
                                help='list of meta algorithm names\n'
                                'example: "-a best mean"\n'
                                'default: %s\n'
                                'options: %s' % (default_text, option_text)))

        if self.with_load_argument:
            actions.append(
                parser.add_argument("-u",
                                    "--use_existing_meta_files",
                                    dest="compute_meta_algos",
                                    action="store_false",
                                    help="use existing meta algorithm files "
                                    "(per default, meta algorithms\n"
                                    "are computed from scratch "
                                    "based on list of 'regular' algorithms)"))
        return actions