Skip to content

Commit

Permalink
Added support for RV1106
Browse files Browse the repository at this point in the history
  • Loading branch information
tunmx committed Dec 23, 2024
1 parent 0722a9d commit b9c4977
Show file tree
Hide file tree
Showing 23 changed files with 518 additions and 206 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build_sdks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,41 @@ jobs:
- name: Execute Docker Compose
run: |
docker-compose up build-manylinux2014-x86
ls build
build_armv7_rv1106_armhf_uclibc:
name: Compile Linux-armv7 rv1106
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Step 2: Synchronize and update submodules recursively
- name: Update submodules
run: |
git clone --recurse-submodules https://github.com/tunmx/inspireface-3rdparty.git 3rdparty
# Step 3: Install wget and xz-utils
- name: Install wget and xz-utils
run: |
sudo apt-get update
sudo apt-get install -y wget xz-utils
# Step 4: Download Toolchain
- name: Download and Extract Linaro Toolchain
run: |
git clone https://github.com/tunmx/arm-rockchip830-linux-uclibcgnueabihf.git
# Step 5: Install Toolchain
- name: Set environment variables
run: |
echo "ARM_CROSS_COMPILE_TOOLCHAIN=${{ github.workspace }}/arm-rockchip830-linux-uclibcgnueabihf" >> $GITHUB_ENV
echo "PATH=${{ github.workspace }}/arm-rockchip830-linux-uclibcgnueabihf/bin:${PATH}" >> $GITHUB_ENV
# Step 6: Start building the SDK
- name: Start Building the InspireFace-Linux-armv7-rv1106
run: |
bash command/build_cross_rv1106_armhf_uclibc.sh
ls build
54 changes: 51 additions & 3 deletions .github/workflows/release-sdks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,57 @@ jobs:
zip -r inspireface-linux-x86-manylinux2014-${{ env.VERSION }}.zip build/inspireface-linux-x86-manylinux2014-${{ env.VERSION }}
stat inspireface-linux-x86-manylinux2014-${{ env.VERSION }}.zip
build_armv7_rv1106_armhf_uclibc:
name: Compile Linux-armv7 rv1106
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Step 2: Extract the version number from the tag (e.g., "v1.2.3" becomes "1.2.3")
- name: Extract Version Number
id: extract_version
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" >> $GITHUB_ENV

# Step 3: Synchronize and update submodules recursively
- name: Update submodules
run: |
git clone --recurse-submodules https://github.com/tunmx/inspireface-3rdparty.git 3rdparty
# Step 4: Install wget and xz-utils
- name: Install wget and xz-utils
run: |
sudo apt-get update
sudo apt-get install -y wget xz-utils
# Step 5: Download Toolchain
- name: Download and Extract Linaro Toolchain
run: |
git clone https://github.com/tunmx/arm-rockchip830-linux-uclibcgnueabihf.git
# Step 6: Install Toolchain
- name: Set environment variables
run: |
echo "ARM_CROSS_COMPILE_TOOLCHAIN=${{ github.workspace }}/arm-rockchip830-linux-uclibcgnueabihf" >> $GITHUB_ENV
echo "PATH=${{ github.workspace }}/arm-rockchip830-linux-uclibcgnueabihf/bin:${PATH}" >> $GITHUB_ENV
# Step 7: Start building the SDK
- name: Start Building the InspireFace-Linux-armv7-rv1106
run: |
bash command/build_cross_rv1106_armhf_uclibc.sh
ls build
# Step 8: Zip SDK directory
- name: Zip SDK directory
run: |
zip -r inspireface-linux-armv7-rv1106-armhf-uclibc-${{ env.VERSION }}.zip build/inspireface-linux-armv7-rv1106-armhf-uclibc-${{ env.VERSION }}
stat inspireface-linux-armv7-rv1106-armhf-uclibc-${{ env.VERSION }}.zip
release:
name: Release SDKs to GitHub
needs: [ build_linux_x86, build_armv7_armhf, build_armv7_rv1109rv1126_armhf, build_linux_aarch64, build_android, build_ios, build_manylinux2014_x86]
needs: [ build_linux_x86, build_armv7_armhf, build_armv7_rv1109rv1126_armhf, build_linux_aarch64, build_android, build_ios, build_manylinux2014_x86, build_armv7_rv1106_armhf_uclibc]
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -407,10 +454,11 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
sdk_artifacts/sdk_files_manylinux2014_x86/inspireface-linux-x86-manylinux2014-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_linux_x86/inspireface-linux-x86-ubuntu18-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_armv7_armhf/inspireface-linux-armv7-armhf-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_armv7_rv1109rv1126_armhf/inspireface-linux-armv7-rv1109rv1126-armhf-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_armv7_rv1106_armhf_uclibc/inspireface-linux-armv7-rv1106-armhf-uclibc-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_linux_aarch64/inspireface-linux-aarch64-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_android/inspireface-android-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_ios/inspireface-ios-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_manylinux2014_x86/inspireface-linux-x86-manylinux2014-${{ env.VERSION }}.zip
sdk_artifacts/sdk_files_ios/inspireface-ios-${{ env.VERSION }}.zip
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ After installation, you can use inspireface like this:
import cv2
import inspireface as isf

