Beispiel #1
0
def get_default_config():
    return {
        'plugins': {
            'descriptor_set': make_default_config(DescriptorIndex.get_impls()),
            'nn_index': make_default_config(NearestNeighborsIndex.get_impls())
        }
    }
Beispiel #2
0
    def get_default_config(cls):
        c = super(SmqtkClassifierService, cls).get_default_config()

        c[cls.CONFIG_ENABLE_CLASSIFIER_REMOVAL] = False

        # Static classifier configurations
        c[cls.CONFIG_CLASSIFIER_COLLECTION] = \
            ClassifierCollection.get_default_config()
        # Classification element factory for new classification results.
        c[cls.CONFIG_CLASSIFICATION_FACTORY] = \
            ClassificationElementFactory.get_default_config()
        # Descriptor generator for new content
        c[cls.CONFIG_DESCRIPTOR_GENERATOR] = make_default_config(
            DescriptorGenerator.get_impls()
        )
        # Descriptor factory for new content descriptors
        c[cls.CONFIG_DESCRIPTOR_FACTORY] = \
            DescriptorElementFactory.get_default_config()
        # Optional Descriptor set for "included" descriptors referenceable by
        # UID.
        c[cls.CONFIG_DESCRIPTOR_SET] = make_default_config(
            DescriptorSet.get_impls()
        )
        # from-IQR-state *supervised* classifier configuration
        c[cls.CONFIG_IQR_CLASSIFIER] = make_default_config(
            SupervisedClassifier.get_impls()
        )
        c[cls.CONFIG_IMMUTABLE_LABELS] = []

        return c
Beispiel #3
0
def default_config():
    return {
        "plugins": {
            "supervised_classifier":
            make_default_config(SupervisedClassifier.get_impls()),
            "descriptor_set":
            make_default_config(DescriptorSet.get_impls()),
        },
        "cross_validation": {
            "truth_labels": None,
            "num_folds": 6,
            "random_seed": None,
            "classification_use_multiprocessing": True,
        },
        "pr_curves": {
            "enabled": True,
            "show": False,
            "output_directory": None,
            "file_prefix": None,
        },
        "roc_curves": {
            "enabled": True,
            "show": False,
            "output_directory": None,
            "file_prefix": None,
        },
    }
Beispiel #4
0
    def get_default_config(cls):
        """
        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
def default_config():
    return {
        'plugins': {
            'classifier':
            make_default_config(SupervisedClassifier.get_impls()),
            'classification_factory':
            ClassificationElementFactory.get_default_config(),
            'descriptor_set':
            make_default_config(DescriptorSet.get_impls())
        },
        'utility': {
            'train': False,
            'csv_filepath': 'CHAMGEME :: PATH :: a csv file',
            'output_plot_pr': None,
            'output_plot_roc': None,
            'output_plot_confusion_matrix': None,
            'output_uuid_confusion_matrix': None,
            'curve_confidence_interval': False,
            'curve_confidence_interval_alpha': 0.4,
        },
        "parallelism": {
            "descriptor_fetch_cores": 4,
            # DEPRECATED
            "classification_cores": None,
        },
    }
Beispiel #6
0
    def get_default_config(cls):
        """
        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.

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

        """
        c = super(NearestNeighborServiceServer, cls).get_default_config()
        merge_dict(
            c, {
                "descriptor_factory":
                DescriptorElementFactory.get_default_config(),
                "descriptor_generator":
                make_default_config(DescriptorGenerator.get_impls()),
                "nn_index":
                make_default_config(NearestNeighborsIndex.get_impls()),
                "descriptor_index":
                make_default_config(DescriptorIndex.get_impls()),
                "update_descriptor_index":
                False,
            })
        return c
Beispiel #7
0
    def get_default_config(cls):
        """
        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(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
Beispiel #8
0
    def get_default_config(cls):
        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
Beispiel #9
0
def get_default_config():
    return {
        "descriptor_factory":
        DescriptorElementFactory.get_default_config(),
        "descriptor_generator":
        make_default_config(DescriptorGenerator.get_impls()),
        "classification_factory":
        ClassificationElementFactory.get_default_config(),
        "classifier":
        make_default_config(Classifier.get_impls()),
    }
Beispiel #10
0
def default_config():
    return {
        "descriptor_generator":
        make_default_config(DescriptorGenerator.get_impls()),
        "descriptor_factory":
        DescriptorElementFactory.get_default_config(),
        "descriptor_set":
        make_default_config(DescriptorSet.get_impls()),
        "optional_data_set":
        make_default_config(DataSet.get_impls())
    }
Beispiel #11
0
def default_config():
    return {
        "utility": {
            "report_interval": 1.0,
            "use_multiprocessing": False,
        },
        "plugins": {
            "descriptor_set": make_default_config(DescriptorSet.get_impls()),
            "lsh_functor": make_default_config(LshFunctor.get_impls()),
            "hash2uuid_kvstore":
            make_default_config(KeyValueStore.get_impls()),
        },
    }
Beispiel #12
0
def default_config():
    return {
        'plugins': {
            'descriptor_index':
            make_default_config(DescriptorIndex.get_impls()),
        }
    }
Beispiel #13
0
 def collect_configs(name, impl_set):
     """
     :type name: str
     :type impl_set: set[type]
     """
     if collect_defaults:
         defaults[name] = make_default_config(impl_set)
def default_config():

    # Trick for mixing in our Configurable class API on top of scikit-learn's
    # MiniBatchKMeans class in order to introspect construction parameters.
    # We never construct this class so we do not need to implement "pure
    # virtual" instance methods.
    # noinspection PyAbstractClass
    class MBKTemp(MiniBatchKMeans, Configurable):
        pass

    c = {
        "minibatch_kmeans_params": MBKTemp.get_default_config(),
        "descriptor_index": make_default_config(DescriptorIndex.get_impls()),
        # Number of descriptors to run an initial fit with. This brings the
        # advantage of choosing a best initialization point from multiple.
        "initial_fit_size": 0,
        # Path to save generated KMeans centroids
        "centroids_output_filepath_npy": "centroids.npy"
    }

    # Change/Remove some KMeans params for more appropriate defaults
    del c['minibatch_kmeans_params']['compute_labels']
    del c['minibatch_kmeans_params']['verbose']
    c['minibatch_kmeans_params']['random_state'] = 0

    return c
Beispiel #15
0
 def get_config(self):
     # Recursively get config from data element if we have one.
     if hasattr(self._cache_element, 'get_config'):
         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}
