示例#1
0
def __vital_algorithm_register__():
    """
    Note:

        We may be able to refactor somethign like this

        # In vital.py

        def _register_algorithm(cls, name=None, desc=''):
            if name is None:
                name = cls.__name__
            from kwiver.vital.algo import algorithm_factory
            if not algorithm_factory.has_algorithm_impl_name(cls.static_type_name(), name):
                algorithm_factory.add_algorithm(name, desc, cls)
                algorithm_factory.mark_algorithm_as_loaded(name)

        def register_algorithm(name=None, desc=''):
            '''
            POC refactor of __vital_algorithm_register__ into a decorator
            '''
            def _wrapper(cls):
                _register_algorithm(cls, name, desc)
                return cls
            return _wrapper

        def lazy_register(cls, name=None, desc=''):
            ''' Alternate Proof-of-Concept '''
            def __vital_algorithm_register__():
                return _register_algorithm(cls, name, desc)
            return __vital_algorithm_register__

        # Then in your class
        import vital
        @vial.register_algorithm(desc="PyTorch Netharn classification routine")
        class MyAlgorithm(BaseAlgo):
            ...

        # OR if the currenty lazy structure is important
        import vital
        class MyAlgorithm(BaseAlgo):
            ...

        __vital_algorithm_register__ = vital.lazy_register(MyAlgorithm, desc="PyTorch Netharn classification routine")

        # We could also play with adding class member variables for the lazy
        # initialization. There is lots of room to make this better / easier.
    """
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "netharn"

    if not algorithm_factory.has_algorithm_impl_name(
            NetharnRefiner.static_type_name(), implementation_name):
        algorithm_factory.add_algorithm(implementation_name,
                                        "PyTorch Netharn refiner routine",
                                        NetharnRefiner)

        algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory
    # Register Algorithm
    implementation_name = "SimpleBundleAdjust"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleBundleAdjust.static_type_name(), implementation_name):
        return
    algorithm_factory.add_algorithm(implementation_name,
                                    "test simple bundle adjust",
                                    SimpleBundleAdjust)
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#3
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory
    # Register Algorithm
    implementation_name = "ResectionCamera"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleResectionCamera.static_type_name(), implementation_name):
        return
    algorithm_factory.add_algorithm(implementation_name,
                                    "Test kwiver.vital.algo.ResectionCamera",
                                    SimpleResectionCamera)
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#4
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory
    # Register Algorithm
    implementation_name = "SimpleEstimatePNP"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleEstimatePNP.static_type_name(), implementation_name):
        return
    algorithm_factory.add_algorithm(implementation_name,
                                    "Test kwiver.vital.algo.EstimatePNP",
                                    SimpleEstimatePNP)
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory
    # Register Algorithm
    implementation_name  = "SimpleDrawDetectedObjectSet"
    if algorithm_factory.has_algorithm_impl_name(
                                SimpleDrawDetectedObjectSet.static_type_name(),
                                implementation_name):
        return
    algorithm_factory.add_algorithm( implementation_name,
        "creates a bounding box around the every object in the detected object set",
         SimpleDrawDetectedObjectSet )
    algorithm_factory.mark_algorithm_as_loaded( implementation_name )