# Global launching and automatic downloading of resource files
ret = isf.launch()
assert ret, "Launch failure. Please ensure the resource path is correct."

# Create a session with optional features
opt = isf.HF_ENABLE_NONE
session = isf.InspireFaceSession(opt, isf.HF_DETECT_MODE_IMAGE)
Expand Down Expand Up @@ -128,10 +124,17 @@ You can download the model package files containing models and configurations ne
You can use the **command/download_models_general.sh** command to download resource files, which will be downloaded to the **test_res/pack** directory. This way, when running the Test program, it can access and read the resource files from this path by default.

```bash
# Download lightweight resource files
# Download lightweight resource files for mobile device
bash command/download_models_general.sh Pikachu
# Download resource files for PC/server
# Download resource files for mobile device or PC/server
bash command/download_models_general.sh Megatron
# Download resource files for RV1109
bash command/download_models_general.sh Gundam_RV1109
# Download resource files for RV1106
bash command/download_models_general.sh Gundam_RV1106

# Download all model files
bash command/download_models_general.sh
```

### Installing OpenCV(Optional)
Expand Down Expand Up @@ -186,14 +189,14 @@ inspireface-linux
- **inspireface.h**:Header file definition.
- **herror.h**:Reference error number definition.
### Cross Compilation
Cross compilation requires you to prepare the target platform's cross-compilation toolchain on the host machine in advance. Here, compiling for Rockchip's embedded devices RV1109/RV1126 is used as an example:
Cross compilation requires you to prepare the target platform's cross-compilation toolchain on the host machine in advance. Here, compiling for Rockchip's embedded devices RV1106 is used as an example:
```bash
# Set the path for the cross-compilation toolchain
export ARM_CROSS_COMPILE_TOOLCHAIN=YOUR_DIR/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
# Execute the cross-compilation script for RV1109/RV1126
bash command/build_cross_rv1109rv1126_armhf.sh
export ARM_CROSS_COMPILE_TOOLCHAIN=YOUR_DIR/arm-rockchip830-linux-uclibcgnueabihf
# Execute the cross-compilation script for RV1106
bash command/build_cross_rv1106_armhf_uclibc.sh
```
After the compilation is complete, you can find the compiled results in the `build/inspireface-linux-armv7-rv1109rv1126-armhf` directory.
After the compilation is complete, you can find the compiled results in the `build/inspireface-linux-armv7-rv1106-armhf-uclibc` directory.

### iOS Compilation

