inference: drop InferenceTaskInterface 58/310158/1
authorInki Dae <inki.dae@samsung.com>
Tue, 23 Apr 2024 08:01:41 +0000 (17:01 +0900)
committerInki Dae <inki.dae@samsung.com>
Tue, 23 Apr 2024 08:01:41 +0000 (17:01 +0900)
Drop IInferenceTaskInterface and its concreate classes which aren't needed
anymore. We can create targeted service through dedicated factory as
a IInferenceServiceInterface type.

Change-Id: I04e32648ff9e17cf85bc5d8d3032357e9f46379c
Signed-off-by: Inki Dae <inki.dae@samsung.com>
13 files changed:
inference/CMakeLists.txt
inference/backends/mediavision/CMakeLists.txt
inference/backends/mediavision/include/MvFaceDetection.h
inference/backends/mediavision/include/MvInferenceServiceFactory.h [new file with mode: 0644]
inference/backends/mediavision/include/MvObjectDetection.h
inference/backends/mediavision/src/MvInferenceServiceFactory.cpp [new file with mode: 0644]
inference/include/IInferenceTaskInterface.h [deleted file]
inference/include/InferenceServiceDefault.h [deleted file]
inference/include/InferenceServiceExternal.h [deleted file]
inference/include/MvInferenceServiceFactory.h [deleted file]
inference/src/InferenceServiceDefault.cpp [deleted file]
inference/src/InferenceServiceExternal.cpp [deleted file]
inference/src/MvInferenceServiceFactory.cpp [deleted file]

index 6313a1712c9ea7ecefd01f1af97f523c308ed543..d8a19f6a5833b967c730f247d8f612855737e132 100644 (file)
@@ -2,14 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.13)
 
 SET(INFERENCE_DIRECTORY ${ROOT_DIRECTORY}/inference)
 
-IF (${USE_EXTERNAL_INFERENCE_SERVICE})
-    SET(SINGLEO_SERVICE_SOURCE_FILES ${SINGLEO_SERVICE_SOURCE_FILES} ${INFERENCE_DIRECTORY}/src/InferenceServiceExternal.cpp)
-ELSE()
-    SET(SINGLEO_SERVICE_SOURCE_FILES ${SINGLEO_SERVICE_SOURCE_FILES}
-                                     ${INFERENCE_DIRECTORY}/src/InferenceServiceDefault.cpp
-                                     ${INFERENCE_DIRECTORY}/src/MvInferenceServiceFactory.cpp)
-ENDIF()
-
 INCLUDE(${INFERENCE_DIRECTORY}/backends/mediavision/CMakeLists.txt)
 
 LIST(APPEND INFERENCE_HEADER_LIST ${INFERENCE_HEADER_LIST} ${INFERENCE_DIRECTORY}/include)
index a32329e12457c03720a92c0b23c118847992ca71..6cbc3001c592863c7234f6d8042d35524d6ec358 100644 (file)
@@ -9,6 +9,7 @@ SET(SINGLEO_SERVICE_SOURCE_FILES
     ${SINGLEO_SERVICE_SOURCE_FILES}
     ${INFERENCE_MEDIAVISION_BACKEND_DIRECTORY}/src/MvFaceDetection.cpp
     ${INFERENCE_MEDIAVISION_BACKEND_DIRECTORY}/src/MvObjectDetection.cpp
+       ${INFERENCE_MEDIAVISION_BACKEND_DIRECTORY}/src/MvInferenceServiceFactory.cpp
 )
 
 LIST(APPEND INFERENCE_LIBRARY_LIST ${INFERENCE_LIBRARY_LIST} mv_common mv_inference mv_object_detection)
index fe463f78f2c0999dd2d102058e51856e8c9510e9..2379b2988c60a84b8a9066d04bb043bb16456eaf 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __FACE_DETECTION_H__
 #define __FACE_DETECTION_H__
 
-#include "IInferenceTaskInterface.h"
+#include "IInferenceServiceInterface.h"
 #include "mv_face_detection_internal.h"
 #include "SingleoCommonTypes.h"
 
