FAST  3.2.0
Framework for Heterogeneous Medical Image Computing and Visualization
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
fast::NeuralNetwork Class Reference

#include <NeuralNetwork.hpp>

+ Inheritance diagram for fast::NeuralNetwork:
+ Collaboration diagram for fast::NeuralNetwork:

Public Member Functions

void load (std::string filename)
 
void load (std::vector< uint8_t > model, std::vector< uint8_t > weights)
 
void setInferenceEngine (InferenceEngine::pointer engine)
 
void setInferenceEngine (std::string engine)
 
InferenceEngine::pointer getInferenceEngine () const
 
void setInputNode (uint portID, std::string name, NodeType type=NodeType::IMAGE, TensorShape shape={})
 
void setOutputNode (uint portID, std::string name, NodeType type=NodeType::IMAGE, TensorShape shape={})
 
void setScaleFactor (float scale)
 
void setMeanAndStandardDeviation (float mean, float std)
 
void setMinAndMaxIntensity (float min, float max)
 
void setSignedInputNormalization (bool signedInputNormalization)
 
void setPreserveAspectRatio (bool preserve)
 
void setHorizontalFlipping (bool flip)
 
void setTemporalWindow (uint window)
 
virtual void setInputSize (std::string name, std::vector< int > size)
 
void loadAttributes ()
 
virtual ~NeuralNetwork ()
 
- Public Member Functions inherited from fast::ProcessObject
virtual ~ProcessObject ()
 
void update (int executeToken=-1)
 
RuntimeMeasurement::pointer getRuntime ()
 
RuntimeMeasurement::pointer getRuntime (std::string name)
 
RuntimeMeasurementsManager::pointer getAllRuntimes ()
 
void enableRuntimeMeasurements ()
 
void disableRuntimeMeasurements ()
 
void setMainDevice (ExecutionDevice::pointer device)
 
void setMainDeviceCriteria (const DeviceCriteria &citeria)
 
ExecutionDevice::pointer getMainDevice () const
 
void setDevice (uint deviceNumber, ExecutionDevice::pointer device)
 
void setDeviceCriteria (uint deviceNumber, const DeviceCriteria &criteria)
 
ExecutionDevice::pointer getDevice (uint deviceNumber) const
 
virtual DataChannel::pointer getOutputPort (uint portID=0)
 
virtual DataChannel::pointer getInputPort (uint portID=0)
 
virtual void setInputConnection (DataChannel::pointer port)
 
virtual void setInputConnection (uint portID, DataChannel::pointer port)
 
virtual void setInputData (DataObject::pointer data)
 
virtual void setInputData (uint portID, DataObject::pointer data)
 
int getNrOfInputConnections () const
 
int getNrOfOutputPorts () const
 
virtual std::string getNameOfClass () const =0
 
std::shared_ptr< AttributegetAttribute (std::string id)
 
std::unordered_map< std::string, std::shared_ptr< Attribute > > getAttributes ()
 
void setAttributes (std::vector< std::shared_ptr< Attribute >> attributes)
 
void stopPipeline ()
 
void setModified (bool modified)
 
template<class DataType >
std::shared_ptr< DataTypeupdateAndGetOutputData (uint portID=0)
 
- Public Member Functions inherited from fast::Object
 Object ()
 
virtual ~Object ()
 
ReportergetReporter ()
 

Protected Member Functions

 NeuralNetwork ()
 
virtual void run ()
 
std::unordered_map< std::string, Tensor::pointerprocessInputData ()
 
std::vector< std::shared_ptr< Image > > resizeImages (const std::vector< std::shared_ptr< Image >> &images, int width, int height, int depth)
 
Tensor::pointer convertImagesToTensor (std::vector< std::shared_ptr< Image >> image, const TensorShape &shape, bool temporal)
 
Tensor::pointer standardizeOutputTensorData (Tensor::pointer tensor, int sample=0)
 
- Protected Member Functions inherited from fast::ProcessObject
 ProcessObject ()
 
virtual void preExecute ()
 
virtual void postExecute ()
 
template<class DataType >
void createInputPort (uint portID, bool required=true)
 
template<class DataType >
void createOutputPort (uint portID)
 
template<class DataType >
std::shared_ptr< DataTypegetInputData (uint portID=0)
 
template<class DataType >
std::shared_ptr< DataTypegetOutputData (uint portID=0)
 
void addOutputData (uint portID, DataObject::pointer data)
 
bool hasNewInputData (uint portID)
 
virtual void waitToFinish ()
 
void createOpenCLProgram (std::string sourceFilename, std::string name="")
 
cl::Program getOpenCLProgram (std::shared_ptr< OpenCLDevice > device, std::string name="", std::string buildOptions="")
 
void createFloatAttribute (std::string id, std::string name, std::string description, float initialValue)
 
void createIntegerAttribute (std::string id, std::string name, std::string description, int initialValue)
 
