コード例 #1
0
ファイル: itergraph.py プロジェクト: heathkh/iwct
 def __init__(self, root_uri, params):
     super(MainFlow, self).__init__()
     self.params = params
     input_images = core.PertResource(self,
                                      '%s/photoid_to_image.pert' %
                                      (root_uri),
                                      check_exists=True,
                                      is_generated=False)
     CheckInputPreconditions(input_images.GetUri())
     photoids_flow = util.PertDropValueFlow(input_images,
                                            '%s/photoid.pert' % root_uri)
     self.photoids = photoids_flow.GetOutput()
     # extract features
     feature_uri_base = '%s/%s/' % (
         root_uri,
         iwutil.HashProto(self.params.tuned_feature_extractor_params))
     feature_flow = util.ExtractFeaturesFlow(
         feature_uri_base, input_images,
         self.params.tuned_feature_extractor_params.params)
     features = feature_flow.GetOutput()
     cbir_params = params.cbir
     cbir_uri_base = '%s/cbir/%s/' % (feature_uri_base,
                                      iwutil.HashProto(cbir_params))
     cbir_flow = util.CbirMetaFlow(feature_uri_base, features, cbir_params)
     cbir_results = cbir_flow.cbir_results
     itergraph_uri_base = "%s/itergraph/%s/" % (
         cbir_uri_base, iwutil.HashProto(self.params))
     build_graph_flow = BuildIterativeGraphFlow(itergraph_uri_base,
                                                features, cbir_results,
                                                self.params)
     self.merged_matches = build_graph_flow.merged_matches
     return
コード例 #2
0
ファイル: allpairsgraph.py プロジェクト: heathkh/iwct
    def __init__(self, base_uri, images, max_batch_size, num_shards_features):
        super(CreateAllPairsMatchBatchesFlow, self).__init__()

        self.AddInput('images', images)
        self.AddOutput(
            'unsorted_match_batches',
            core.PertResource(self,
                              '%s/unsorted_match_batches.pert' % (base_uri)))
        self.max_batch_size = max_batch_size
        self.num_shards_features = num_shards_features
        return
コード例 #3
0
    def __init__(self, root_uri, matches_root_uri):
        super(MainFlow, self).__init__()
        tide = core.PertResource(self,
                                 '%s/objectid_to_object.pert' % (root_uri),
                                 check_exists=True,
                                 is_generated=False)
        matches = core.PertResource(self,
                                    '%s/merged_matches.pert' %
                                    (matches_root_uri),
                                    check_exists=True,
                                    is_generated=False)

        matches_to_ig_flow = util.MatchesToImageGraphFlow(
            matches_root_uri, matches, tide)
        image_graph = matches_to_ig_flow.GetOutput()
        eval1_flow = util.LabelpropEval1Flow(matches_root_uri, image_graph,
                                             tide)

        matches_to_irg_flow = util.MatchesToImageRegionGraphFlow(
            matches_root_uri, matches, tide)
        image_region_graph = matches_to_irg_flow.GetOutput()
        eval2_flow = util.LabelpropEval2Flow(matches_root_uri,
                                             image_region_graph, tide)
        return
コード例 #4
0
ファイル: itergraph.py プロジェクト: heathkh/iwct
 def __init__(self, phase_base_uri, itergraph_params, phase_index,
              candidates, prev_state, features):
     super(ItergraphMatchBatchPlanningFlow, self).__init__()
     self.features = features
     self.AddInput('candidates', candidates)
     self.AddInput('prev_state', prev_state)
     self.AddOutput(
         'sorted_match_batches',
         core.PertResource(
             self, '%s/sorted_match_batches.pert' % (phase_base_uri)))
     phase = itergraph_params.phase[phase_index]
     self.max_candidates_per_phase = phase.max_match_candidates
     self.max_vertex_degree = phase.max_vertex_degree
     self.max_batch_size = phase.max_match_batch_size
     self.max_replication_factor = phase.max_image_replication_factor
     self.match_groups = {}
     self.num_replications = {}
     return
コード例 #5
0
ファイル: allpairsgraph.py プロジェクト: heathkh/iwct
    def __init__(self, root_uri):
        super(MainFlow, self).__init__()

        feature_type = 'usift'
        max_batch_size = 50

        matcher_config = image_matcher_config.GetImageMatcherConfig(
            feature_type)
        num_shards_features = 100

        images = core.PertResource(self,
                                   '%s/photoid_to_image.pert' % (root_uri))
        CHECK(images.Exists(), 'flow expects input to exist: %s' % images)
        #tide = core.PertResource(self, '%s/objectid_to_object.pert' % (root_uri))
        #CHECK(tide.Exists(), 'flow expects input to exist: %s' % tide)

        # crop out borders
        crop_flow = util.CropAndScaleImagesFlow(root_uri, images, 1.0)

        # extract features
        feature_uri_base = "%s/%s/" % (root_uri, feature_type)
        feature_flow = util.ExtractFeaturesFlow(feature_uri_base,
                                                crop_flow.GetOutput(),
                                                feature_type,
                                                num_shards_features)
        create_allpairs_metadata_flow = CreateAllPairsMatchBatchesFlow(
            feature_uri_base, images, max_batch_size, num_shards_features)
        sorted_metadata_flow = util.SortFlow(
            create_allpairs_metadata_flow.GetOutput(),
            '%s/match_batches.pert' % feature_uri_base, num_shards_features)

        # build graph
        matching_flow = util.MatchBatchesFlow(feature_uri_base,
                                              feature_flow.GetOutput(),
                                              sorted_metadata_flow.GetOutput(),
                                              matcher_config)

        return