def __init__(self, *args, **kwargs): super(OpPredictionPipelineNoCache, self).__init__(*args, **kwargs) # Random forest prediction using the raw feature image slot (not the cached features) # This would be bad for interactive labeling, but it's good for headless flows # because it avoids the overhead of cache. self.cacheless_predict = OpPredictCounter(parent=self) self.cacheless_predict.name = "OpPredictCounter (Cacheless Path)" self.cacheless_predict.inputs['Classifier'].connect(self.Classifier) self.cacheless_predict.inputs['Image'].connect( self.FeatureImages) # <--- Not from cache self.cacheless_predict.inputs['LabelsCount'].connect(self.MaxLabel) self.meaner = OpMean(parent=self) self.meaner.Input.connect(self.cacheless_predict.PMaps) self.HeadlessPredictionProbabilities.connect(self.meaner.Output)
def __init__(self, *args, **kwargs): super(OpPredictionPipeline, self).__init__(*args, **kwargs) # Random forest prediction using CACHED features. self.predict = OpPredictCounter(parent=self) self.predict.name = "OpPredictCounter" self.predict.inputs['Classifier'].connect(self.Classifier) self.predict.inputs['Image'].connect(self.CachedFeatureImages) self.predict.inputs['LabelsCount'].connect(self.MaxLabel) self.PredictionProbabilities.connect(self.predict.PMaps) # Prediction cache for the GUI self.prediction_cache_gui = OpArrayCache(parent=self) self.prediction_cache_gui.name = "prediction_cache_gui" self.prediction_cache_gui.inputs["fixAtCurrent"].connect( self.FreezePredictions) self.prediction_cache_gui.inputs["Input"].connect(self.predict.PMaps) self.prediction_cache_gui.blockShape.setValue(128) ## Also provide each prediction channel as a separate layer (for the GUI) self.opUncertaintyEstimator = OpEnsembleMargin(parent=self) self.opUncertaintyEstimator.Input.connect( self.prediction_cache_gui.Output) ## Cache the uncertainty so we get zeros for uncomputed points self.opUncertaintyCache = OpArrayCache(parent=self) self.opUncertaintyCache.name = "opUncertaintyCache" self.opUncertaintyCache.blockShape.setValue(128) self.opUncertaintyCache.Input.connect( self.opUncertaintyEstimator.Output) self.opUncertaintyCache.fixAtCurrent.connect(self.FreezePredictions) self.UncertaintyEstimate.connect(self.opUncertaintyCache.Output) self.meaner = OpMean(parent=self) self.meaner.Input.connect(self.prediction_cache_gui.Output) self.precomputed_predictions_gui = OpPrecomputedInput( ignore_dirty_input=False, parent=self) self.precomputed_predictions_gui.name = "precomputed_predictions_gui" self.precomputed_predictions_gui.SlowInput.connect(self.meaner.Output) self.precomputed_predictions_gui.PrecomputedInput.connect( self.PredictionsFromDisk) self.CachedPredictionProbabilities.connect( self.precomputed_predictions_gui.Output)
def __init__(self, *args, **kwargs): super(OpPredictionPipelineNoCache, self).__init__(*args, **kwargs) # Random forest prediction using the raw feature image slot (not the cached features) # This would be bad for interactive labeling, but it's good for headless flows # because it avoids the overhead of cache. self.cacheless_predict = OpPredictCounter(parent=self) self.cacheless_predict.name = "OpPredictCounter (Cacheless Path)" self.cacheless_predict.inputs['Classifier'].connect(self.Classifier) self.cacheless_predict.inputs['Image'].connect( self.FeatureImages) # <--- Not from cache self.cacheless_predict.inputs['LabelsCount'].connect(self.MaxLabel) self.HeadlessPredictionProbabilities.connect( self.cacheless_predict.PMaps) # Alternate headless output: uint8 instead of float. # Note that drange is automatically updated. self.opConvertToUint8 = OpPixelOperator(parent=self) self.opConvertToUint8.Input.connect(self.cacheless_predict.PMaps) self.opConvertToUint8.Function.setValue(lambda a: (255 * a).astype(numpy.uint8)) self.HeadlessUint8PredictionProbabilities.connect( self.opConvertToUint8.Output)