Пример #1
0
    def build_list_and_evaluate_and_save_chart(
            self, list_results: List, gt_graph: GraphDataStruct,
            only_decisions: List[scoring_datastrutures.DecisionTypes],
            output_folder: pathlib.Path):

        # Generate name of the list
        generated_name = "".join([d.name + "_"
                                  for d in only_decisions]) + "only"

        # Filter out results
        results_list_filtered = [
            self.filter_out_request_result(r, only_decisions)
            for r in list_results
        ]
        json_import_export.save_json(
            results_list_filtered,
            pathlib.Path(get_homedir() / (generated_name + ".json")))

        perfs_list_filtered = self._compute_perfs_list(results_list_filtered,
                                                       gt_graph)
        # Save to graph
        twoDplot = two_dimensions_plot.TwoDimensionsPlot()
        twoDplot.print_graph(perfs_list_filtered,
                             output_folder,
                             file_name=(generated_name + ".png"))
    def get_proximity_graph_and_evaluate(self, image_folder: pathlib.Path, output_path: pathlib.Path, gt_path: pathlib.Path):
        list_results, _ = self.get_proximity_graph(image_folder, output_path)
        perfs_list = self.evaluate_list_results(list_results, gt_path, output_path)

        # Save to file
        json_import_export.save_json(perfs_list, output_path / "perfs_list.json")
        self.logger.debug(f"Performance list saved.")

        # Save to graph
        twoDplot = two_dimensions_plot.TwoDimensionsPlot()
        twoDplot.print_graph(perfs_list, output_path)
Пример #3
0
    def print_data(self,
                   scalabilitygraph: ScalabilityData,
                   output_folder: pathlib.Path,
                   file_name: str = "scalability_graph.pdf"):
        twoDplot = two_dimensions_plot.TwoDimensionsPlot()
        twoDplot.print_scalability_data(scalabilitygraph, output_folder,
                                        file_name)

        # Save to file
        json_import_export.save_json(scalabilitygraph.list_request_time,
                                     output_folder / "scalability_graph.json")
        self.logger.info("Results scalability_graph json saved.")
Пример #4
0
    def launch(self):
        # ========= INPUTS =========
        # Input files folder
        image_folder = get_homedir() / "datasets" / "MINI_DATASET"
        # Ground truth file
        gt = get_homedir() / "datasets" / "MINI_DATASET_VISJS.json"
        # Output general folder
        output_folder = get_homedir() / "datasets" / "OUTPUT"
        output_folder.mkdir(parents=True, exist_ok=True)

        # ========= GOAL =========
        perfs = []

        iterations_limit = 50  # Or nb of iteration if complete exploration

        max_threshold = 1
        min_threshold = 0

        # ========= CONFIGURATION CHOSING =========

        for i in range(iterations_limit):

            # Computing the new threshold
            curr_threshold = i * (
                (max_threshold - min_threshold) / iterations_limit)
            self.logger.info(
                f"Current threshold computation : {curr_threshold}")

            # If the instance already exist, delete it
            if self.server_launcher is not None:
                del self.server_launcher

            # Put configuration in place
            self.server_launcher = instance_handler.Instance_Handler()
            self.server_launcher.dist_conf.MAX_DIST_FOR_NEW_CLUSTER = curr_threshold

            # Create output folder for this configuration
            tmp_output = output_folder / ''.join(
                [str(curr_threshold), "_threshold"])
            tmp_output.mkdir(parents=True, exist_ok=True)

            # ========= CONFIGURATION LAUNCH =========

            # Launch Server
            self.server_launcher.launch()
            time.sleep(2)

            # Launch client tester
            self.client_launcher = evaluator.InternalClusteringQualityEvaluator(
            )
            perf_overview = self.client_launcher.get_storage_graph(
                image_folder, gt, tmp_output)
            self.logger.warning(f"Perf overview added : {perf_overview}")

            perfs.append(perf_datastruct.Perf(perf_overview, curr_threshold))

            # Wait for client end

            # ========= TIDY UP FOR NEXT ROUND =========

            # Flush server
            self.server_launcher.flush_db()

            # Shutdown server
            self.server_launcher.stop()

            # Wait for shutdown (wait for workers to shutdown, usually longer than db)
            while not self.server_launcher.check_worker():
                time.sleep(1)  # Enough ?
                self.logger.warning("Waiting for workers to stop .. ")

            # Remove all workers
            self.server_launcher.flush_workers()
            time.sleep(2)

        # Print plot
        TwoD_plot = two_dimensions_plot.TwoDimensionsPlot()
        TwoD_plot.print_graph(perfs, output_folder)
Пример #5
0
 def setUp(self):
     self.logger = logging.getLogger()
     # self.conf = .Default_configuration()
     self.test_path = get_homedir(
     ) / "datasets" / "douglas-quaid-tests" / "TwoDPlot"
     self.matrix_gen = two_dimensions_plot.TwoDimensionsPlot()