EXPECT_TRUE(answer_found);
}
-class TestImageClassification : public ::testing::Test
+class TestImageClassification : public TestInference
{
public:
- TestImageClassification()
- {
- EXPECT_EQ(mv_create_engine_config(&engine_cfg),
- MEDIA_VISION_ERROR_NONE);
- EXPECT_EQ(mv_inference_create(&infer), MEDIA_VISION_ERROR_NONE);
- EXPECT_EQ(mv_create_source(&mv_source), MEDIA_VISION_ERROR_NONE);
- }
- ~TestImageClassification()
- {
- EXPECT_EQ(mv_destroy_source(mv_source), MEDIA_VISION_ERROR_NONE);
- EXPECT_EQ(mv_inference_destroy(infer), MEDIA_VISION_ERROR_NONE);
- EXPECT_EQ(mv_destroy_engine_config(engine_cfg),
- MEDIA_VISION_ERROR_NONE);
- }
- void inference_banana()
+ void inferenceBanana()
{
ASSERT_EQ(mv_inference_configure(infer, engine_cfg),
MEDIA_VISION_ERROR_NONE);
_image_classified_cb, NULL),
MEDIA_VISION_ERROR_NONE);
}
- mv_engine_config_h engine_cfg;
- mv_inference_h infer;
- mv_source_h mv_source;
};
TEST_F(TestImageClassification, CPU_TFLITE_MobilenetV1)
engine_config_hosted_cpu_tflite_user_model(
engine_cfg, IC_TFLITE_WEIGHT_MOBILENET_V1_224_PATH,
IC_LABEL_MOBILENET_V1_224_PATH);
- inference_banana();
+ inferenceBanana();
}
TEST_F(TestImageClassification, CPU_TFLITE_MobilenetV2)
engine_config_hosted_cpu_tflite_user_model(
engine_cfg, IC_TFLITE_WEIGHT_MOBILENET_V2_224_PATH,
IC_LABEL_MOBILENET_V1_224_PATH);
- inference_banana();
+ inferenceBanana();
}
TEST_F(TestImageClassification, CPU_TFLITE_Densenet)
engine_config_hosted_cpu_tflite_user_model(
engine_cfg, IC_TFLITE_WEIGHT_DENSENET_224_PATH,
IC_LABEL_MOBILENET_V1_224_PATH);
- inference_banana();
+ inferenceBanana();
}
TEST_F(TestImageClassification, CPU_TFLITE_Nasnet)
engine_config_hosted_cpu_tflite_user_model(engine_cfg,
IC_TFLITE_WEIGHT_NASNET_224_PATH,
IC_LABEL_MOBILENET_V1_224_PATH);
- inference_banana();
+ inferenceBanana();
}
TEST_F(TestImageClassification, CPU_TFLITE_MNasnet)
engine_config_hosted_cpu_tflite_user_model(
engine_cfg, IC_TFLITE_WEIGHT_MNASNET_224_PATH,
IC_LABEL_MOBILENET_V1_224_PATH);
- inference_banana();
+ inferenceBanana();
}
TEST_F(TestImageClassification, CPU_TFLITE_Squeezenet)
engine_config_hosted_cpu_tflite_user_model(
engine_cfg, IC_TFLITE_WEIGHT_SQUEEZENET_224_PATH,
IC_LABEL_MOBILENET_V1_224_PATH);
- inference_banana();
+ inferenceBanana();
}
TEST_F(TestImageClassification, CPU_TFLITE_QUANT_MobilenetV1)
engine_config_hosted_cpu_tflite_user_model(
engine_cfg, IC_TFLITE_WEIGHT_QUANT_MOBILENET_V1_224_PATH,
IC_LABEL_MOBILENET_V1_224_PATH);
- inference_banana();
+ inferenceBanana();
}
\ No newline at end of file
#include <image_helper.h>
#include "test_inference_helper.hpp"
+TestInference::TestInference()
+{
+ EXPECT_EQ(mv_create_engine_config(&engine_cfg), MEDIA_VISION_ERROR_NONE);
+ EXPECT_EQ(mv_inference_create(&infer), MEDIA_VISION_ERROR_NONE);
+ EXPECT_EQ(mv_create_source(&mv_source), MEDIA_VISION_ERROR_NONE);
+}
+TestInference::~TestInference()
+{
+ EXPECT_EQ(mv_destroy_source(mv_source), MEDIA_VISION_ERROR_NONE);
+ EXPECT_EQ(mv_inference_destroy(infer), MEDIA_VISION_ERROR_NONE);
+ EXPECT_EQ(mv_destroy_engine_config(engine_cfg), MEDIA_VISION_ERROR_NONE);
+}
+
void engine_config_hosted_cpu_tflite(mv_engine_config_h handle,
const char *tf_weight)
{
--- /dev/null
+#include <gtest/gtest.h>
+#include <string>
+#include <ImageHelper.h>
+#include "test_inference_helper.hpp"
+
+#define OD_LABEL_MOBILENET_V1_SSD_300_PATH \
+ MV_CONFIG_PATH \
+ "/models/OD/tflite/od_mobilenet_v1_ssd_postop_label.txt"
+#define OD_TFLITE_WEIGHT_MOBILENET_V1_SSD_300_PATH \
+ MV_CONFIG_PATH \
+ "/models/OD/tflite/od_mobilenet_v1_ssd_postop_300x300.tflite"
+#define IMG_DOG \
+ MV_CONFIG_PATH \
+ "/res/inference/images/dog2.jpg"
+
+void _object_detected_cb(mv_source_h source, const int number_of_objects,
+ const int *indices, const char **names,
+ const float *confidences,
+ const mv_rectangle_s *locations, void *user_data)
+{
+ const std::string answer = "Dog";
+ auto answer_found = false;
+ for (int i = 0; i < number_of_objects; i++) {
+ if (answer == names[i]) {
+ answer_found = true;
+ }
+ }
+ EXPECT_TRUE(answer_found);
+}
+
+class TestObjectDetection : public TestInference
+{
+public:
+ void inferenceDog()
+ {
+ ASSERT_EQ(mv_inference_configure(infer, engine_cfg),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_inference_prepare(infer), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(MediaVision::Common::ImageHelper::loadImageToSource(
+ IMG_DOG, mv_source),
+ MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_inference_object_detect(mv_source, infer,
+ _object_detected_cb, NULL),
+ MEDIA_VISION_ERROR_NONE);
+ }
+};
+
+TEST_F(TestObjectDetection, CPU_TFLITE_MobilenetV1_SSD)
+{
+ engine_config_hosted_cpu_tflite_user_model(
+ engine_cfg, OD_TFLITE_WEIGHT_MOBILENET_V1_SSD_300_PATH,
+ OD_LABEL_MOBILENET_V1_SSD_300_PATH);
+ inferenceDog();
+}
\ No newline at end of file