void createBooleanAttribute (std::string id, std::string name, std::string description, bool initialValue)
 
void createStringAttribute (std::string id, std::string name, std::string description, std::string initialValue)
 
float getFloatAttribute (std::string id)
 
int getIntegerAttribute (std::string id)
 
bool getBooleanAttribute (std::string id)
 
std::string getStringAttribute (std::string id)
 
std::vector< float > getFloatListAttribute (std::string id)
 
std::vector< int > getIntegerListAttribute (std::string id)
 
std::vector< bool > getBooleanListAttribute (std::string id)
 
std::vector< std::string > getStringListAttribute (std::string id)
 
void changeDeviceOnInputs (uint deviceNumber, ExecutionDevice::pointer device)
 
void validateInputPortExists (uint portID)
 
void validateOutputPortExists (uint portID)
 
- Protected Member Functions inherited from fast::Object
ReporterreportError ()
 
ReporterreportWarning ()
 
ReporterreportInfo ()
 
ReporterEnd reportEnd () const
 

Protected Attributes

bool mPreserveAspectRatio
 
bool mHorizontalImageFlipping = false
 
bool mSignedInputNormalization = false
 
int mTemporalWindow = 0
 
int m_batchSize
 
float mScaleFactor
 
float mMean
 
float mStd
 
float mMinIntensity
 
float mMaxIntensity
 
bool mMinAndMaxIntensitySet = false
 
Vector3f mNewInputSpacing
 
std::unordered_map< std::string, std::vector< int > > mInputSizes
 
std::unordered_map< int, DataObject::pointerm_processedOutputData
 
std::shared_ptr< InferenceEnginem_engine
 
std::unordered_map< std::string, std::vector< std::shared_ptr< Image > > > mInputImages
 
std::unordered_map< std::string, std::vector< std::shared_ptr< Tensor > > > mInputTensors
 
- Protected Attributes inherited from fast::ProcessObject
bool mIsModified
 
int m_lastExecuteToken = -1
 
RuntimeMeasurementsManager::pointer mRuntimeManager
 
std::unordered_map< uint, bool > mRequiredInputs
 
std::unordered_map< uint, std::vector< uint > > mInputDevices
 
std::unordered_map< uint, ExecutionDevice::pointermDevices
 
std::unordered_map< uint, DeviceCriteriamDeviceCriteria
 
std::unordered_map< uint, DataChannel::pointermInputConnections
 
std::unordered_map< uint, std::vector< std::weak_ptr< DataChannel > > > mOutputConnections
 
std::unordered_map< uint, bool > mInputPorts
 
std::unordered_set< uintmOutputPorts
 
std::unordered_map< uint, std::pair< DataObject::pointer, uint64_t > > mLastProcessed
 
std::unordered_map< std::string, std::shared_ptr< OpenCLProgram > > mOpenCLPrograms
 
std::unordered_map< std::string, std::shared_ptr< Attribute > > mAttributes
 
std::unordered_map< std::string, std::string > m_frameData
 
std::unordered_set< std::string > m_lastFrame
 
int m_maximumNrOfFrames = -1
 
- Protected Attributes inherited from fast::Object
std::weak_ptr< ObjectmPtr
 

Additional Inherited Members

- Public Types inherited from fast::ProcessObject
typedef std::shared_ptr< ProcessObjectpointer
 
- Public Types inherited from fast::Object
typedef std::shared_ptr< Objectpointer
 
- Static Public Member Functions inherited from fast::ProcessObject
static std::string getStaticNameOfClass ()
 
- Static Public Member Functions inherited from fast::Object
static std::string getStaticNameOfClass ()
 

Constructor & Destructor Documentation

◆ ~NeuralNetwork()

virtual fast::NeuralNetwork::~NeuralNetwork ( )
virtual

◆ NeuralNetwork()

fast::NeuralNetwork::NeuralNetwork ( )
protected

Member Function Documentation

◆ convertImagesToTensor()

Tensor::pointer fast::NeuralNetwork::convertImagesToTensor ( std::vector< std::shared_ptr< Image >>  image,
const TensorShape shape,
bool  temporal 
)
protected

◆ getInferenceEngine()

InferenceEngine::pointer fast::NeuralNetwork::getInferenceEngine ( ) const

Retrieve current inference engine

Returns

◆ load() [1/2]

void fast::NeuralNetwork::load ( std::string  filename)

Load a given netowrk file. This takes time.

Parameters
filename

◆ load() [2/2]

void fast::NeuralNetwork::load ( std::vector< uint8_t >  model,
std::vector< uint8_t >  weights 
)

Load a network from memory provided as byte two byte vectors: model and weights

Parameters
model
weights

◆ loadAttributes()

void fast::NeuralNetwork::loadAttributes ( )
virtual

Reimplemented from fast::ProcessObject.

Reimplemented in fast::SegmentationNetwork.

◆ processInputData()

std::unordered_map<std::string, Tensor::pointer> fast::NeuralNetwork::processInputData ( )
protected