示例#6
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory
    # Register Algorithm
    implementation_name = "SimpleComputeStereoDepthMap"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleComputeStereoDepthMap.static_type_name(),
            implementation_name):
        return
    algorithm_factory.add_algorithm(
        implementation_name, "Test kwiver.vital.algo.ComputeStereoDepthMap",
        SimpleComputeStereoDepthMap)
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory
    # Register Algorithm
    implementation_name  = "SimpleDetectedObjectSetOutput"
    if algorithm_factory.has_algorithm_impl_name(
                            SimpleDetectedObjectSetOutput.static_type_name(),
                            implementation_name):
        return
    algorithm_factory.add_algorithm( implementation_name,
                                "Test kwiver.vital.algo.DetectedObjectSetOutput",
                                 SimpleDetectedObjectSetOutput )
    algorithm_factory.mark_algorithm_as_loaded( implementation_name )
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "MetadataMapIO"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleMetadataMapIO.static_type_name(), implementation_name):
        return
    algorithm_factory.add_algorithm(implementation_name,
                                    "Test kwiver.vital.algo.MetadataMapIO",
                                    SimpleMetadataMapIO)
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleOptimizeCameras"
    if algorithm_factory.has_algorithm_impl_name(
        SimpleOptimizeCameras.static_type_name(), implementation_name
    ):
        return

    algorithm_factory.add_algorithm(
        implementation_name, "test simple optimize cameras", SimpleOptimizeCameras,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#10
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "npy_percentile_norm"
    if algorithm_factory.has_algorithm_impl_name(
            PercentileNorm16BitTo8Bit.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(implementation_name,
                                    "Numpy percentile normalization",
                                    PercentileNorm16BitTo8Bit)

    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "DetectedObjectSetOutputBinary"
    if algorithm_factory.has_algorithm_impl_name(
            DetectedObjectSetOutputBinary.static_type_name(),
            implementation_name):
        return
    algorithm_factory.add_algorithm(
        implementation_name,
        "Output detected object sets using Python's pickle package",
        DetectedObjectSetOutputBinary)
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleInterpolateTrack"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleInterpolateTrack.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple interpolate track",
        SimpleInterpolateTrack,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleSplitImage"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleSplitImage.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple split image",
        SimpleSplitImage,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleUVUnwrapMesh"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleUVUnwrapMesh.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple uv unwrap mesh",
        SimpleUVUnwrapMesh,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleAssociateDetectionsToTracks"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleAssociateDetectionsToTracks.static_type_name(),
            implementation_name):
        return
    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple associate detections to tracks",
        SimpleAssociateDetectionsToTracks,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleFeatureDescriptorIO"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleFeatureDescriptorIO.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "Test kwiver.vital.algo.FeatureDescriptorIO",
        SimpleFeatureDescriptorIO,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#17
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "tensorflow"

    if algorithm_factory.has_algorithm_impl_name(TFDetector.static_type_name(),
                                                 implementation_name):
        return

    algorithm_factory.add_algorithm(implementation_name,
                                    "Tensorflow detector testing routine",
                                    TFDetector)

    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#18
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleTrainDetector"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleTrainDetector.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple train detector",
        SimpleTrainDetector,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleVideoInput"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleVideoInput.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple video input",
        SimpleVideoInput,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleKeyframeSelection"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleKeyframeSelection.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple keyframe selection",
        SimpleKeyframeSelection,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#21
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "smqtk"

    if algorithm_factory.has_algorithm_impl_name(
            SMQTKTrainer.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name, "PyTorch SMQTK detection training routine",
        SMQTKTrainer)

    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#22
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "mmdet"

    if algorithm_factory.has_algorithm_impl_name(
            MMDetDetector.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(implementation_name,
                                    "PyTorch MMDetection inference routine",
                                    MMDetDetector)

    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#23
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "nms_fusion"

    if algorithm_factory.has_algorithm_impl_name(
            MergeDetectionsNMSFusion.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(implementation_name,
                                    "Fusion of multiple different detections",
                                    MergeDetectionsNMSFusion)

    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#24
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "netharn"

    if algorithm_factory.has_algorithm_impl_name(
            NetharnDetector.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name, "PyTorch Netharn detection routine",
        NetharnDetector)

    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleReadObjectTrackSet"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleReadObjectTrackSet.static_type_name(), implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple read object track set",
        SimpleReadObjectTrackSet,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleWriteTrackDescriptorSet"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleWriteTrackDescriptorSet.static_type_name(),
            implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple write track descriptor set",
        SimpleWriteTrackDescriptorSet,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
示例#27
0
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleTriangulateLandmarks"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleTriangulateLandmarks.static_type_name(),
            implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple triangulate landmarks",
        SimpleTriangulateLandmarks,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleIntegrateDepthMaps"
    if algorithm_factory.has_algorithm_impl_name(
        SimpleIntegrateDepthMaps.static_type_name(), implementation_name
    ):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple integrate depth maps",
        SimpleIntegrateDepthMaps,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__():
    from kwiver.vital.algo import algorithm_factory

    # Register Algorithm
    implementation_name = "SimpleInitializeObjectTracks"
    if algorithm_factory.has_algorithm_impl_name(
            SimpleInitializeObjectTracks.static_type_name(),
            implementation_name):
        return

    algorithm_factory.add_algorithm(
        implementation_name,
        "test simple initialize object tracks",
        SimpleInitializeObjectTracks,
    )
    algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def test_algorithm_factory():

    # Add algorithm
    algorithm_factory.add_algorithm("TestImageObjectDetector", "test detector",
                                    TestImageObjectDetector)

    nt.ok_(
        algorithm_factory.has_algorithm_impl_name("image_object_detector",
                                                  "TestImageObjectDetector"),
        "TestImageObjectDetector not found by the factory",
    )

    # Check with an empty implementation
    nt.assert_equal(
        algorithm_factory.has_algorithm_impl_name("image_object_detector", ""),
        False)
    # Check with dummy implementation
    nt.assert_equal(
        algorithm_factory.has_algorithm_impl_name("image_object_detector",
                                                  "NotAnObjectDetector"),
        False,
    )

    # Check that a registered implementation is returned by implementations
    nt.ok_(
        "TestImageObjectDetector"
        in algorithm_factory.implementations("image_object_detector"),
        "Dummy example_detector not registered",
    )
    # Check with an empty algorithm return empty list
    nt.assert_equal(len(algorithm_factory.implementations("")), 0)
    # Check with dummy algorithm returns empty list
    nt.assert_equal(len(algorithm_factory.implementations("NotAnAlgorithm")),
                    0)

    # Make sure creating works
    alg_out = algorithm_factory.create_algorithm("image_object_detector",
                                                 "TestImageObjectDetector")

    nt.ok_(isinstance(alg_out, TestImageObjectDetector))
    nt.ok_(isinstance(alg_out, ImageObjectDetector))