mv_machine_learning: drop create member from itask
authorInki Dae <inki.dae@samsung.com>
Thu, 27 Jul 2023 06:58:47 +0000 (15:58 +0900)
committerKwanghoon Son <k.son@samsung.com>
Mon, 7 Aug 2023 04:25:06 +0000 (13:25 +0900)
[Issue type] : code cleanup

Drop create interface from itask interface class.

The create interface isn't common but specific to certain task group.
Therefore, drop the interface from itask interface class, and change
the create member function of each adapter class to private member if needed.

Change-Id: I65264ede3d5b627c04b7fd6d8cb7555677b0d665
Signed-off-by: Inki Dae <inki.dae@samsung.com>
17 files changed:
mv_machine_learning/common/include/itask.h
mv_machine_learning/face_recognition/include/face_recognition_adapter.h
mv_machine_learning/face_recognition/include/facenet_adapter.h
mv_machine_learning/face_recognition/src/face_recognition_adapter.cpp
mv_machine_learning/face_recognition/src/facenet_adapter.cpp
mv_machine_learning/image_classification/include/image_classification_adapter.h
mv_machine_learning/image_classification/src/image_classification_adapter.cpp
mv_machine_learning/landmark_detection/include/facial_landmark_adapter.h
mv_machine_learning/landmark_detection/include/pose_landmark_adapter.h
mv_machine_learning/landmark_detection/src/facial_landmark_adapter.cpp
mv_machine_learning/landmark_detection/src/pose_landmark_adapter.cpp
mv_machine_learning/object_detection/include/face_detection_adapter.h
mv_machine_learning/object_detection/include/object_detection_adapter.h
mv_machine_learning/object_detection/src/face_detection_adapter.cpp
mv_machine_learning/object_detection/src/object_detection_adapter.cpp
mv_machine_learning/object_detection_3d/include/object_detection_3d_adapter.h
mv_machine_learning/object_detection_3d/src/object_detection_3d_adapter.cpp

index 2c32c10f3e2e52b818b139b8608246cd3eb49958..bfad5a915468436a58b23cf01a866b2ae666353c 100644 (file)
@@ -26,7 +26,6 @@ template<typename T, typename V> class ITask
 {
 public:
        virtual ~ITask() {};
-       virtual void create(int type) = 0;
        virtual void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                                          const char *model_name = "") = 0;
        virtual void setEngineInfo(const char *engine_type, const char *device_type) = 0;
index 2de90a734605d6de5c41a60aba8f1e887d494b13..b6acf6328f223af488384ccc30ad094fb296e748 100644 (file)
@@ -43,7 +43,6 @@ public:
                return _config;
        }
 
-       void create(int type) override;
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index 001eb8431b3303e3e9182d384459655baa18db68..17e1b261a9aede2f3d25eab26ad6270bacb19278 100644 (file)
@@ -37,7 +37,6 @@ public:
        FacenetAdapter();
        ~FacenetAdapter();
 
-       void create(int type) override;
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index 21d555c76708ea6e3723fd1f329db2792fd81196..a6126ef5b2c75e98aa90692b27b9ccd79a9fde1c 100644 (file)
@@ -35,11 +35,6 @@ template<typename T, typename V> FaceRecognitionAdapter<T, V>::FaceRecognitionAd
 template<typename T, typename V> FaceRecognitionAdapter<T, V>::~FaceRecognitionAdapter()
 {}
 
-template<typename T, typename V> void FaceRecognitionAdapter<T, V>::create(int type)
-{
-       throw InvalidOperation("Not support yet.");
-}
-
 template<typename T, typename V>
 void FaceRecognitionAdapter<T, V>::setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                                                                                const char *model_name)
index a65c34131f6a8e75c9ff10e1ac2bd1f20f9a33d5..7f16ba5f6ec3655ad0f1db8c8f906c0408bfa884 100644 (file)
@@ -34,11 +34,6 @@ template<typename T, typename V> FacenetAdapter<T, V>::FacenetAdapter() : _sourc
 template<typename T, typename V> FacenetAdapter<T, V>::~FacenetAdapter()
 {}
 
-template<typename T, typename V> void FacenetAdapter<T, V>::create(int type)
-{
-       throw InvalidOperation("Not support yet.");
-}
-
 template<typename T, typename V>
 void FacenetAdapter<T, V>::setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                                                                const char *model_name)