Beispiel #16
0
def default_config():
    return {
        "hash2uuid_kv_store":
        make_default_config(smqtk.representation.KeyValueStore.get_impls()),
        "sklearn_balltree":
        SkLearnBallTreeHashIndex.get_default_config(),
        "itq_bit_length":
        256,
    }
def default_config():
    return {
        "utility": {
            "classify_overwrite": False,
            "parallel": {
                "use_multiprocessing": False,
                "index_extraction_cores": None,
                "classification_cores": None,
            }
        },
        "plugins": {
            "classifier":
            make_default_config(Classifier.get_impls()),
            "classification_factory":
            make_default_config(ClassificationElement.get_impls()),
            "descriptor_set":
            make_default_config(DescriptorSet.get_impls()),
        }
    }
Beispiel #18
0
def test_make_default_config():
    """
    Test expected normal operation of ``make_default_config``.
    """
    expected = {
        'type': None,
        'T1': T1.get_default_config(),
        '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
Beispiel #20
0
    def get_default_config(cls):
        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
Beispiel #21
0
    def get_default_config(cls):
        d = super(IqrSearch, cls).get_default_config()

        # Remove parent_app slot for later explicit specification.
        del d['parent_app']

        d['iqr_service_url'] = None

        # fill in plugin configs
        d['data_set'] = make_default_config(DataSet.get_impls())

        return d
def default_config():
    return {
        'tool': {
            'girder_api_root': 'http://localhost:8080/api/v1',
            'api_key': None,
            'api_query_batch': 1000,
            'dataset_insert_batch_size': None,
        },
        'plugins': {
            'data_set': make_default_config(DataSet.get_impls()),
        }
    }
Beispiel #23
0
    def get_default_config(cls):
        """
        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

        """
        return make_default_config(ClassificationElement.get_impls())
Beispiel #24
0
    def get_default_config(cls):
        """
        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
Beispiel #25
0
    def get_default_config(cls):
        """
        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
Beispiel #26
0
    def get_default_config(cls):
        """
        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.

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

        """
        c = super(DescriptorServiceServer, cls).get_default_config()
        merge_dict(c, {
            "descriptor_factory": DescriptorElementFactory.get_default_config(),
            "descriptor_generators": {
                "example": make_default_config(DescriptorGenerator.get_impls())
            }
        })
        return c
Beispiel #27
0
    def get_default_config(cls):
        """
        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(ImageMatrixObjectDetector, cls).get_default_config()
        default['image_reader'] = make_default_config(ImageReader.get_impls())
        return default
Beispiel #28
0
    def get_default_config(cls):
        """
        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

        """
        c = super(MemoryDescriptorSet, cls).get_default_config()
        c['cache_element'] = make_default_config(DataElement.get_impls())
        return c
Beispiel #29
0
    def get_default_config(cls):
        """
        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,
        aside from the first two assumed positional 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

        """
        c = super(CachingDescriptorElement, cls).get_default_config()

        # Nested DescriptorElementFactory configuration
        if c['wrapped_element_factory'] is None:
            # Have to make this configuration in such a way that we don't
            # include ourselves in the list of nestable classes else an infinite
            # recursion will occur.

            de_impls = DescriptorElement.get_impls()
            # Remove ourselves
            de_impls.remove(cls)

            # Construct config block DescriptorElementFactory wants
            c['wrapped_element_factory'] = make_default_config(de_impls)
        else:
            c['wrapped_element_factory'] = \
                c['wrapped_element_factory'].get_config()

        return c
Beispiel #30
0
def build_default_config():
    return {
        'descriptor_set': make_default_config(DescriptorSet.get_impls()),
        'neighbor_index':
        make_default_config(NearestNeighborsIndex.get_impls()),
    }