@@ -27,7 +27,7 @@ namespace inference
 {
 namespace backends
 {
-class MvFaceDetection : public IInferenceTaskInterface
+class MvFaceDetection : public IInferenceServiceInterface
 {
 private:
        mv_face_detection_h _handle {};
diff --git a/inference/backends/mediavision/include/MvInferenceServiceFactory.h b/inference/backends/mediavision/include/MvInferenceServiceFactory.h
new file mode 100644 (file)
index 0000000..351203e
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MV_INFERENCE_SERVICE_FACTORY_H__
+#define __MV_INFERENCE_SERVICE_FACTORY_H__
+
+#include "IInferenceServiceFactory.h"
+
+namespace singleo
+{
+namespace inference
+{
+class MvInferenceServiceFactory : public IInferenceServiceFactory
+{
+private:
+       static bool _registered;
+
+public:
+       MvInferenceServiceFactory() = default;
+       virtual ~MvInferenceServiceFactory() = default;
+
+       std::unique_ptr<IInferenceServiceInterface> createImageClassification() override;
+       std::unique_ptr<IInferenceServiceInterface> createObjectDetection() override;
+       std::unique_ptr<IInferenceServiceInterface> createFaceDetection() override;
+       std::unique_ptr<IInferenceServiceInterface> createFaceLandmarkDetection() override;
+};
+
+}
+}
+
+#endif
index dab3a354b9c1027c228bcc68a9445714252d3100..9c8a97f4844857786e45f2a711cd086eecf0e763 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __OBJECT_DETECTION_H__
 #define __OBJECT_DETECTION_H__
 
-#include "IInferenceTaskInterface.h"
+#include "IInferenceServiceInterface.h"
 #include "mv_object_detection_internal.h"
 #include "SingleoCommonTypes.h"
 
@@ -27,7 +27,7 @@ namespace inference
 {
 namespace backends
 {
-class MvObjectDetection : public IInferenceTaskInterface
+class MvObjectDetection : public IInferenceServiceInterface
 {
 private:
        mv_object_detection_h _handle {};
diff --git a/inference/backends/mediavision/src/MvInferenceServiceFactory.cpp b/inference/backends/mediavision/src/MvInferenceServiceFactory.cpp
new file mode 100644 (file)
index 0000000..5ff3b7b
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "InferenceServiceFactory.h"
+#include "MvInferenceServiceFactory.h"
+#include "MvFaceDetection.h"
+#include "MvObjectDetection.h"
+#include "SingleoLog.h"
+#include "SingleoException.h"
+
+using namespace std;
+using namespace singleo::exception;
+using namespace singleo::inference::backends;
+
+namespace singleo
+{
+namespace inference
+{
+bool MvInferenceServiceFactory::_registered =
+               registerInferenceServiceFactory<MvInferenceServiceFactory>("MvInferenceServiceFactory");
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createImageClassification()
+{
+       throw InvalidOperation("Interface not supported yet.");
+}
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createObjectDetection()
+{
+       return make_unique<MvObjectDetection>();
+}
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceDetection()
+{
+       return make_unique<MvFaceDetection>();
+}
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceLandmarkDetection()
+{
+       throw InvalidOperation("Interface not supported yet.");
+}
+
+}
+}
diff --git a/inference/include/IInferenceTaskInterface.h b/inference/include/IInferenceTaskInterface.h
deleted file mode 100644 (file)
index 2b0aa78..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __IINFERENCE_TASK_INTERFACE_H__
-#define __IINFERENCE_TASK_INTERFACE_H__
-
-#include "SingleoCommonTypes.h"
-
-namespace singleo
-{
-namespace inference
-{
-class IInferenceTaskInterface
-{
-public:
-       virtual ~IInferenceTaskInterface() {};
-
-       virtual void configure() = 0;
-       virtual void prepare() = 0;
-       virtual void invoke(BaseDataType &input, bool async = false) = 0;
-       virtual BaseResultType &result() = 0;
-};
-
-} // inference
-} // singleo
-
-#endif
\ No newline at end of file
diff --git a/inference/include/InferenceServiceDefault.h b/inference/include/InferenceServiceDefault.h
deleted file mode 100644 (file)
index c33f326..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __INFERENCE_SERVICE_DEFAULT_H__
-#define __INFERENCE_SERVICE_DEFAULT_H__
-
-#include <memory>
-#include "IInferenceServiceInterface.h"
-#include "IInferenceTaskInterface.h"
-#include "SingleoInferenceTypes.h"
-#include "SingleoCommonTypes.h"
-
-namespace singleo
-{
-namespace inference
-{
-class InferenceServiceDefault : public IInferenceServiceInterface
-{
-private:
-       std::unique_ptr<IInferenceTaskInterface> _task;
-
-public:
-       explicit InferenceServiceDefault(TaskType task_type);
-       virtual ~InferenceServiceDefault() = default;
-
-       void configure() override;
-       void prepare() override;
-       void invoke(BaseDataType &input, bool async = false) override;
-       BaseResultType &result() override;
-};
-
-} // inference
-} // singleo
-
-#endif
diff --git a/inference/include/InferenceServiceExternal.h b/inference/include/InferenceServiceExternal.h
deleted file mode 100644 (file)
index 955ae1d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __INFERENCE_SERVICE_EXTERNAL_H__
-#define __INFERENCE_SERVICE_EXTERNAL_H__
-
-#include "IInferenceServiceInterface.h"
-#include "IInferenceTaskInterface.h"
-#include "SingleoInferenceTypes.h"
-#include "SingleoCommonTypes.h"
-
-namespace singleo
-{
-namespace inference
-{
-class InferenceServiceExternal : public IInferenceServiceInterface
-{
-public:
-       explicit InferenceServiceExternal(TaskType task_type);
-       virtual ~InferenceServiceExternal();
-
-       void configure(TaskType task_type) override;
-       void prepare() override;
-       void invoke(BaseDataType &input, bool async = false) override;
-       BaseResultType &result() override;
-};
-
-} // inference
-} // singleo
-
-#endif
diff --git a/inference/include/MvInferenceServiceFactory.h b/inference/include/MvInferenceServiceFactory.h
deleted file mode 100644 (file)
index 351203e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MV_INFERENCE_SERVICE_FACTORY_H__
-#define __MV_INFERENCE_SERVICE_FACTORY_H__
-
-#include "IInferenceServiceFactory.h"
-
-namespace singleo
-{
-namespace inference
-{
-class MvInferenceServiceFactory : public IInferenceServiceFactory
-{
-private:
-       static bool _registered;
-
-public:
-       MvInferenceServiceFactory() = default;
-       virtual ~MvInferenceServiceFactory() = default;
-
-       std::unique_ptr<IInferenceServiceInterface> createImageClassification() override;
-       std::unique_ptr<IInferenceServiceInterface> createObjectDetection() override;
-       std::unique_ptr<IInferenceServiceInterface> createFaceDetection() override;
-       std::unique_ptr<IInferenceServiceInterface> createFaceLandmarkDetection() override;
-};
-
-}
-}
-
-#endif
diff --git a/inference/src/InferenceServiceDefault.cpp b/inference/src/InferenceServiceDefault.cpp
deleted file mode 100644 (file)
index 4de47f4..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "InferenceServiceDefault.h"
-#include "MvObjectDetection.h"
-#include "MvFaceDetection.h"
-
-using namespace std;
-using namespace singleo::inference::backends;
-
-namespace singleo
-{
-namespace inference
-{
-InferenceServiceDefault::InferenceServiceDefault(TaskType task_type)
-{
-       // TODO. add other task types later.
-       if (task_type != TaskType::OBJECT_DETECTION && task_type != TaskType::FACE_DETECTION)
-               invalid_argument("Task type not supported.");
-
-       switch (task_type) {
-       case TaskType::OBJECT_DETECTION:
-               _task = make_unique<MvObjectDetection>();
-               break;
-       case TaskType::FACE_DETECTION:
-               _task = make_unique<MvFaceDetection>();
-               break;
-       }
-}
-
-void InferenceServiceDefault::configure()
-{
-       _task->configure();
-}
-
-void InferenceServiceDefault::prepare()
-{
-       _task->prepare();
-}
-
-void InferenceServiceDefault::invoke(BaseDataType &input, bool async)
-{
-       _task->invoke(input, async);
-}
-
-BaseResultType &InferenceServiceDefault::result()
-{
-       return _task->result();
-}
-
-}
-}
diff --git a/inference/src/InferenceServiceExternal.cpp b/inference/src/InferenceServiceExternal.cpp
deleted file mode 100644 (file)
index 76fa63a..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdexcept>
-#include "InferenceServiceExternal.h"
-
-using namespace std;
-
-namespace singleo
-{
-namespace inference
-{
-InferenceServiceExternal::InferenceServiceExternal(TaskType task_type)
-{}
-InferenceServiceExternal::~InferenceServiceExternal()
-{}
-
-void InferenceServiceExternal::configure(TaskType task_type)
-{
-       throw runtime_error("Not support yet.");
-}
-
-void InferenceServiceExternal::prepare()
-{
-       throw runtime_error("Not support yet.");
-}
-
-void InferenceServiceExternal::invoke(BaseDataType &input, bool async)
-{
-       throw runtime_error("Not support yet.");
-}
-
-BaseResultType &InferenceServiceExternal::result()
-{
-       throw runtime_error("Not support yet.");
-}
-
-}
-}
diff --git a/inference/src/MvInferenceServiceFactory.cpp b/inference/src/MvInferenceServiceFactory.cpp
deleted file mode 100644 (file)
index 87b3a09..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "InferenceServiceFactory.h"
-#include "InferenceServiceDefault.h"
-#include "MvInferenceServiceFactory.h"
-#include "SingleoLog.h"
-#include "SingleoException.h"
-
-using namespace std;
-using namespace singleo::exception;
-
-namespace singleo
-{
-namespace inference
-{
-bool MvInferenceServiceFactory::_registered =
-               registerInferenceServiceFactory<MvInferenceServiceFactory>("MvInferenceServiceFactory");
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createImageClassification()
-{
-       throw InvalidOperation("Interface not supported yet.");
-}
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createObjectDetection()
-{
-       return make_unique<InferenceServiceDefault>(TaskType::OBJECT_DETECTION);
-}
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceDetection()
-{
-       return make_unique<InferenceServiceDefault>(TaskType::FACE_DETECTION);
-}
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceLandmarkDetection()
-{
-       throw InvalidOperation("Interface not supported yet.");
-}
-
-}
-}