index 75f88d99c0cf78ea860c167426b5e4ae1faa62e0..45e493d831c9537d29677cb3d0dfa239dab7c948 100644 (file)
@@ -37,7 +37,6 @@ public:
        ImageClassificationAdapter();
        ~ImageClassificationAdapter();
 
-       void create(int type) override;
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index 29e2ae54c4deb64d271e6a883e5e0bb61207dede..4c59dd3c5ee3bb39e8f1faef567b1db9c0143680 100644 (file)
@@ -37,11 +37,6 @@ template<typename T, typename V> ImageClassificationAdapter<T, V>::ImageClassifi
 template<typename T, typename V> ImageClassificationAdapter<T, V>::~ImageClassificationAdapter()
 {}
 
-template<typename T, typename V> void ImageClassificationAdapter<T, V>::create(int type)
-{
-       throw InvalidOperation("Interface not supported.");
-}
-
 template<typename T, typename V>
 void ImageClassificationAdapter<T, V>::setModelInfo(const char *model_file, const char *meta_file,
                                                                                                        const char *label_file, const char *model_name)
index 49abb7607f3249684d6152a6328e294d7ad1a1fc..1ea521dbe275f24fe0e186e70358cd1d69ecce5e 100644 (file)
@@ -37,12 +37,12 @@ private:
        std::string _meta_file;
        std::string _label_file;
 
+       void create(LandmarkDetectionTaskType task_type);
+
 public:
        FacialLandmarkAdapter();
        ~FacialLandmarkAdapter();
 
-       void create(int type) override;
-
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index 99456dfd6bdbebaf6b5b01eb9e77661d5d7e7232..f2b7f53c38a31fefe81dee9f5e290cb48de33105 100644 (file)
@@ -37,12 +37,12 @@ private:
        std::string _meta_file;
        std::string _label_file;
 
+       void create(LandmarkDetectionTaskType task_type);
+
 public:
        PoseLandmarkAdapter();
        ~PoseLandmarkAdapter();
 
-       void create(int type) override;
-
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index 6d2943acb3895893c7eaee155f49c9642206f8e1..9fb19e0e17ff35a857ef5623c9a0290149cdba4e 100644 (file)
@@ -37,10 +37,8 @@ template<typename T, typename V> FacialLandmarkAdapter<T, V>::FacialLandmarkAdap
 template<typename T, typename V> FacialLandmarkAdapter<T, V>::~FacialLandmarkAdapter()
 {}
 