◆ resizeImages()

std::vector<std::shared_ptr<Image> > fast::NeuralNetwork::resizeImages ( const std::vector< std::shared_ptr< Image >> &  images,
int  width,
int  height,
int  depth 
)
protected

◆ run()

virtual void fast::NeuralNetwork::run ( )
protectedvirtual

◆ setHorizontalFlipping()

void fast::NeuralNetwork::setHorizontalFlipping ( bool  flip)

Setting this parameter to true will flip the input image horizontally. For pixel classification the output image will be flipped back.

Parameters
flip

◆ setInferenceEngine() [1/2]

void fast::NeuralNetwork::setInferenceEngine ( InferenceEngine::pointer  engine)

Specify which inference engine to use

Parameters
engine

◆ setInferenceEngine() [2/2]

void fast::NeuralNetwork::setInferenceEngine ( std::string  engine)

Specify which inference engine to use

Parameters
engine

◆ setInputNode()

void fast::NeuralNetwork::setInputNode ( uint  portID,
std::string  name,
NodeType  type = NodeType::IMAGE,
TensorShape  shape = {} 
)

◆ setInputSize()

virtual void fast::NeuralNetwork::setInputSize ( std::string  name,
std::vector< int >  size 
)
virtual

◆ setMeanAndStandardDeviation()

void fast::NeuralNetwork::setMeanAndStandardDeviation ( float  mean,
float  std 
)

For each input value i: new_i = (i - mean)/std, this is applied after the scale factor

Parameters
mean
std

◆ setMinAndMaxIntensity()

void fast::NeuralNetwork::setMinAndMaxIntensity ( float  min,
float  max 
)

Intensities of input image will be clipped at these values

Parameters
min
max

◆ setOutputNode()

void fast::NeuralNetwork::setOutputNode ( uint  portID,
std::string  name,
NodeType  type = NodeType::IMAGE,
TensorShape  shape = {} 
)

◆ setPreserveAspectRatio()

void fast::NeuralNetwork::setPreserveAspectRatio ( bool  preserve)

◆ setScaleFactor()

void fast::NeuralNetwork::setScaleFactor ( float  scale)

For each input value i: new_i = i*scale

Parameters
scale

◆ setSignedInputNormalization()

void fast::NeuralNetwork::setSignedInputNormalization ( bool  signedInputNormalization)

◆ setTemporalWindow()

void fast::NeuralNetwork::setTemporalWindow ( uint  window)

Set the temporal window for dynamic mode. If window > 1, assume the second dimension of the input tensor is the number of timesteps. If the window is set to 4, the frames t-3, t-2, t-1 and t, where t is the current timestep, will be given as input to the network.

Parameters
window

◆ standardizeOutputTensorData()

Tensor::pointer fast::NeuralNetwork::standardizeOutputTensorData ( Tensor::pointer  tensor,
int  sample = 0 
)
protected

Converts a tensor to channel last image ordering and takes care of frame data and spacing

Parameters
tensor
Returns

Member Data Documentation

◆ m_batchSize

int fast::NeuralNetwork::m_batchSize
protected

◆ m_engine

std::shared_ptr<InferenceEngine> fast::NeuralNetwork::m_engine
protected

◆ m_processedOutputData

std::unordered_map<int, DataObject::pointer> fast::NeuralNetwork::m_processedOutputData
protected

◆ mHorizontalImageFlipping

bool fast::NeuralNetwork::mHorizontalImageFlipping = false
protected

◆ mInputImages

std::unordered_map<std::string, std::vector<std::shared_ptr<Image> > > fast::NeuralNetwork::mInputImages
protected

◆ mInputSizes

std::unordered_map<std::string, std::vector<int> > fast::NeuralNetwork::mInputSizes
protected

◆ mInputTensors

std::unordered_map<std::string, std::vector<std::shared_ptr<Tensor> > > fast::NeuralNetwork::mInputTensors
protected

◆ mMaxIntensity

float fast::NeuralNetwork::mMaxIntensity
protected

◆ mMean

float fast::NeuralNetwork::mMean
protected

◆ mMinAndMaxIntensitySet

bool fast::NeuralNetwork::mMinAndMaxIntensitySet = false
protected

◆ mMinIntensity

float fast::NeuralNetwork::mMinIntensity
protected

◆ mNewInputSpacing

Vector3f fast::NeuralNetwork::mNewInputSpacing
protected

◆ mPreserveAspectRatio

bool fast::NeuralNetwork::mPreserveAspectRatio
protected

◆ mScaleFactor

float fast::NeuralNetwork::mScaleFactor
protected

◆ mSignedInputNormalization

bool fast::NeuralNetwork::mSignedInputNormalization = false
protected

◆ mStd

float fast::NeuralNetwork::mStd
protected

◆ mTemporalWindow

int fast::NeuralNetwork::mTemporalWindow = 0
protected

The documentation for this class was generated from the following file: