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 __vital_algorithm_register__(): from vital.algo import algorithm_factory # Register Algorithm implementation_name = "SimpleImageObjectDetector" if algorithm_factory.has_algorithm_impl_name( SimpleImageObjectDetector.static_type_name(), implementation_name): return algorithm_factory.add_algorithm(implementation_name, "test image object detector arrow", SimpleImageObjectDetector) algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__(): from vital.algo import algorithm_factory # Register Algorithm implementation_name = "CascadeClassifier" if algorithm_factory.has_algorithm_impl_name( CascadeClassifier.static_type_name(), implementation_name): return algorithm_factory.add_algorithm( implementation_name, "Opencv implementation of Haar cascade classifier", CascadeClassifier) algorithm_factory.mark_algorithm_as_loaded(implementation_name)
def __vital_algorithm_register__(): from vital.algo import algorithm_factory # Register Algorithm implementation_name = "SimpleImageObjectDetector" if algorithm_factory.has_algorithm_impl_name( SimpleImageObjectDetector.static_type_name(), implementation_name): return algorithm_factory.add_algorithm( implementation_name, "test image object detector arrow", SimpleImageObjectDetector ) algorithm_factory.mark_algorithm_as_loaded( implementation_name )
def __vital_algorithm_register__(): from 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 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 testing routine", MMDetDetector ) algorithm_factory.mark_algorithm_as_loaded( implementation_name )
def __vital_algorithm_register__(): from vital.algo import algorithm_factory # Register Algorithm implementation_name = "netharn" if algorithm_factory.has_algorithm_impl_name( NetHarnTrainer.static_type_name(), implementation_name ): return algorithm_factory.add_algorithm( implementation_name, "PyTorch NetHarn detection training routine", NetHarnTrainer ) algorithm_factory.mark_algorithm_as_loaded( implementation_name )
def __vital_algorithm_register__(): from 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 )
def __vital_algorithm_register__(): from 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 testing routine", MMDetDetector ) algorithm_factory.mark_algorithm_as_loaded( implementation_name )
bbox_int = bbox.astype( np.int32 ) bounding_box = BoundingBox( bbox_int[0], bbox_int[1], bbox_int[2], bbox_int[3] ) detected_object_type = DetectedObjectType( label, 1.0 ) detected_object = DetectedObject( bounding_box, np.max( class_confidence ), detected_object_type ) output.add( detected_object ) return output def __vital_algorithm_register__(): from vital.algo import algorithm_factory # Register Algorithm implementation_name = "@template@" if algorithm_factory.has_algorithm_impl_name( @[email protected]_type_name(), implementation_name ): return algorithm_factory.add_algorithm( implementation_name, "@template@ dection inference routine", @template@Detector ) algorithm_factory.mark_algorithm_as_loaded( implementation_name )