-template<typename T, typename V> void FacialLandmarkAdapter<T, V>::create(int type)
+template<typename T, typename V> void FacialLandmarkAdapter<T, V>::create(LandmarkDetectionTaskType task_type)
 {
-       LandmarkDetectionTaskType task_type = static_cast<LandmarkDetectionTaskType>(type);
-
        // If default task type is same as a given one then skip.
        if (_landmark_detection->getTaskType() == task_type)
                return;
@@ -61,15 +59,15 @@ void FacialLandmarkAdapter<T, V>::setModelInfo(const char *model_file, const cha
        if (!model_name_str.empty()) {
                transform(model_name_str.begin(), model_name_str.end(), model_name_str.begin(), ::toupper);
 
-               int model_type = 0;
+               LandmarkDetectionTaskType task_type = LandmarkDetectionTaskType::LANDMARK_DETECTION_TASK_NONE;
 
                if (model_name_str == string("FLD_TWEAK_CNN"))
-                       model_type = static_cast<int>(LandmarkDetectionTaskType::FLD_TWEAK_CNN);
+                       task_type = LandmarkDetectionTaskType::FLD_TWEAK_CNN;
                // TODO.
                else
                        throw InvalidParameter("Invalid landmark detection model name.");
 
-               create(static_cast<int>(model_type));
+               create(task_type);
        }
 
        _model_file = string(model_file);
index 3ba82d18891d2bdf550ca35cc3ee15d85e78c29a..5fb6c3132e0fd5d8e9a89964435fdb1239a5802f 100644 (file)
@@ -37,10 +37,8 @@ template<typename T, typename V> PoseLandmarkAdapter<T, V>::PoseLandmarkAdapter(
 template<typename T, typename V> PoseLandmarkAdapter<T, V>::~PoseLandmarkAdapter()
 {}
 
-template<typename T, typename V> void PoseLandmarkAdapter<T, V>::create(int type)
+template<typename T, typename V> void PoseLandmarkAdapter<T, V>::create(LandmarkDetectionTaskType task_type)
 {
-       LandmarkDetectionTaskType task_type = static_cast<LandmarkDetectionTaskType>(type);
-
        // If default task type is same as a given one then skip.
        if (_landmark_detection->getTaskType() == task_type)
                return;
@@ -61,15 +59,15 @@ void PoseLandmarkAdapter<T, V>::setModelInfo(const char *model_file, const char
        if (!model_name_str.empty()) {
                transform(model_name_str.begin(), model_name_str.end(), model_name_str.begin(), ::toupper);
 
-               int model_type = 0;
+               LandmarkDetectionTaskType task_type = LandmarkDetectionTaskType::LANDMARK_DETECTION_TASK_NONE;
 
                if (model_name_str == string("PLD_CPM"))
-                       model_type = static_cast<int>(LandmarkDetectionTaskType::PLD_CPM);
+                       task_type = LandmarkDetectionTaskType::PLD_CPM;
                // TODO.
                else
                        throw InvalidParameter("Invalid landmark detection model name.");
 
-               create(static_cast<int>(model_type));
+               create(task_type);
        }
 
        _model_file = string(model_file);
index d71bbe38bd33ef52fb03e68dd483bc0eb5f74e19..50e32d16aa82e8ce2edbc841ee16aac7e8ca0c57 100644 (file)
@@ -37,12 +37,12 @@ private:
        std::string _meta_file;
        std::string _label_file;
 
+       void create(ObjectDetectionTaskType task_type);
+
 public:
        FaceDetectionAdapter();
        ~FaceDetectionAdapter();
 
-       void create(int type) override;
-
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index 5975c6868f40db097bbd8197a095cbe76d8670b5..7aa6ff4089993a7c87182f932edacc7811394ec0 100644 (file)
@@ -38,12 +38,12 @@ private:
        std::string _meta_file;
        std::string _label_file;
 
+       void create(ObjectDetectionTaskType task_type);
+
 public:
        ObjectDetectionAdapter();
        ~ObjectDetectionAdapter();
 
-       void create(int type) override;
-
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index e718305c5cf33d41758c549dc288b40a31935d10..239a6d6e559c594a2b7fe9aa0df2cdf882db2cc2 100644 (file)
@@ -39,10 +39,8 @@ template<typename T, typename V> FaceDetectionAdapter<T, V>::~FaceDetectionAdapt
        _object_detection->preDestroy();
 }
 
-template<typename T, typename V> void FaceDetectionAdapter<T, V>::create(int type)
+template<typename T, typename V> void FaceDetectionAdapter<T, V>::create(ObjectDetectionTaskType task_type)
 {
-       ObjectDetectionTaskType task_type = static_cast<ObjectDetectionTaskType>(type);
-
        // If default task type is same as a given one then skip.
        if (_object_detection->getTaskType() == task_type)
                return;
@@ -63,15 +61,15 @@ void FaceDetectionAdapter<T, V>::setModelInfo(const char *model_file, const char
        if (!model_name_str.empty()) {
                transform(model_name_str.begin(), model_name_str.end(), model_name_str.begin(), ::toupper);
 
-               int model_type = 0;
+               ObjectDetectionTaskType task_type = ObjectDetectionTaskType::OBJECT_DETECTION_TASK_NONE;
 
                if (model_name_str == string("FD_MOBILENET_V1_SSD"))
-                       model_type = static_cast<int>(ObjectDetectionTaskType::FD_MOBILENET_V1_SSD);
+                       task_type = ObjectDetectionTaskType::FD_MOBILENET_V1_SSD;
                // TODO.
                else
                        throw InvalidParameter("Invalid face detection model name.");
 
-               create(static_cast<int>(model_type));
+               create(task_type);
        }
 
        _model_file = string(model_file);
index 6165c4a0c019298dec92a66afb17c35a2815d218..57993b3122c40f48b50b7350aadec72289c885a4 100644 (file)
@@ -40,10 +40,8 @@ template<typename T, typename V> ObjectDetectionAdapter<T, V>::~ObjectDetectionA
        _object_detection->preDestroy();
 }
 
-template<typename T, typename V> void ObjectDetectionAdapter<T, V>::create(int type)
+template<typename T, typename V> void ObjectDetectionAdapter<T, V>::create(ObjectDetectionTaskType task_type)
 {
-       ObjectDetectionTaskType task_type = static_cast<ObjectDetectionTaskType>(type);
-
        // If default task type is same as a given one then skip.
        if (_object_detection->getTaskType() == task_type)
                return;
@@ -68,30 +66,30 @@ void ObjectDetectionAdapter<T, V>::setModelInfo(const char *model_file, const ch
        if (!model_name_str.empty()) {
                transform(model_name_str.begin(), model_name_str.end(), model_name_str.begin(), ::toupper);
 
-               int model_type = 0;
+               ObjectDetectionTaskType task_type = ObjectDetectionTaskType::OBJECT_DETECTION_TASK_NONE;
 
                if (model_name_str == "OD_PLUGIN" || model_name_str == "FD_PLUGIN") {
                        if (model_name_str == "OD_PLUGIN")
-                               model_type = static_cast<int>(ObjectDetectionTaskType::OD_PLUGIN);
+                               task_type = ObjectDetectionTaskType::OD_PLUGIN;
                        if (model_name_str == "FD_PLUGIN")
-                               model_type = static_cast<int>(ObjectDetectionTaskType::FD_PLUGIN);
+                               task_type = ObjectDetectionTaskType::FD_PLUGIN;
 
                        // In case of using plugin module, model information will be managed by the plugin module.
                        // Therefore, create plugin instance now.
-                       create(model_type);
+                       create(task_type);
                        return;
                }
 
                if (model_name_str == string("MOBILENET_V1_SSD")) {
-                       model_type = static_cast<int>(ObjectDetectionTaskType::MOBILENET_V1_SSD);
+                       task_type = ObjectDetectionTaskType::MOBILENET_V1_SSD;
                } else if (model_name_str == string("MOBILENET_V2_SSD")) {
-                       model_type = static_cast<int>(ObjectDetectionTaskType::MOBILENET_V2_SSD);
+                       task_type = ObjectDetectionTaskType::MOBILENET_V2_SSD;
                        // TODO.
                } else {
                        throw InvalidParameter("Invalid object detection model name.");
                }
 
-               create(model_type);
+               create(task_type);
        }
 
        _model_file = string(model_file);
index 248f27ca12e62e9a375bcf273048727e78bebb73..542dc85717ab61ed22cda4d421b005f8a416ce68 100644 (file)
@@ -37,11 +37,12 @@ private:
        std::string _meta_file;
        std::string _label_file;
 
+       void create(ObjectDetection3dTaskType task_type);
+
 public:
        ObjectDetection3dAdapter();
        ~ObjectDetection3dAdapter();
 
-       void create(int type) override;
        void setModelInfo(const char *model_file, const char *meta_file, const char *label_file,
                                          const char *model_name) override;
        void setEngineInfo(const char *engine_type, const char *device_type) override;
index b782a39e6a5e872ac8da3baf0fccd8d12a8088c7..b72274f033e14e9a036831f21259a7b450f40387 100644 (file)
@@ -34,7 +34,7 @@ template<typename T, typename V> ObjectDetection3dAdapter<T, V>::ObjectDetection
 template<typename T, typename V> ObjectDetection3dAdapter<T, V>::~ObjectDetection3dAdapter()
 {}
 
-template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::create(int type)
+template<typename T, typename V> void ObjectDetection3dAdapter<T, V>::create(ObjectDetection3dTaskType task_type)
 {}
 
 template<typename T, typename V>
@@ -46,14 +46,14 @@ void ObjectDetection3dAdapter<T, V>::setModelInfo(const char *model_file, const
        if (!model_name_str.empty()) {
                transform(model_name_str.begin(), model_name_str.end(), model_name_str.begin(), ::toupper);
 
-               int model_type = 0;
+               ObjectDetection3dTaskType task_type = ObjectDetection3dTaskType::OBJECT_DETECTION_3D_TASK_NONE;
 
                if (model_name_str == string("OBJECTRON"))
-                       model_type = static_cast<int>(ObjectDetection3dTaskType::OBJECTRON);
+                       task_type = ObjectDetection3dTaskType::OBJECTRON;
                else
                        throw InvalidParameter("Invalid object detection 3d model name.");
 
-               create(static_cast<int>(model_type));
+               create(task_type);
        }
 
        _model_file = string(model_file);