예제 #1
0
    def get_default_config(cls) -> Dict[str, Any]:
        """
        Generate and return a default configuration dictionary for this class.
        This will be primarily used for generating what the configuration
        dictionary would look like for this class without instantiating it.

        By default, we observe what this class's constructor takes as
        arguments, turning those argument names into configuration dictionary
        keys. If any of those arguments have defaults, we will add those values
        into the configuration dictionary appropriately. The dictionary
        returned should only contain JSON compliant value types.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this
        class.

        :return: Default configuration dictionary for the class.
        :rtype: dict

        """
        default = super(LSHNearestNeighborIndex, cls).get_default_config()

        lf_default = make_default_config(LshFunctor.get_impls())
        default['lsh_functor'] = lf_default

        di_default = make_default_config(DescriptorSet.get_impls())
        default['descriptor_set'] = di_default

        hi_default = make_default_config(HashIndex.get_impls())
        default['hash_index'] = hi_default

        h2u_default = make_default_config(KeyValueStore.get_impls())
        default['hash2uuids_kvstore'] = h2u_default

        return default
예제 #2
0
    def get_default_config(cls) -> Dict[str, Any]:
        """
        Generate and return a default configuration dictionary for this class.
        This will be primarily used for generating what the configuration
        dictionary would look like for this class without instantiating it.

        By default, we observe what this class's constructor takes as
        arguments, turning those argument names into configuration dictionary
        keys. If any of those arguments have defaults, we will add those
        values into the configuration dictionary appropriately. The dictionary
        returned should only contain JSON compliant value types.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this
        class.

        :return: Default configuration dictionary for the class.

        """
        default = super(FaissNearestNeighborsIndex, cls).get_default_config()

        data_element_default_config = \
            make_default_config(DataElement.get_impls())
        default['index_element'] = data_element_default_config
        default['index_param_element'] = deepcopy(data_element_default_config)

        di_default = make_default_config(DescriptorSet.get_impls())
        default['descriptor_set'] = di_default

        kvs_default = make_default_config(KeyValueStore.get_impls())
        default['idx2uid_kvs'] = kvs_default
        default['uid2idx_kvs'] = deepcopy(kvs_default)

        return default
예제 #3
0
    def get_default_config(cls) -> Dict[str, Any]:
        default = super(CaffeDescriptorGenerator, cls).get_default_config()

        data_elem_impl_set = DataElement.get_impls()
        # Need to make copies of dict so changes to one does not effect others.
        default['network_prototxt'] = \
            make_default_config(data_elem_impl_set)
        default['network_model'] = make_default_config(data_elem_impl_set)
        default['image_mean'] = make_default_config(data_elem_impl_set)

        return default
예제 #4
0
    def get_default_config(cls) -> Dict[str, Any]:
        default = super(MRPTNearestNeighborsIndex, cls).get_default_config()

        di_default = make_default_config(DescriptorSet.get_impls())
        default['descriptor_set'] = di_default

        return default
예제 #5
0
 def get_config(self) -> Dict[str, Any]:
     # Recursively get config from data element if we have one.
     if self._cache_element is not None:
         elem_config = to_config_dict(self._cache_element)
     else:
         # No cache element, output default config with no type.
         elem_config = make_default_config(DataElement.get_impls())
     return {'cache_element': elem_config}
예제 #6
0
def test_make_default_config() -> None:
    """
    Test expected normal operation of ``make_default_config``.
    """
    expected = {
        'type': None,
        'tests.test_configuration.T1': T1.get_default_config(),
        'tests.test_configuration.T2': T2.get_default_config(),
    }
    assert make_default_config(T_CLASS_SET) == expected
    def get_default_config(cls):
        c = super(ClassifierCollection, cls).get_default_config()

        # We list the label-classifier mapping on one level, so remove the
        # nested map parameter that can optionally be used in the constructor.
        del c['classifiers']

        # Add slot of a list of classifier plugin specifications
        c[cls.EXAMPLE_KEY] = make_default_config(Classifier.get_impls())

        return c
    def get_default_config(cls) -> Dict[str, Any]:
        """
        Generate and return a default configuration dictionary for this class.
        This will be primarily used for generating what the configuration
        dictionary would look like for this class without instantiating it.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this class.

        :return: Default configuration dictionary for the class.
        """
        return make_default_config(DescriptorElement.get_impls())
예제 #9
0
    def get_default_config(cls) -> Dict[str, Any]:
        default = super(ItqFunctor, cls).get_default_config()

        # Cache element parameters need to be split out into sub-configurations
        data_element_default_config = \
            make_default_config(DataElement.get_impls())
        default['mean_vec_cache'] = data_element_default_config
        # Need to deepcopy source to prevent modifications on one sub-config
        # from reflecting in the other.
        default['rotation_cache'] = deepcopy(data_element_default_config)

        return default
예제 #10
0
    def get_default_config(cls) -> Dict:
        """
        Generate and return a default configuration dictionary for this class.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this class.

        :return: Default configuration dictionary for the class.
        :rtype: dict
        """
        c = super(KVSDataSet, cls).get_default_config()
        c['kvstore'] = merge_dict(
            make_default_config(KeyValueStore.get_impls()),
            to_config_dict(c['kvstore']))
        return c
예제 #11
0
    def get_default_config(cls) -> Dict[str, Any]:
        """
        Generate and return a default configuration dictionary for this class.
        This will be primarily used for generating what the configuration
        dictionary would look like for this class without instantiating it.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this class.

        :return: Default configuration dictionary for the class.
        :rtype: dict

        """
        default = super(MemoryKeyValueStore, cls).get_default_config()
        default['cache_element'] = make_default_config(DataElement.get_impls())
        return default
예제 #12
0
    def get_default_config(cls) -> Dict[str, Any]:
        """
        Generate and return a default configuration dictionary for this class.
        This will be primarily used for generating what the configuration
        dictionary would look like for this class without instantiating it.

        By default, we observe what this class's constructor takes as arguments,
        turning those argument names into configuration dictionary keys. If any
        of those arguments have defaults, we will add those values into the
        configuration dictionary appropriately. The dictionary returned should
        only contain JSON compliant value types.

        It is not be guaranteed that the configuration dictionary returned
        from this method is valid for construction of an instance of this class.

        :return: Default configuration dictionary for the class.

        """
        c = super(MemoryDescriptorSet, cls).get_default_config()
        c['cache_element'] = make_default_config(DataElement.get_impls())
        return c
예제 #13
0
 def get_default_config(cls) -> Dict[str, Any]:
     c = super().get_default_config()
     c['classifier_inst'] = \
         make_default_config(ClassifyDescriptorSupervised.get_impls())
     return c
예제 #14
0
 def get_default_config(cls) -> Dict[str, Any]:
     c = super().get_default_config()
     rr_default = make_default_config(RankRelevancy.get_impls())
     return dict(c, rank_relevancy=rr_default)
예제 #15
0
 def get_default_config(cls) -> Dict[str, Any]:
     cfg = super().get_default_config()
     cfg['perturber'] = make_default_config(PerturbImage.get_impls())
     cfg['generator'] = make_default_config(GenerateClassifierConfidenceSaliency.get_impls())
     return cfg