Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segNet: Add zero-copy class score getter #574

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions c/segNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,19 @@ bool segNet::Process( void* image, uint32_t width, uint32_t height, imageFormat
return true;
}

bool segNet::GetClassScores( float** class_scores, uint32_t* width, uint32_t* height, uint32_t* num_classes )
{
if ( mOutputs[0].CPU == NULL )
{
return false;
}
*class_scores = (float*) mOutputs[0].CPU;
*width = DIMS_W(mOutputs[0].dims);
*height = DIMS_H(mOutputs[0].dims);
*num_classes = DIMS_C(mOutputs[0].dims);
return true;
}


// argmax classification
bool segNet::classify( const char* ignore_class )
Expand Down
10 changes: 10 additions & 0 deletions c/segNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ class segNet : public tensorNet
bool Process( float* input, uint32_t width, uint32_t height, const char* ignore_class="void" );

/**
* Return per-pixel class probabilities, as well as number of classes and size of the output layer.
* Does not perform a memory copy.
* @param class_scores float pointer to destination array
* @param width pointer to the variable that will hold the output layer width
* @param height pointer to the variable that will hold the output layer height
* @param num_classes pointer to the variable that will hold the number of classes
*/
bool GetClassScores( float** class_scores, uint32_t* width, uint32_t* height, uint32_t* num_classes );

/**
* Produce a colorized segmentation mask.
*/
template<typename T> bool Mask( T* output, uint32_t width, uint32_t height, FilterMode filter=FILTER_LINEAR ) { return Mask((void*)output, width, height, imageFormatFromType<T>(), filter); }
Expand Down