Skip to content

Commit 098ac7c

Browse files
committed
Update InspireFace to 1.1.0
1 parent a1e535c commit 098ac7c

File tree

89 files changed

+4096
-510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+4096
-510
lines changed

cpp-package/inspireface/.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ test_res/*
77
resource/*
88
pack/*
99
*.zip
10-
3rdparty
10+
3rdparty/
11+
.macos_cache/
12+
*.framework
13+
.cache/*
14+
.vscode/*
15+
build_local/*

cpp-package/inspireface/CMakeLists.txt

+60-26
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
#cmake_minimum_required(VERSION 3.19)
21
cmake_minimum_required(VERSION 3.10)
32
project(InspireFace)
43

54
set(CMAKE_CXX_STANDARD 14)
6-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++14")
75
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
86
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
97
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
108

9+
# Current version
10+
set(INSPIRE_FACE_VERSION_MAJOR 1)
11+
set(INSPIRE_FACE_VERSION_MINOR 1)
12+
set(INSPIRE_FACE_VERSION_PATCH 0)
13+
14+
# Converts the version number to a string
15+
string(CONCAT INSPIRE_FACE_VERSION_MAJOR_STR ${INSPIRE_FACE_VERSION_MAJOR})
16+
string(CONCAT INSPIRE_FACE_VERSION_MINOR_STR ${INSPIRE_FACE_VERSION_MINOR})
17+
string(CONCAT INSPIRE_FACE_VERSION_PATCH_STR ${INSPIRE_FACE_VERSION_PATCH})
18+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/information.h.in ${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/information.h)
19+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/version.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/version.txt)
20+
1121
# Set the ISF_THIRD_PARTY_DIR variable to allow it to be set externally from the command line, or use the default path if it is not set
1222
set(ISF_THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty" CACHE PATH "Path to the third-party libraries directory")
1323

@@ -78,8 +88,24 @@ set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cpp/)
7888

7989
# OpenCV dependency configuration
8090
if (APPLE)
81-
set(PLAT darwin)
82-
find_package(OpenCV REQUIRED)
91+
if (IOS)
92+
message(IOS_3RDPARTY=${IOS_3RDPARTY})
93+
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO)
94+
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE NO)
95+
96+
link_directories(${IOS_3RDPARTY})
97+
include_directories(${IOS_3RDPARTY}/opencv2.framework)
98+
99+
set(MNN_FRAMEWORK_PATH "${IOS_3RDPARTY}/MNN.framework")
100+
include_directories("${MNN_FRAMEWORK_PATH}/")
101+
102+
set(OpenCV_DIR "${IOS_3RDPARTY}/opencv2.framework")
103+
# find_package(OpenCV REQUIRED)
104+
else()
105+
message("Use apple device")
106+
set(PLAT darwin)
107+
find_package(OpenCV REQUIRED)
108+
endif ()
83109
else()
84110
if (ISF_BUILD_LINUX_ARM7 OR ISF_BUILD_LINUX_AARCH64)
85111
add_definitions("-DDISABLE_GUI")
@@ -115,35 +141,43 @@ else()
115141
find_package(OpenCV REQUIRED)
116142
endif ()
117143

144+
set(ISF_LINUX_MNN_CUDA "" CACHE STRING "Path to CUDA directory")
118145

119-
# MNN Config
120-
if (NOT ANDROID)
121-
122-
if (ISF_GLOBAL_INFERENCE_BACKEND_USE_MNN_CUDA)
123-
# Use MNN Cuda
124-
message("Global MNN CUDA device inference")
125-
add_definitions("-DISF_GLOBAL_INFERENCE_BACKEND_USE_MNN_CUDA")
126-
set(MNN_INCLUDE_DIRS ${ISF_LINUX_MNN_CUDA}/include)
127-
link_directories(${ISF_LINUX_MNN_CUDA}/lib)
128-
set(MNN_LIBS MNN)
129-
130-
elseif(DEFINED MNN_STATIC_PATH)
131-
message("Using static MNN from specified path: ${MNN_STATIC_PATH}")
132-
set(MNN_INCLUDE_DIRS "${MNN_STATIC_PATH}/include")
133-
set(MNN_LIBS "${MNN_STATIC_PATH}/lib/libMNN.a")
134-
else ()
135-
# Default or fallback case for MNN setup
136-
message("Default or fallback case for MNN setup")
146+
if (ISF_GLOBAL_INFERENCE_BACKEND_USE_MNN_CUDA)
147+
message("Global MNN CUDA device inference")
148+
add_definitions("-DISF_GLOBAL_INFERENCE_BACKEND_USE_MNN_CUDA")
149+
# Use MNN Cuda
150+
if (NOT DEFINED ISF_LINUX_MNN_CUDA)
137151
# MNN Options
138-
set(MNN_BUILD_SHARED_LIBS OFF CACHE BOOL "Build MNN as a shared library")
139-
152+
set(MNN_CUDA ON)
140153
add_subdirectory(${ISF_THIRD_PARTY_DIR}/MNN EXCLUDE_FROM_ALL)
141154
set(MNN_INCLUDE_DIRS "${ISF_THIRD_PARTY_DIR}/MNN/include")
142155
set(MNN_LIBS MNN)
156+
else()
157+
message(ISF_LINUX_MNN_CUDA=${ISF_LINUX_MNN_CUDA})
158+
set(MNN_INCLUDE_DIRS ${ISF_LINUX_MNN_CUDA}/include)
159+
link_directories(${ISF_LINUX_MNN_CUDA}/)
160+
set(MNN_LIBS MNN)
161+
endif()
143162

144-
endif ()
163+
elseif(DEFINED MNN_STATIC_PATH)
164+
message("Using static MNN from specified path: ${MNN_STATIC_PATH}")
165+
set(MNN_INCLUDE_DIRS "${MNN_STATIC_PATH}/include")
166+
set(MNN_LIBS "${MNN_STATIC_PATH}/lib/libMNN.a")
167+
elseif(IOS)
168+
message(Build iOS)
169+
else ()
170+
# Default or fallback case for MNN setup
171+
message("Default or fallback case for MNN setup")
172+
# MNN Options
173+
set(MNN_BUILD_SHARED_LIBS OFF CACHE BOOL "Build MNN as a shared library")
174+
175+
add_subdirectory(${ISF_THIRD_PARTY_DIR}/MNN EXCLUDE_FROM_ALL)
176+
set(MNN_INCLUDE_DIRS "${ISF_THIRD_PARTY_DIR}/MNN/include")
177+
set(MNN_LIBS MNN)
178+
179+
endif ()
145180

146-
endif()
147181

148182
# Set install path
149183
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")

cpp-package/inspireface/README.md

+30-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ If you require further information on tracking development branches, CI/CD proce
88

99
Please contact [[email protected]](mailto:[email protected]?subject=InspireFace) for commercial support, including obtaining and integrating higher accuracy models, as well as custom development.
1010

11+
## Top News
12+
13+
**`2024-06-18`** Added face detection feature with tracking-by-detection mode.
14+
15+
**`2024-06-01`** Adapted for accelerated inference on CUDA-enabled devices.
16+
1117
## 1. Preparation
1218
### 1.1. Clone 3rdparty
1319

@@ -105,12 +111,12 @@ We have completed the adaptation and testing of the software across various oper
105111
| 2 | | ARMv8 | - | [![build](https://img.shields.io/github/actions/workflow/status/HyperInspire/InspireFace/release-sdks.yaml?&style=for-the-badge&label=build)](https://github.com/HyperInspire/InspireFace/actions/workflows/release-sdks.yaml) | ![test](https://img.shields.io/badge/OFFLINE-PASSING-blue?style=for-the-badge) |
106112
| 3 | | x86/x86_64 | - | [![build](https://img.shields.io/github/actions/workflow/status/HyperInspire/InspireFace/release-sdks.yaml?&style=for-the-badge&label=build)](https://github.com/HyperInspire/InspireFace/actions/workflows/release-sdks.yaml) | [![test](https://img.shields.io/github/actions/workflow/status/HyperInspire/InspireFace/test_ubuntu_x86_Pikachu.yaml?style=for-the-badge&label=Test&color=blue)](https://github.com/HyperInspire/InspireFace/actions/workflows/test_ubuntu_x86_Pikachu.yaml) |
107113
| 4 | | ARMv7 | RV1109RV1126 | [![build](https://img.shields.io/github/actions/workflow/status/HyperInspire/InspireFace/release-sdks.yaml?&style=for-the-badge&label=build)](https://github.com/HyperInspire/InspireFace/actions/workflows/release-sdks.yaml) | ![test](https://img.shields.io/badge/OFFLINE-PASSING-blue?style=for-the-badge) |
108-
| 5 | | x86/x86_64 | CUDA | ![build](https://img.shields.io/badge/OFFLINE-PASSING-green?style=for-the-badge) | |
114+
| 5 | | x86/x86_64 | CUDA | ![build](https://img.shields.io/badge/OFFLINE-PASSING-green?style=for-the-badge) | ![test](https://img.shields.io/badge/OFFLINE-PASSING-blue?style=for-the-badge) |
109115
| 6 | **macOS** | Intel x86 | - | ![build](https://img.shields.io/badge/OFFLINE-PASSING-green?style=for-the-badge) | ![test](https://img.shields.io/badge/OFFLINE-PASSING-blue?style=for-the-badge) |
110116
| 7 | | Apple Silicon | - | ![build](https://img.shields.io/badge/OFFLINE-PASSING-green?style=for-the-badge) | ![test](https://img.shields.io/badge/OFFLINE-PASSING-blue?style=for-the-badge) |
111-
| 8 | **iOS** | ARM | - | | |
112-
| 9 | **Android** | ARMv7 | - | | |
113-
| 10 | | ARMv8 | - | | |
117+
| 8 | **iOS** | ARM | - | [![build](https://img.shields.io/github/actions/workflow/status/HyperInspire/InspireFace/release-sdks.yaml?&style=for-the-badge&label=build)](https://github.com/HyperInspire/InspireFace/actions/workflows/release-sdks.yaml) | |
118+
| 9 | **Android** | ARMv7 | - | [![build](https://img.shields.io/github/actions/workflow/status/HyperInspire/InspireFace/release-sdks.yaml?&style=for-the-badge&label=build)](https://github.com/HyperInspire/InspireFace/actions/workflows/release-sdks.yaml) | |
119+
| 10 | | ARMv8 | - | [![build](https://img.shields.io/github/actions/workflow/status/HyperInspire/InspireFace/release-sdks.yaml?&style=for-the-badge&label=build)](https://github.com/HyperInspire/InspireFace/actions/workflows/release-sdks.yaml) | |
114120

115121
- Complete compilation scripts and successful compilation.
116122
- Pass unit tests on physical devices.
@@ -129,6 +135,9 @@ build-cross-armv7-armhf
129135
# Build armv7 with support RV1109RV1126 device NPU cross-complie
130136
docker-compose up build-cross-rv1109rv1126-armhf
131137

138+
# Build Android with support arm64-v8a and armeabi-v7a
139+
docker-compose up build-cross-android
140+
132141
# Build all
133142
docker-compose up
134143
```
@@ -154,7 +163,7 @@ HFDetectMode detMode = HF_DETECT_MODE_IMAGE;
154163
HInt32 maxDetectNum = 5;
155164
// Handle of the current face SDK algorithm context
156165
HFSession session = {0};
157-
ret = HFCreateInspireFaceSessionOptional(option, detMode, maxDetectNum, &session);
166+
ret = HFCreateInspireFaceSessionOptional(option, detMode, maxDetectNum, -1, -1, &session);
158167
if (ret != HSUCCEED) {
159168
std::cout << "Create FaceContext error: " << ret << std::endl;
160169
return ret;
@@ -296,6 +305,22 @@ During the process of building the test program using CMake, it will involve sel
296305

297306
**Note**: If you want to view the benchmark test report, you can click on the [link](doc/Benchmark-Remark(Updating).md).
298307

308+
### Quick Test
309+
310+
If you need to perform a quick test, you can use the script we provide. This script will automatically download the test file `test_res` and build the test program to run the test.
311+
312+
*Note: If you need to enable more comprehensive tests, you can adjust the options in the script as needed.*
313+
314+
```bash
315+
# If you are using Ubuntu, you can execute this.
316+
bash ci/quick_test_linux_x86_usual.sh
317+
318+
# If you are using another system (including Ubuntu), you can execute this.
319+
bash ci/quick_test_local.sh
320+
```
321+
322+
Every time code is committed, tests are run on GitHub Actions.
323+
299324
## 5. Function Support
300325
The following functionalities and technologies are currently supported.
301326

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
# Exit immediately if any command exits with a non-zero status
4+
set -e
5+
6+
TARGET_DIR="test_res"
7+
DOWNLOAD_URL="https://github.com/tunmx/inspireface-store/raw/main/resource/test_res-lite.zip"
8+
ZIP_FILE="test_res-lite.zip"
9+
BUILD_DIRNAME="quick_test_build"
10+
TEST_DIR="./build/${BUILD_DIRNAME}/test"
11+
TEST_EXECUTABLE="./test/Test"
12+
13+
# Check if the target directory already exists
14+
if [ ! -d "$TARGET_DIR" ]; then
15+
echo "Directory '$TARGET_DIR' does not exist. Downloading..."
16+
17+
# Download the dataset zip file
18+
wget -q "$DOWNLOAD_URL" -O "$ZIP_FILE"
19+
20+
echo "Extracting '$ZIP_FILE' to '$TARGET_DIR'..."
21+
# Unzip the downloaded file
22+
unzip "$ZIP_FILE"
23+
24+
# Remove the downloaded zip file and unnecessary folders
25+
rm "$ZIP_FILE"
26+
rm -rf "__MACOSX"
27+
28+
echo "Download and extraction complete."
29+
else
30+
echo "Directory '$TARGET_DIR' already exists. Skipping download."
31+
fi
32+
33+
# Get the absolute path of the target directory
34+
FULL_TEST_DIR="$(realpath ${TARGET_DIR})"
35+
36+
# Create the build directory if it doesn't exist
37+
mkdir -p build/${BUILD_DIRNAME}/
38+
39+
# Change directory to the build directory
40+
# Disable the shellcheck warning for potential directory changes
41+
# shellcheck disable=SC2164
42+
cd build/${BUILD_DIRNAME}/
43+
44+
# Configure the CMake build system
45+
cmake -DCMAKE_BUILD_TYPE=Release \
46+
-DISF_BUILD_WITH_SAMPLE=OFF \
47+
-DISF_BUILD_WITH_TEST=ON \
48+
-DISF_ENABLE_BENCHMARK=ON \
49+
-DISF_ENABLE_USE_LFW_DATA=OFF \
50+
-DISF_ENABLE_TEST_EVALUATION=OFF \
51+
-DISF_BUILD_SHARED_LIBS=OFF ../../
52+
53+
# Compile the project using 4 parallel jobs
54+
make -j4
55+
56+
# Create a symbolic link to the extracted test data directory
57+
ln -s ${FULL_TEST_DIR} .
58+
59+
# Check if the test executable file exists
60+
if [ ! -f "$TEST_EXECUTABLE" ]; then
61+
# If not, print an error message and exit with a non-zero status code
62+
echo "Error: Test executable '$TEST_EXECUTABLE' not found. Please ensure it is built correctly."
63+
exit 1
64+
else
65+
# If it exists, print a message and run the test executable
66+
echo "Test executable found. Running tests..."
67+
"$TEST_EXECUTABLE"
68+
fi

0 commit comments

Comments
 (0)