Expand Down Expand Up @@ -225,7 +228,7 @@ We have completed the adaptation and testing of the software across various oper
| 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) |
| 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) |
| 4 | **Linux-Rockchip** | 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) |
| 5 | | ARMv7 | RV1106 | ![build](https://img.shields.io/badge/build-developing-yellow?style=for-the-badge) ||
| 5 | | ARMv7 | RV1106 | [![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)|
| 6 | | ARMv8 | RK3566/RK3568 | ![build](https://img.shields.io/badge/build-developing-yellow?style=for-the-badge) | |
| 7 | | ARMv8 | RK3588 | ![build](https://img.shields.io/badge/build-developing-yellow?style=for-the-badge) | |
| 8 | **Linux-CUDA** | x86/x86_64 | NVIDIA-GPU | ![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) |
Expand All @@ -252,6 +255,9 @@ docker-compose up build-cross-armv7-armhf
# Build armv7 with support RV1109RV1126 device NPU cross-complie
docker-compose up build-cross-rv1109rv1126-armhf

# Build armv7 with support RV1106 device NPU cross-complie
docker-compose up build-cross-rv1106-armhf-uclibc

# Build Android with support arm64-v8a and armeabi-v7a
docker-compose up build-cross-android

Expand Down Expand Up @@ -374,8 +380,8 @@ Import inspireface for a quick facial detection example:
import cv2
import inspireface as isf

# Step 1: Initialize the SDK and downloading resource files.
ret = isf.launch()
# Step 1: Initialize the SDK globally (only needs to be called once per application)
ret = isf.reload()
assert ret, "Launch failure. Please ensure the resource path is correct."

# Optional features, loaded during session creation based on the modules specified.
Expand Down Expand Up @@ -524,13 +530,16 @@ For different scenarios, we currently provide several Packs, each containing mul
| Pikachu | CPU | Lightweight edge-side models | [Download](https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Pikachu) |
| Megatron | CPU, GPU | Mobile and server models | [Download](https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Megatron) |
| Gundam-RV1109 | RKNPU | Supports RK1109 and RK1126 | [Download](https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RV1109) |
| Gundam-RV1106 | RKNPU | Supports RK1106(RV1103 may be supported, but not verified) | [Download](https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RV1106) |

## Acknowledgement

InspireFace is built on the following libraries:

- [MNN](https://github.com/alibaba/MNN)
- [RKNN](https://github.com/rockchip-linux/rknn-toolkit)
- [RKNN2](https://github.com/airockchip/rknn-toolkit2.git)
- [librga](https://github.com/airockchip/librga.git)
- [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page)
- [sqlite](https://www.sqlite.org/index.html)
- [sqlite-vec](https://github.com/asg017/sqlite-vec)
Expand Down
4 changes: 2 additions & 2 deletions command/build_cross_rv1106_armhf_uclibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ cmake -DCMAKE_SYSTEM_NAME=Linux \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}

make -j4
# make install
make install

# move_install_files "$(pwd)"
move_install_files "$(pwd)"
47 changes: 24 additions & 23 deletions command/download_models_general.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ DOWNLOAD_DIR="test_res/pack"
# File URLs
URL1="https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Megatron"
URL2="https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Pikachu"
URL3="https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RV1109"
URL4="https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RV1106"

# Color codes
YELLOW='\033[1;33m'
Expand Down Expand Up @@ -39,43 +41,42 @@ if [ $# -eq 0 ]; then
echo "No argument provided, downloading all files..."
download_file "$URL1"
download_file "$URL2"
# Check both files
if [ -f "$DOWNLOAD_DIR/Megatron" ] && [ -f "$DOWNLOAD_DIR/Pikachu" ]; then
download_file "$URL3"
download_file "$URL4"
# Check all files
if [ -f "$DOWNLOAD_DIR/Megatron" ] && [ -f "$DOWNLOAD_DIR/Pikachu" ] && \
[ -f "$DOWNLOAD_DIR/Gundam_RV1109" ] && [ -f "$DOWNLOAD_DIR/Gundam_RV1106" ]; then
echo "All downloads completed successfully!"
print_file_path "Megatron"
print_file_path "Pikachu"
print_file_path "Gundam_RV1109"
print_file_path "Gundam_RV1106"
else
echo "Download failed!"
exit 1
fi
else
case "$1" in
"Megatron")
echo "Downloading Megatron..."
download_file "$URL1"
# Check Megatron file
if [ -f "$DOWNLOAD_DIR/Megatron" ]; then
echo "Megatron download completed successfully!"
print_file_path "Megatron"
"Megatron"|"Pikachu"|"Gundam_RV1109"|"Gundam_RV1106")
echo "Downloading $1..."
case "$1" in
"Megatron") url="$URL1" ;;
"Pikachu") url="$URL2" ;;
"Gundam_RV1109") url="$URL3" ;;
"Gundam_RV1106") url="$URL4" ;;
esac
download_file "$url"
# Check file
if [ -f "$DOWNLOAD_DIR/$1" ]; then
echo "$1 download completed successfully!"
print_file_path "$1"
else
echo "Megatron download failed!"
exit 1
fi
;;
"Pikachu")
echo "Downloading Pikachu..."
download_file "$URL2"
# Check Pikachu file
if [ -f "$DOWNLOAD_DIR/Pikachu" ]; then
echo "Pikachu download completed successfully!"
print_file_path "Pikachu"
else
echo "Pikachu download failed!"
echo "$1 download failed!"
exit 1
fi
;;
*)
echo "Invalid argument. Please use 'Megatron' or 'Pikachu'"
echo "Invalid argument. Please use 'Megatron', 'Pikachu', 'Gundam_RV1109' or 'Gundam_RV1106'"
exit 1
;;
esac
Expand Down
10 changes: 10 additions & 0 deletions cpp/inspireface/c_api/inspireface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,21 @@ HResult HFLaunchInspireFace(HPath resourcePath) {
return INSPIRE_LAUNCH->Load(resourcePath);
}

HResult HFReloadInspireFace(HPath resourcePath) {
std::string path(resourcePath);
return INSPIRE_LAUNCH->Reload(resourcePath);
}

HResult HFTerminateInspireFace() {
INSPIRE_LAUNCH->Unload();
return HSUCCEED;
}

HResult HFQueryInspireFaceLaunchStatus(HInt32 *status) {
*status = INSPIRE_LAUNCH->isMLoad();
return HSUCCEED;
}

HResult HFFeatureHubDataDisable() {
return FEATURE_HUB_DB->DisableHub();
}
Expand Down
16 changes: 16 additions & 0 deletions cpp/inspireface/c_api/inspireface.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ HYPER_CAPI_EXPORT extern HResult HFImageBitmapShow(HFImageBitmap handle, HString
* */
HYPER_CAPI_EXPORT extern HResult HFLaunchInspireFace(HPath resourcePath);

/**
* @brief Reload InspireFace SDK
* Reload the InspireFace SDK, releasing all allocated resources.
* @param resourcePath Initializes the path to the resource file that needs to be loaded
* @return HResult indicating the success or failure of the operation.
* */
HYPER_CAPI_EXPORT extern HResult HFReloadInspireFace(HPath resourcePath);

/**
* @brief Terminate InspireFace SDK
* Terminate the InspireFace SDK, releasing all allocated resources.
Expand All @@ -221,6 +229,14 @@ HYPER_CAPI_EXPORT extern HResult HFLaunchInspireFace(HPath resourcePath);
* */
HYPER_CAPI_EXPORT extern HResult HFTerminateInspireFace();

/**
* @brief Query InspireFace SDK launch status
* Query the launch status of the InspireFace SDK.
* @param status Pointer to the status variable that will be returned.
* @return HResult indicating the success or failure of the operation.
* */
HYPER_CAPI_EXPORT extern HResult HFQueryInspireFaceLaunchStatus(HInt32 *status);

/************************************************************************
* FaceSession
************************************************************************/
Expand Down
Loading

0 comments on commit b9c4977

Please sign in to comment.