Skip to content

Commit

Permalink
Merge branch 'feature/add-general-debug-information' into dev-0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
maumonteroj committed Jun 12, 2019
2 parents 0fc0317 + 475b00a commit e63de5e
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 132 deletions.
14 changes: 4 additions & 10 deletions ext/r2inference/gstfacenetv1.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <math.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_facenetv1_debug_category);
#define GST_CAT_DEFAULT gst_facenetv1_debug_category
Expand Down Expand Up @@ -209,20 +210,13 @@ gst_facenetv1_postprocess (GstVideoInference * vi, const gpointer prediction,
gboolean * valid_prediction)
{
GstClassificationMeta *class_meta = (GstClassificationMeta *) meta_model;
GstDebugLevel level;
GstDebugLevel gst_debug_level = GST_LEVEL_LOG;
GST_LOG_OBJECT (vi, "Postprocess");

gst_fill_classification_meta (class_meta, prediction, predsize);

/* Only display vector if debug level >= 6 */
level = gst_debug_category_get_threshold (gst_facenetv1_debug_category);
if (level >= GST_LEVEL_LOG) {
for (gint i = 0; i < class_meta->num_labels; ++i) {
gfloat current = ((gfloat *) prediction)[i];
GST_LOG_OBJECT (vi, "Output vector element %i : (%f)", i, current);
}
}

gst_inference_print_embedding (vi, gst_facenetv1_debug_category, class_meta,
prediction, gst_debug_level);
*valid_prediction = TRUE;
return TRUE;
}
Expand Down
21 changes: 4 additions & 17 deletions ext/r2inference/gstinceptionv1.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <string.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_inceptionv1_debug_category);
#define GST_CAT_DEFAULT gst_inceptionv1_debug_category
Expand Down Expand Up @@ -148,27 +149,13 @@ gst_inceptionv1_postprocess (GstVideoInference * vi, const gpointer prediction,
gboolean * valid_prediction)
{
GstClassificationMeta *class_meta = (GstClassificationMeta *) meta_model;
gint index;
gdouble max;
GstDebugLevel level;
GstDebugLevel gst_debug_level = GST_LEVEL_LOG;
GST_LOG_OBJECT (vi, "Postprocess");

gst_fill_classification_meta (class_meta, prediction, predsize);

/* Only compute the highest probability is label when debug >= 6 */
level = gst_debug_category_get_threshold (gst_inceptionv1_debug_category);
if (level >= GST_LEVEL_LOG) {
index = 0;
max = -1;
for (gint i = 0; i < class_meta->num_labels; ++i) {
gfloat current = ((gfloat *) prediction)[i];
if (current > max) {
max = current;
index = i;
}
}
GST_LOG_OBJECT (vi, "Highest probability is label %i : (%f)", index, max);
}
gst_inference_print_highest_probability (vi, gst_inceptionv1_debug_category,
class_meta, prediction, gst_debug_level);

*valid_prediction = TRUE;
return TRUE;
Expand Down
21 changes: 4 additions & 17 deletions ext/r2inference/gstinceptionv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <string.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_inceptionv2_debug_category);
#define GST_CAT_DEFAULT gst_inceptionv2_debug_category
Expand Down Expand Up @@ -215,27 +216,13 @@ gst_inceptionv2_postprocess (GstVideoInference * vi, const gpointer prediction,
gboolean * valid_prediction)
{
GstClassificationMeta *class_meta = (GstClassificationMeta *) meta_model;
gint index;
gdouble max;
GstDebugLevel level;
GstDebugLevel gst_debug_level = GST_LEVEL_LOG;
GST_LOG_OBJECT (vi, "Postprocess");

gst_fill_classification_meta (class_meta, prediction, predsize);

/* Only compute the highest probability is label when debug >= 6 */
level = gst_debug_category_get_threshold (gst_inceptionv2_debug_category);
if (level >= GST_LEVEL_LOG) {
index = 0;
max = -1;
for (gint i = 0; i < class_meta->num_labels; ++i) {
gfloat current = ((gfloat *) prediction)[i];
if (current > max) {
max = current;
index = i;
}
}
GST_LOG_OBJECT (vi, "Highest probability is label %i : (%f)", index, max);
}
gst_inference_print_highest_probability (vi, gst_inceptionv2_debug_category,
class_meta, prediction, gst_debug_level);

*valid_prediction = TRUE;
return TRUE;
Expand Down
21 changes: 4 additions & 17 deletions ext/r2inference/gstinceptionv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <string.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_inceptionv3_debug_category);
#define GST_CAT_DEFAULT gst_inceptionv3_debug_category
Expand Down Expand Up @@ -147,27 +148,13 @@ gst_inceptionv3_postprocess (GstVideoInference * vi, const gpointer prediction,
gboolean * valid_prediction)
{
GstClassificationMeta *class_meta = (GstClassificationMeta *) meta_model;
gint index;
gdouble max;
GstDebugLevel level;
GstDebugLevel gst_debug_level = GST_LEVEL_LOG;
GST_LOG_OBJECT (vi, "Postprocess");

gst_fill_classification_meta (class_meta, prediction, predsize);

/* Only compute the highest probability is label when debug >= 6 */
level = gst_debug_category_get_threshold (gst_inceptionv3_debug_category);
if (level >= GST_LEVEL_LOG) {
index = 0;
max = -1;
for (gint i = 0; i < class_meta->num_labels; ++i) {
gfloat current = ((gfloat *) prediction)[i];
if (current > max) {
max = current;
index = i;
}
}
GST_LOG_OBJECT (vi, "Highest probability is label %i : (%f)", index, max);
}
gst_inference_print_highest_probability (vi, gst_inceptionv3_debug_category,
class_meta, prediction, gst_debug_level);

*valid_prediction = TRUE;
return TRUE;
Expand Down
21 changes: 4 additions & 17 deletions ext/r2inference/gstinceptionv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <string.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_inceptionv4_debug_category);
#define GST_CAT_DEFAULT gst_inceptionv4_debug_category
Expand Down Expand Up @@ -214,27 +215,13 @@ gst_inceptionv4_postprocess (GstVideoInference * vi, const gpointer prediction,
gboolean * valid_prediction)
{
GstClassificationMeta *class_meta = (GstClassificationMeta *) meta_model;
gint index;
gdouble max;
GstDebugLevel level;
GstDebugLevel gst_debug_level = GST_LEVEL_LOG;
GST_LOG_OBJECT (vi, "Postprocess");

gst_fill_classification_meta (class_meta, prediction, predsize);

/* Only compute the highest probability is label when debug >= 6 */
level = gst_debug_category_get_threshold (gst_inceptionv4_debug_category);
if (level >= GST_LEVEL_LOG) {
index = 0;
max = -1;
for (gint i = 0; i < class_meta->num_labels; ++i) {
gfloat current = ((gfloat *) prediction)[i];
if (current > max) {
max = current;
index = i;
}
}
GST_LOG_OBJECT (vi, "Highest probability is label %i : (%f)", index, max);
}
gst_inference_print_highest_probability (vi, gst_inceptionv4_debug_category,
class_meta, prediction, gst_debug_level);

*valid_prediction = TRUE;
return TRUE;
Expand Down
21 changes: 4 additions & 17 deletions ext/r2inference/gstmobilenetv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <string.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_mobilenetv2_debug_category);
#define GST_CAT_DEFAULT gst_mobilenetv2_debug_category
Expand Down Expand Up @@ -146,27 +147,13 @@ gst_mobilenetv2_postprocess (GstVideoInference * vi, const gpointer prediction,
gboolean * valid_prediction)
{
GstClassificationMeta *class_meta = (GstClassificationMeta *) meta_model;
gint index;
gdouble max;
GstDebugLevel level;
GstDebugLevel gst_debug_level = GST_LEVEL_LOG;
GST_LOG_OBJECT (vi, "Postprocess");

gst_fill_classification_meta (class_meta, prediction, predsize);

/* Only compute the highest probability is label when debug >= 6 */
level = gst_debug_category_get_threshold (gst_mobilenetv2_debug_category);
if (level >= GST_LEVEL_LOG) {
index = 0;
max = -1;
for (gint i = 0; i < class_meta->num_labels; ++i) {
gfloat current = ((gfloat *) prediction)[i];
if (current > max) {
max = current;
index = i;
}
}
GST_LOG_OBJECT (vi, "Highest probability is label %i : (%f)", index, max);
}
gst_inference_print_highest_probability (vi, gst_mobilenetv2_debug_category,
class_meta, prediction, gst_debug_level);

*valid_prediction = TRUE;
return TRUE;
Expand Down
21 changes: 4 additions & 17 deletions ext/r2inference/gstresnet50v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <string.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_resnet50v1_debug_category);
#define GST_CAT_DEFAULT gst_resnet50v1_debug_category
Expand Down Expand Up @@ -152,27 +153,13 @@ gst_resnet50v1_postprocess (GstVideoInference * vi, const gpointer prediction,
gboolean * valid_prediction)
{
GstClassificationMeta *class_meta = (GstClassificationMeta *) meta_model;
gint index;
gdouble max;
GstDebugLevel level;
GstDebugLevel gst_debug_level = GST_LEVEL_LOG;
GST_LOG_OBJECT (vi, "Postprocess");

gst_fill_classification_meta (class_meta, prediction, predsize);

/* Only compute the highest probability is label when debug >= 6 */
level = gst_debug_category_get_threshold (gst_resnet50v1_debug_category);
if (level >= GST_LEVEL_LOG) {
index = 0;
max = -1;
for (gint i = 0; i < class_meta->num_labels; ++i) {
gfloat current = ((gfloat *) prediction)[i];
if (current > max) {
max = current;
index = i;
}
}
GST_LOG_OBJECT (vi, "Highest probability is label %i : (%f)", index, max);
}
gst_inference_print_highest_probability (vi, gst_resnet50v1_debug_category,
class_meta, prediction, gst_debug_level);

*valid_prediction = TRUE;
return TRUE;
Expand Down
11 changes: 2 additions & 9 deletions ext/r2inference/gsttinyyolov2.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <math.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_tinyyolov2_debug_category);
#define GST_CAT_DEFAULT gst_tinyyolov2_debug_category
Expand Down Expand Up @@ -282,25 +283,17 @@ gst_tinyyolov2_postprocess (GstVideoInference * vi, const gpointer prediction,
gsize predsize, GstMeta * meta_model, GstVideoInfo * info_model,
gboolean * valid_prediction)
{
gint index;
GstTinyyolov2 *tinyyolov2;
GstDetectionMeta *detect_meta = (GstDetectionMeta *) meta_model;
GST_LOG_OBJECT (vi, "Postprocess");
detect_meta->num_boxes = 0;
index = 0;
tinyyolov2 = GST_TINYYOLOV2 (vi);

gst_create_boxes (vi, prediction, detect_meta, info_model, valid_prediction,
&detect_meta->boxes, &detect_meta->num_boxes, tinyyolov2->obj_thresh,
tinyyolov2->prob_thresh, tinyyolov2->iou_thresh);

for (index = 0; index < detect_meta->num_boxes; index++) {
GST_LOG_OBJECT (vi,
"Box: [class:%d, x:%f, y:%f, width:%f, height:%f, prob:%f]",
detect_meta->boxes[index].label, detect_meta->boxes[index].x,
detect_meta->boxes[index].y, detect_meta->boxes[index].width,
detect_meta->boxes[index].height, detect_meta->boxes[index].prob);
}
gst_inference_print_boxes (vi, gst_tinyyolov2_debug_category, detect_meta);

*valid_prediction = (detect_meta->num_boxes > 0) ? TRUE : FALSE;

Expand Down
11 changes: 2 additions & 9 deletions ext/r2inference/gsttinyyolov3.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <string.h>
#include "gst/r2inference/gstinferencepreprocess.h"
#include "gst/r2inference/gstinferencepostprocess.h"
#include "gst/r2inference/gstinferencedebug.h"

GST_DEBUG_CATEGORY_STATIC (gst_tinyyolov3_debug_category);
#define GST_CAT_DEFAULT gst_tinyyolov3_debug_category
Expand Down Expand Up @@ -248,25 +249,17 @@ gst_tinyyolov3_postprocess (GstVideoInference * vi, const gpointer prediction,
gsize predsize, GstMeta * meta_model, GstVideoInfo * info_model,
gboolean * valid_prediction)
{
gint index;
GstTinyyolov3 *tinyyolov3;
GstDetectionMeta *detect_meta = (GstDetectionMeta *) meta_model;
GST_LOG_OBJECT (vi, "Postprocess");
detect_meta->num_boxes = 0;
tinyyolov3 = GST_TINYYOLOV3 (vi);
index = 0;

gst_create_boxes_float (vi, prediction, detect_meta, info_model,
valid_prediction, &detect_meta->boxes, &detect_meta->num_boxes,
tinyyolov3->obj_thresh, tinyyolov3->prob_thresh, tinyyolov3->iou_thresh);

for (index = 0; index < detect_meta->num_boxes; index++) {
GST_LOG_OBJECT (vi,
"Box: [class:%d, x:%f, y:%f, width:%f, height:%f, prob:%f]",
detect_meta->boxes[index].label, detect_meta->boxes[index].x,
detect_meta->boxes[index].y, detect_meta->boxes[index].width,
detect_meta->boxes[index].height, detect_meta->boxes[index].prob);
}
gst_inference_print_boxes (vi, gst_tinyyolov3_debug_category, detect_meta);

*valid_prediction = (detect_meta->num_boxes > 0) ? TRUE : FALSE;

Expand Down
6 changes: 4 additions & 2 deletions gst-libs/gst/r2inference/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ libgstinference_@GST_API_VERSION@_la_SOURCES= \
gstncsdk.cc \
gsttensorflow.cc \
gstinferencepreprocess.c \
gstinferencepostprocess.c
gstinferencepostprocess.c \
gstinferencedebug.c

libgstinference_@GST_API_VERSION@_la_CXXFLAGS= \
$(GST_CXXFLAGS) \
Expand Down Expand Up @@ -43,4 +44,5 @@ gstinferenceinclude_HEADERS= \
gstncsdk.h \
gsttensorflow.h \
gstinferencepreprocess.h \
gstinferencepostprocess.h
gstinferencepostprocess.h \
gstinferencedebug.h
Loading

0 comments on commit e63de5e

Please sign in to comment.