def test_register_cluster(): from sprokit.pipeline import config from sprokit.pipeline import process from sprokit.pipeline import process_cluster from sprokit.pipeline import process_factory proc_type = 'python_example' proc_desc = 'simple description' process_factory.add_process(proc_type, proc_desc, base_example_process_cluster()) if not proc_desc == process_factory.description(proc_type): test_error("Description was not preserved when registering") p = None try: p = process_factory.create_process(proc_type, '') if p is None: raise Exception() except BaseException: import sys e = sys.exc_info()[1] test_error("Could not create newly registered process cluster type: %s" % str(e)) if process_cluster.cluster_from_process(p) is None: test_error("A cluster process from the registry was not detected as a cluster process")
def test_register_cluster(): from vital.config import config from sprokit.pipeline import process from sprokit.pipeline import process_cluster from sprokit.pipeline import process_factory proc_type = 'python_example' proc_desc = 'simple description' process_factory.add_process(proc_type, proc_desc, base_example_process_cluster()) if not proc_desc == process_factory.description(proc_type): test_error("Description was not preserved when registering") p = None try: p = process_factory.create_process(proc_type, '') if p is None: raise Exception() except BaseException: import sys e = sys.exc_info()[1] test_error( "Could not create newly registered process cluster type: %s" % str(e)) if process_cluster.cluster_from_process(p) is None: test_error( "A cluster process from the registry was not detected as a cluster process" )
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python_' + __name__ # module_name = 'python:camtrawl.processes' # module_name = 'python' + __name__ if process_factory.is_process_module_loaded(module_name): return # print('TMP_SPROKIT_PROCESS_REGISTRY = {}'.format(ub.repr2(TMP_SPROKIT_PROCESS_REGISTRY))) for name, doc, cls in TMP_SPROKIT_PROCESS_REGISTRY: # print("REGISTER PROCESS:") # print(' * name = {!r}'.format(name)) # print(' * cls = {!r}'.format(cls)) process_factory.add_process(name, doc, cls) # process_factory.add_process('camtrawl_detect_fish', # 'preliminatry detection / feature extraction', # CamtrawlDetectFishProcess) # process_factory.add_process('camtrawl_measure', # 'preliminatry measurement', # CamtrawlMeasureProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python_' + __name__ print("REGISTER MY CAMTRAWL MODULE: {}, {}".format(module_name, __file__)) # module_name = 'python:camtrawl.processes' # module_name = 'python' + __name__ if process_factory.is_process_module_loaded(module_name): return # print('TMP_SPROKIT_PROCESS_REGISTRY = {}'.format(ub.repr2(TMP_SPROKIT_PROCESS_REGISTRY))) for name, doc, cls in TMP_SPROKIT_PROCESS_REGISTRY: # print("REGISTER PROCESS:") # print(' * name = {!r}'.format(name)) # print(' * cls = {!r}'.format(cls)) process_factory.add_process(name, doc, cls) # process_factory.add_process('camtrawl_detect_fish', # 'preliminatry detection / feature extraction', # CamtrawlDetectFishProcess) # process_factory.add_process('camtrawl_measure', # 'preliminatry measurement', # CamtrawlMeasureProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:kwiver.ClassifierSample' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('ClassifierSample', 'Dummy Classifier', ClassifierProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:sender' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('SenderProcess', 'Process to send BBoxWithMultipleDescriptors', SenderProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:test.pythonpath.test' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('pythonpath_test_process', 'A test process.', TestPythonProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:kwiver.ApplyDescriptor' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('ApplyDescriptor', 'Apply descriptor to image', ApplyDescriptor) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:kwiver.ProcessImage' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('ProcessImage', 'Process image test', ProcessImage) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:kwiver.python.SimpleHomogTracker' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'simple_homog_tracker', 'Simple IOU-based tracker with homography support', SimpleHomogTracker, ) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:test.pythonpath.process_test' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('pythonpath_test_process', 'A test process.', TestPythonProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:viame.example_filter' if process_factory.is_process_module_loaded( module_name ): return process_factory.add_process('example_filter', 'Example external filter', example_filter) process_factory.mark_process_module_as_loaded( module_name )
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:yuvals_plugins.track_set_to_object_set' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'track_set_to_object_set', 'Example detector', \ track_set_to_object_set.track_set_to_object_set ) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:tf_detector.tf_detector' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('tf_detector', 'TF detector', tf_detector.tf_detector) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:test.examples' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('test_python_process', 'A test Python process', examples.TestPythonProcess) process_factory.add_process('pyprint_number', 'A Python process which prints numbers', examples.PythonPrintNumberProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:kwiver.faceDetection' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('faceDetection', 'face detection', faceDetection) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:kwiver.write_homography' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('kw_write_homography', 'A Simple Kwiver homography writer', HomographyWriterProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:test.python.extras' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('extra_test_python_process', 'An extra test Python process', TestPythonProcess) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:kwiver.print_number' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process('kw_print_number_process', 'A Simple Kwiver Test Process', kw_print_number_process) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:smqtk.smqtk_add_descriptors_uuids' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'smqtk_add_descriptors_uuids', 'Add descriptors and parallel UUIDs to a SMQTK descriptor index', smqtk_add_descriptors_uuids.SmqtkAddDescriptorsUuids) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:hello_world.hello_world_detector' if process_factory.is_process_module_loaded( module_name ): return process_factory.add_process('hello_world_detector', 'Example detector', hello_world_detector.hello_world_detector ) process_factory.add_process('hello_world_filter', 'Example filter', hello_world_filter.hello_world_filter ) process_factory.mark_process_module_as_loaded( module_name )
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:hello_world.hello_world_detector' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'hello_world_detector', 'Example detector', \ hello_world_detector.hello_world_detector ) process_factory.add_process( 'hello_world_filter', 'Example filter', \ hello_world_filter.hello_world_filter ) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:core.core_processes' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'blank_out_frames', 'Blank out frames with no object detections on them', utility_processes.blank_out_frames) process_factory.mark_process_module_as_loaded(module_name)
def test_register(): from sprokit.pipeline import config from sprokit.pipeline import process from sprokit.pipeline import process_factory proc_type = 'python_example' proc_desc = 'simple description' process_factory.add_process(proc_type, proc_desc, example_process(True)) if not proc_desc == process_factory.description(proc_type): test_error("Description was not preserved when registering") try: p = process_factory.create_process(proc_type, '') if p is None: raise Exception() except: test_error("Could not create newly registered process type")
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:core.core_processes' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'blank_out_frames', 'Blank out frames with no object detections on them', utility_processes.blank_out_frames) process_factory.add_process( 'percentile_norm_npy_16_to_8bit', 'A specialized percentile normalization method', utility_processes.percentile_norm_npy_16_to_8bit) process_factory.mark_process_module_as_loaded(module_name)
def test_register(): from vital.config import config from sprokit.pipeline import process from sprokit.pipeline import process_factory proc_type = 'python_example' proc_desc = 'simple description' process_factory.add_process(proc_type, proc_desc, example_process(True)) if not proc_desc == process_factory.description(proc_type): test_error("Description was not preserved when registering") try: p = process_factory.create_process(proc_type, '') if p is None: raise Exception() except: test_error("Could not create newly registered process type")
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:smqtk.smqtk_processes' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'smqtk_ingest_descriptors', 'Add descriptors and parallel UUIDs to a SMQTK descriptor index', smqtk_ingest_descriptors.SmqtkIngestDescriptors) process_factory.add_process( 'smqtk_process_query', 'Perform queries against some arbitrary descriptor index', smqtk_process_query.SmqtkProcessQuery) process_factory.mark_process_module_as_loaded(module_name)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:opencv.opencv_processes' if process_factory.is_process_module_loaded( module_name ): return process_factory.add_process( 'ocv_multimodal_registration', 'Register optical and thermal frames', ocv_multimodal_registration.register_frames_process ) process_factory.add_process( 'ocv_fft_filter_based_on_ref', 'Filter image in the frequency based on some template', ocv_fft_filter_based_on_ref.filter_based_on_ref_process ) process_factory.mark_process_module_as_loaded( module_name )
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:core.core_processes' if process_factory.is_process_module_loaded( module_name ): return process_factory.add_process( 'blank_out_frames', 'Blank out frames with no object detections on them', utility_processes.blank_out_frames ) process_factory.add_process( 'percentile_norm_npy_16_to_8bit', 'A specialized percentile normalization method', utility_processes.percentile_norm_npy_16_to_8bit ) process_factory.mark_process_module_as_loaded( module_name )
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:smqtk.smqtk_processes' if process_factory.is_process_module_loaded(module_name): return process_factory.add_process( 'smqtk_ingest_descriptors', 'Add descriptors and parallel UUIDs to a SMQTK descriptor index', smqtk_ingest_descriptors.SmqtkIngestDescriptors ) process_factory.add_process( 'smqtk_process_query', 'Perform queries against some arbitrary descriptor index', smqtk_process_query.SmqtkProcessQuery ) process_factory.add_process( 'smqtk_object_track_descriptors', 'Add descriptors to object tracks', smqtk_object_track_descriptors.SmqtkObjectTrackDescriptors ) process_factory.mark_process_module_as_loaded(module_name)
def test_wrapper_api(): from vital.config import config from sprokit.pipeline import edge from sprokit.pipeline import process from sprokit.pipeline import process_factory proc_type = 'python_example' proc_desc = 'simple description' proc_base_type = 'python_base_example' proc_base_desc = 'simple base description' iport = 'no_such_iport' oport = 'no_such_oport' key = 'no_such_key' ptype = 'no_type' process_factory.add_process(proc_type, proc_desc, example_process(False)) process_factory.add_process(proc_base_type, proc_base_desc, base_example_process()) def check_process(p): if p is None: test_error("Got a 'None' process") return p.properties() p.input_ports() p.output_ports() expect_exception("asking for info on a non-existant input port", RuntimeError, p.input_port_info, iport) expect_exception("asking for info on a non-existant output port", RuntimeError, p.output_port_info, oport) e = edge.Edge() expect_exception("connecting to a non-existant input port", RuntimeError, p.connect_input_port, iport, e) expect_exception("connecting to a non-existant output port", RuntimeError, p.connect_output_port, oport, e) p.available_config() p.available_tunable_config() expect_exception("asking for info on a non-existant config key", RuntimeError, p.config_info, key) expect_exception("setting a type on a non-existent input port", RuntimeError, p.set_input_port_type, iport, ptype) expect_exception("setting a type on a non-existent output port", RuntimeError, p.set_output_port_type, oport, ptype) p.reset() p.configure() p.init() # TODO: Can't check this because the core frequency of the process # cannot be set. Needs to be stepped within a pipeline to verify this. # Enable the ran_step check in p.check when this is fixed. #p.step() # TODO: Can't check this because only the process_cluster base class # and the pipeline may reconfigure a process. Needs to be stepped # within a pipeline to verify this. Enable the ran_step check in # p.check when this is fixed. #p.reconfigure(reconf) del p p = process_factory.create_process(proc_type, '') check_process(p) p = process_factory.create_process(proc_base_type, '') check_process(p)
def __sprokit_register__(): from sprokit.pipeline import process_factory module_name = 'python:detection_matching.match_fixed_labels_with_detections' if process_factory.is_process_module_loaded( module_name ): return process_factory.add_process( 'match_fixed_labels_with_detections', 'Example detector', \ match_fixed_labels_with_detections.match_fixed_labels_with_detections ) process_factory.mark_process_module_as_loaded( module_name ) # 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 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 vital.algo import algorithm_factory # # Register Algorithm # implementation_name = "netharn_classifier" # if not algorithm_factory.has_algorithm_impl_name( # NetharnClassifier.static_type_name(), implementation_name): # algorithm_factory.add_algorithm( # implementation_name, "PyTorch Netharn classification routine", # NetharnClassifier) # algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def test_wrapper_api(): from sprokit.pipeline import config from sprokit.pipeline import edge from sprokit.pipeline import process from sprokit.pipeline import process_factory proc_type = 'python_example' proc_desc = 'simple description' proc_base_type = 'python_base_example' proc_base_desc = 'simple base description' iport = 'no_such_iport' oport = 'no_such_oport' key = 'no_such_key' ptype = 'no_type' process_factory.add_process(proc_type, proc_desc, example_process(False)) process_factory.add_process(proc_base_type, proc_base_desc, base_example_process()) def check_process(p): if p is None: test_error("Got a 'None' process") return p.properties() p.input_ports() p.output_ports() expect_exception("asking for info on a non-existant input port", RuntimeError, p.input_port_info, iport) expect_exception("asking for info on a non-existant output port", RuntimeError, p.output_port_info, oport) e = edge.Edge() expect_exception("connecting to a non-existant input port", RuntimeError, p.connect_input_port, iport, e) expect_exception("connecting to a non-existant output port", RuntimeError, p.connect_output_port, oport, e) p.available_config() p.available_tunable_config() expect_exception("asking for info on a non-existant config key", RuntimeError, p.config_info, key) expect_exception("setting a type on a non-existent input port", RuntimeError, p.set_input_port_type, iport, ptype) expect_exception("setting a type on a non-existent output port", RuntimeError, p.set_output_port_type, oport, ptype) p.reset() p.configure() p.init() # TODO: Can't check this because the core frequency of the process # cannot be set. Needs to be stepped within a pipeline to verify this. # Enable the ran_step check in p.check when this is fixed. #p.step() # TODO: Can't check this because only the process_cluster base class # and the pipeline may reconfigure a process. Needs to be stepped # within a pipeline to verify this. Enable the ran_step check in # p.check when this is fixed. #p.reconfigure(reconf) del p p = process_factory.create_process(proc_type, '') check_process(p) p = process_factory.create_process(proc_base_type, '') check_process(p)