Update inspireface to 1.2.0

This commit is contained in:
Jingyu
2025-03-25 00:51:26 +08:00
parent 977ea6795b
commit ca64996b84
388 changed files with 28584 additions and 13036 deletions

View File

@@ -98,6 +98,8 @@ build() {
cmake ${SCRIPT_DIR} \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-g0 ${CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="-g0 ${CMAKE_CXX_FLAGS}" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_ABI=${arch} \
@@ -109,8 +111,7 @@ build() {
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON \
-DOpenCV_DIR=${OPENCV_DIR}
-DISF_BUILD_SHARED_LIBS=ON
make -j4
make install
popd

View File

@@ -0,0 +1,140 @@
#!/bin/bash
reorganize_structure() {
local base_path=$1
# Define the new main directories
local main_dirs=("lib" "sample" "test")
# Check if the base path exists
if [[ ! -d "$base_path" ]]; then
echo "Error: The path '$base_path' does not exist."
return 1
fi
# Create new main directories at the base path
for dir in "${main_dirs[@]}"; do
mkdir -p "$base_path/$dir"
done
# Find all architecture directories (e.g., arm64-v8a, armeabi-v7a)
local arch_dirs=($(find "$base_path" -maxdepth 1 -type d -name "arm*"))
for arch_dir in "${arch_dirs[@]}"; do
# Get the architecture name (e.g., arm64-v8a)
local arch=$(basename "$arch_dir")
# Operate on each main directory
for main_dir in "${main_dirs[@]}"; do
# Create a specific directory for each architecture under the main directory
mkdir -p "$base_path/$main_dir/$arch"
# Selectively copy content based on the directory type
case "$main_dir" in
lib)
# Copy the lib directory
if [ -d "$arch_dir/InspireFace/lib" ]; then
cp -r "$arch_dir/InspireFace/lib/"* "$base_path/$main_dir/$arch/"
fi
;;
sample)
# Copy the sample directory
if [ -d "$arch_dir/InspireFace/sample" ]; then
cp -r "$arch_dir/InspireFace/sample/"* "$base_path/$main_dir/$arch/"
fi
;;
test)
# Copy the test directory
if [ -d "$arch_dir/InspireFace/test" ]; then
cp -r "$arch_dir/InspireFace/test/"* "$base_path/$main_dir/$arch/"
fi
;;
esac
done
# Copy version.txt file to the base path, ignoring duplicates
if [ -f "$arch_dir/version.txt" ]; then
cp -f "$arch_dir/version.txt" "$base_path/version.txt"
fi
done
# Delete the original architecture directories
for arch_dir in "${arch_dirs[@]}"; do
rm -rf "$arch_dir"
done
echo "Reorganization complete."
}
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
build() {
arch=$1
NDK_API_LEVEL=$2
mkdir -p ${BUILD_FOLDER_PATH}/${arch}
pushd ${BUILD_FOLDER_PATH}/${arch}
cmake ${SCRIPT_DIR} \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-g0 ${CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="-g0 ${CMAKE_CXX_FLAGS}" \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_ABI=${arch} \
-DANDROID_NATIVE_API_LEVEL=${NDK_API_LEVEL} \
-DANDROID_STL=c++_static \
-DMNN_BUILD_FOR_ANDROID_COMMAND=true \
-DISF_ENABLE_RKNN=ON \
-DISF_ENABLE_RGA=OFF \
-DISF_RK_DEVICE_TYPE=RK356X \
-DISF_RKNPU_MAJOR=rknpu2 \
-DISF_RK_COMPILER_TYPE=${arch} \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON
make -j4
make install
popd
move_install_files "${BUILD_FOLDER_PATH}/${arch}"
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
SCRIPT_DIR=$(pwd) # Project dir
BUILD_FOLDER_PATH="build/inspireface-android-rk356x-rk3588${TAG}"
build arm64-v8a 24
build armeabi-v7a 24
reorganize_structure "${BUILD_FOLDER_PATH}"

View File

@@ -0,0 +1,74 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
SCRIPT_DIR=$(pwd) # Project dir
cd ${SCRIPT_DIR}
BUILD_FOLDER_PATH="build/inspireface-linux-aarch64-rk356x-rk3588${TAG}"
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
# export ARM_CROSS_COMPILE_TOOLCHAIN=/host/software/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu
cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_VERSION=1 \
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
-DCMAKE_C_COMPILER=$ARM_CROSS_COMPILE_TOOLCHAIN/bin/aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=$ARM_CROSS_COMPILE_TOOLCHAIN/bin/aarch64-linux-gnu-g++ \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -flax-vector-conversions" \
-DTARGET_PLATFORM=armlinux \
-DISF_BUILD_LINUX_AARCH64=ON \
-DISF_BUILD_LINUX_ARM7=OFF \
-DMNN_SEP_BUILD=off \
-DISF_ENABLE_RKNN=ON \
-DISF_RK_DEVICE_TYPE=RK356X \
-DISF_RKNPU_MAJOR=rknpu2 \
-DISF_RK_COMPILER_TYPE=aarch64 \
-DISF_ENABLE_RGA=ON \
-DISF_ENABLE_COST_TIME=OFF \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=OFF ${SCRIPT_DIR}
make -j4
make install
move_install_files "$(pwd)"

View File

@@ -0,0 +1,106 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
SCRIPT_DIR=$(pwd) # Project dir
# Create .rknpu2_cache directory if it doesn't exist
CACHE_DIR="$(pwd)/.rknpu2_cache"
mkdir -p "$CACHE_DIR"
# Check if MNN-2.3.0 directory already exists
if [ ! -d "$CACHE_DIR/MNN-2.3.0" ]; then
echo "Downloading MNN 2.3.0..."
# Download MNN 2.3.0
if ! wget -P "$CACHE_DIR" https://github.com/alibaba/MNN/archive/refs/tags/2.3.0.zip; then
echo "Error: Failed to download MNN 2.3.0"
exit 1
fi
# Extract the zip file
cd "$CACHE_DIR"
if ! unzip 2.3.0.zip; then
echo "Error: Failed to extract MNN 2.3.0"
exit 1
fi
# Remove the zip file
rm 2.3.0.zip
echo "MNN 2.3.0 downloaded and extracted"
else
echo "MNN-2.3.0 already exists in cache"
fi
# Set absolute path to MNN source
export ISF_MNN_CUSTOM_SOURCE="$CACHE_DIR/MNN-2.3.0"
echo "ISF_MNN_CUSTOM_SOURCE: ${ISF_MNN_CUSTOM_SOURCE}"
cd ${SCRIPT_DIR}
# export ARM_CROSS_COMPILE_TOOLCHAIN=/root/arm-rockchip830-linux-uclibcgnueabihf/
BUILD_FOLDER_PATH="build/inspireface-linux-armv7-rv1106-armhf-uclibc${TAG}"
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
# export cross_compile_toolchain=/home/jingyuyan/software/arm-rockchip830-linux-uclibcgnueabihf
cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_VERSION=1 \
-DCMAKE_SYSTEM_PROCESSOR=armv7 \
-DCMAKE_C_COMPILER=$ARM_CROSS_COMPILE_TOOLCHAIN/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc \
-DCMAKE_CXX_COMPILER=$ARM_CROSS_COMPILE_TOOLCHAIN/bin/arm-rockchip830-linux-uclibcgnueabihf-g++ \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -flax-vector-conversions" \
-DTARGET_PLATFORM=armlinux \
-DISF_BUILD_LINUX_ARM7=ON \
-DISF_MNN_CUSTOM_SOURCE=${ISF_MNN_CUSTOM_SOURCE} \
-DMNN_SEP_BUILD=off \
-DISF_ENABLE_RKNN=ON \
-DISF_RK_DEVICE_TYPE=RV1106 \
-DISF_RKNPU_MAJOR=rknpu2 \
-DISF_RK_COMPILER_TYPE=armhf-uclibc \
-DISF_ENABLE_RGA=ON \
-DISF_ENABLE_COST_TIME=OFF \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=OFF ${SCRIPT_DIR}
make -j4
# make install
# move_install_files "$(pwd)"

View File

@@ -25,7 +25,6 @@ move_install_files() {
# Define download URLs
MNN_IOS_URL="https://github.com/alibaba/MNN/releases/download/2.8.1/mnn_2.8.1_ios_armv82_cpu_metal_coreml.zip"
OPENCV_IOS_URL="https://github.com/opencv/opencv/releases/download/4.5.1/opencv-4.5.1-ios-framework.zip"
# Set the cache directory
MACOS_CACHE="$PWD/.macos_cache/"
@@ -74,7 +73,6 @@ download_and_unzip() {
download_and_unzip "$MNN_IOS_URL" "$MACOS_CACHE" "MNN.framework"
# Download and unzip OpenCV iOS package
download_and_unzip "$OPENCV_IOS_URL" "$MACOS_CACHE" "opencv2.framework"
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
@@ -154,3 +152,5 @@ cat <<EOF >$FRAMEWORK_DIR/Resources/Info.plist
EOF
echo "Framework $FRAMEWORK_NAME.framework has been created at $FRAMEWORK_DIR"
cp -r $MACOS_CACHE/MNN.framework $BUILD_DIR/

View File

@@ -43,7 +43,6 @@ cmake -DCMAKE_SYSTEM_NAME=Linux \
-DISF_ENABLE_BENCHMARK=ON \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_ENABLE_TRACKING_BY_DETECTION=ON \
-DMNN_CUDA=ON \
-DISF_GLOBAL_INFERENCE_BACKEND_USE_MNN_CUDA=ON \
-DISF_LINUX_MNN_CUDA=/home/tunm/softwate/MNN-2.7.2/build_cuda ${SCRIPT_DIR}

View File

@@ -45,8 +45,7 @@ cmake -DCMAKE_SYSTEM_NAME=Linux \
-DISF_ENABLE_TEST_EVALUATION=ON \
-DMNN_CUDA=ON \
-DISF_GLOBAL_INFERENCE_BACKEND_USE_MNN_CUDA=ON \
-DISF_LINUX_MNN_CUDA=/host/softwate/MNN-2.7.2/build_cuda \
-DOpenCV_DIR=3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4 ${SCRIPT_DIR}
-DISF_LINUX_MNN_CUDA=/host/softwate/MNN-2.7.2/build_cuda ${SCRIPT_DIR}
make -j4

View File

@@ -0,0 +1,51 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
# Build folder path
BUILD_FOLDER_PATH="build/inspireface-linux-x86-manylinux2014${TAG}/"
SCRIPT_DIR=$(pwd) # Project dir
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}
make -j4
make install
move_install_files "$(pwd)"

View File

@@ -0,0 +1,118 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
get_cuda_ubuntu_tag() {
# If CUDA_TAG is set, use it
if [ -n "${CUDA_TAG}" ]; then
echo "${CUDA_TAG}"
return 0
fi
# Get CUDA version
CUDA_VERSION="_none"
if command -v nvcc &> /dev/null; then
# Try to get version from nvcc
CUDA_VERSION=$(nvcc --version 2>/dev/null | grep "release" | awk '{print $6}' | cut -d',' -f1 | tr -d '.')
if [ -z "${CUDA_VERSION}" ]; then
CUDA_VERSION="_none"
else
CUDA_VERSION="${CUDA_VERSION}"
fi
elif [ -f "/usr/local/cuda/version.txt" ]; then
# Get version from CUDA installation directory
CUDA_VERSION=$(cat /usr/local/cuda/version.txt 2>/dev/null | grep "CUDA Version" | awk '{print $3}' | tr -d '.')
if [ -z "${CUDA_VERSION}" ]; then
CUDA_VERSION="_none"
fi
elif [ -d "/usr/local/cuda" ] && ls -l /usr/local/cuda 2>/dev/null | grep -q "cuda-"; then
# Get version from symbolic link
CUDA_LINK=$(ls -l /usr/local/cuda 2>/dev/null | grep -o "cuda-[0-9.]*" | head -n 1)
CUDA_VERSION=$(echo "${CUDA_LINK}" | cut -d'-' -f2 | tr -d '.')
if [ -z "${CUDA_VERSION}" ]; then
CUDA_VERSION="_none"
fi
fi
# Get Ubuntu version
UBUNTU_VERSION="_none"
if [ -f "/etc/os-release" ]; then
# Check if it is Ubuntu
if grep -q "Ubuntu" /etc/os-release 2>/dev/null; then
UBUNTU_VERSION=$(grep "VERSION_ID" /etc/os-release 2>/dev/null | cut -d'"' -f2)
if [ -z "${UBUNTU_VERSION}" ]; then
UBUNTU_VERSION="_none"
fi
fi
elif [ -f "/etc/lsb-release" ]; then
# Get version from lsb-release
if grep -q "Ubuntu" /etc/lsb-release 2>/dev/null; then
UBUNTU_VERSION=$(grep "DISTRIB_RELEASE" /etc/lsb-release 2>/dev/null | cut -d'=' -f2)
if [ -z "${UBUNTU_VERSION}" ]; then
UBUNTU_VERSION="_none"
fi
fi
fi
# Generate and return tag
echo "cuda${CUDA_VERSION}_ubuntu${UBUNTU_VERSION}"
}
CUDA_TAG=$(get_cuda_ubuntu_tag)
echo "Cuda Tag: ${CUDA_TAG}"
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
SCRIPT_DIR=$(pwd)
BUILD_FOLDER_NAME="inspireface-linux-tensorrt-${CUDA_TAG}${TAG}"
mkdir -p build/${BUILD_FOLDER_NAME}
cd build/${BUILD_FOLDER_NAME}
echo "TENSORRT_ROOT: ${TENSORRT_ROOT}"
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=ON \
-DISF_BUILD_WITH_TEST=ON \
-DISF_ENABLE_BENCHMARK=ON \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DTENSORRT_ROOT=${TENSORRT_ROOT} \
-DISF_ENABLE_TENSORRT=ON ../..
make -j4
make install
if [ $? -eq 0 ] && [ -d "$(pwd)/install" ]; then
move_install_files "$(pwd)"
else
echo "Build failed or the installation directory does not exist"
exit 1
fi

View File

@@ -37,12 +37,11 @@ mkdir -p ${BUILD_FOLDER_PATH}
cd ${BUILD_FOLDER_PATH}
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=ON \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DOpenCV_DIR=3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4 \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}
make -j4

View File

@@ -0,0 +1,50 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
BUILD_FOLDER_PATH="build/inspireface-macos-apple-silicon-arm64${TAG}/"
SCRIPT_DIR=$(pwd) # Project dir
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}
make -j4
make install
move_install_files "$(pwd)"

View File

@@ -0,0 +1,50 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
BUILD_FOLDER_PATH="build/inspireface-macos-intel-x86-64${TAG}/"
SCRIPT_DIR=$(pwd) # Project dir
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}
make -j4
make install
move_install_files "$(pwd)"

View File

@@ -0,0 +1,64 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
BUILD_FOLDER_PATH="build/inspireface-macos-apple-silicon-arm64${TAG}/"
SCRIPT_DIR=$(pwd) # Project dir
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}
make -j4
make install
move_install_files "$(pwd)"
BUILD_DYLIB_PATH="$(pwd)/InspireFace/lib/libInspireFace.dylib"
# Copy the library to the python directory
DYLIB_DEST_PATH="${SCRIPT_DIR}/python/inspireface/modules/core/libs/darwin/arm64/"
mkdir -p ${DYLIB_DEST_PATH}
cp -r ${BUILD_DYLIB_PATH} ${DYLIB_DEST_PATH}
pip3 install setuptools wheel twine
PYTHON_PRJ_PATH=${SCRIPT_DIR}/python
cd ${PYTHON_PRJ_PATH}/
python3 setup.py bdist_wheel
echo "Build wheel for MacOS Arm64, Well Done!"

View File

@@ -0,0 +1,64 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
BUILD_FOLDER_PATH="build/inspireface-macos-intel-x86-64${TAG}/"
SCRIPT_DIR=$(pwd) # Project dir
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}
make -j4
make install
move_install_files "$(pwd)"
BUILD_DYLIB_PATH="$(pwd)/InspireFace/lib/libInspireFace.dylib"
# Copy the library to the python directory
DYLIB_DEST_PATH="${SCRIPT_DIR}/python/inspireface/modules/core/libs/darwin/x64/"
mkdir -p ${DYLIB_DEST_PATH}
cp -r ${BUILD_DYLIB_PATH} ${DYLIB_DEST_PATH}
pip3 install setuptools wheel twine
PYTHON_PRJ_PATH=${SCRIPT_DIR}/python
cd ${PYTHON_PRJ_PATH}/
python3 setup.py bdist_wheel
echo "Build wheel for MacOS x86_64, Well Done!"

View File

@@ -0,0 +1,69 @@
#!/bin/bash
# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"
# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi
# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +
# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null
# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}
if [ -n "$VERSION" ]; then
TAG="-$VERSION"
else
TAG=""
fi
BUILD_FOLDER_PATH="build/inspireface-linux-x86-manylinux2014${TAG}/"
SCRIPT_DIR=$(pwd) # Project dir
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd ${BUILD_FOLDER_PATH}
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}
make -j4
make install
move_install_files "$(pwd)"
BUILD_DYLIB_PATH="$(pwd)/InspireFace/lib/libInspireFace.so"
# Copy the library to the python directory
DYLIB_DEST_PATH="${SCRIPT_DIR}/python/inspireface/modules/core/libs/linux/x64/"
mkdir -p ${DYLIB_DEST_PATH}
cp -r ${BUILD_DYLIB_PATH} ${DYLIB_DEST_PATH}
PYTHON_PRJ_PATH=${SCRIPT_DIR}/python
cd ${PYTHON_PRJ_PATH}/
# Build wheels for Python 3.7-3.12
for PYTHON_VERSION in python3.7 python3.8 python3.9 python3.10 python3.11 python3.12; do
if [[ "${PYTHON_VERSION}" == "python3.12" ]]; then
${PYTHON_VERSION} -m pip install setuptools wheel twine
fi
${PYTHON_VERSION} setup.py bdist_wheel
done
echo "Build wheel for Linux x86_64, Well Done!"

View File

@@ -0,0 +1,97 @@
#!/bin/bash
# Target download folder
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"
URL5="https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RK356X"
URL6="https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Megatron_TRT"
URL7="https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RK3588"
# Color codes
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Create download folder
mkdir -p "$DOWNLOAD_DIR"
# Function to download file
download_file() {
local url=$1
if command -v wget > /dev/null 2>&1; then
echo "Using wget for download..."
wget --no-check-certificate -L -P "$DOWNLOAD_DIR" "$url"
else
echo "wget not found, using curl instead..."
cd "$DOWNLOAD_DIR"
curl -L -O "$url"
cd - > /dev/null
fi
}
# Function to print file path
print_file_path() {
local filename=$1
echo -e "File downloaded to: ${YELLOW}$(cd "$DOWNLOAD_DIR" && pwd)/${filename}${NC}"
}
# Check if argument is provided
if [ $# -eq 0 ]; then
echo "No argument provided, downloading all files..."
download_file "$URL1"
download_file "$URL2"
download_file "$URL3"
download_file "$URL4"
download_file "$URL5"
download_file "$URL6"
download_file "$URL7"
# Check all files
if [ -f "$DOWNLOAD_DIR/Megatron" ] && [ -f "$DOWNLOAD_DIR/Pikachu" ] && \
[ -f "$DOWNLOAD_DIR/Gundam_RV1109" ] && [ -f "$DOWNLOAD_DIR/Gundam_RV1106" ] && \
[ -f "$DOWNLOAD_DIR/Gundam_RK356X" ] && [ -f "$DOWNLOAD_DIR/Megatron_TRT" ] && \
[ -f "$DOWNLOAD_DIR/Gundam_RK3588" ]; then
echo "All downloads completed successfully!"
print_file_path "Megatron"
print_file_path "Pikachu"
print_file_path "Gundam_RV1109"
print_file_path "Gundam_RV1106"
print_file_path "Gundam_RK356X"
print_file_path "Megatron_TRT"
print_file_path "Gundam_RK3588"
else
echo "Download failed!"
exit 1
fi
else
case "$1" in
"Megatron"|"Pikachu"|"Gundam_RV1109"|"Gundam_RV1106"|"Gundam_RK356X"|"Megatron_TRT"|"Gundam_RK3588")
echo "Downloading $1..."
case "$1" in
"Megatron") url="$URL1" ;;
"Pikachu") url="$URL2" ;;
"Gundam_RV1109") url="$URL3" ;;
"Gundam_RV1106") url="$URL4" ;;
"Gundam_RK356X") url="$URL5" ;;
"Megatron_TRT") url="$URL6" ;;
"Gundam_RK3588") url="$URL7" ;;
esac
download_file "$url"
# Check file
if [ -f "$DOWNLOAD_DIR/$1" ]; then
echo "$1 download completed successfully!"
print_file_path "$1"
else
echo "$1 download failed!"
exit 1
fi
;;
*)
echo "Invalid argument. Please use 'Megatron', 'Pikachu', 'Gundam_RV1109', 'Gundam_RV1106', 'Gundam_RK356X', 'Megatron_TRT' or 'Gundam_RK3588'"
exit 1
;;
esac
fi

View File

@@ -0,0 +1,66 @@
#!/bin/bash
# 函数获取CUDA和Ubuntu版本标签
# 如果CUDA_TAG环境变量已设置则使用该值
# 否则自动检测CUDA和Ubuntu版本并生成标签
# 格式: cudaXX_ubuntuXX.XX
# 如果检测不到某个版本,则用"none"代替
get_cuda_ubuntu_tag() {
# 如果CUDA_TAG已设置则直接返回
if [ -n "${CUDA_TAG}" ]; then
echo "${CUDA_TAG}"
return 0
fi
# 获取CUDA版本
CUDA_VERSION="_none"
if command -v nvcc &> /dev/null; then
# 尝试从nvcc获取版本
CUDA_VERSION=$(nvcc --version 2>/dev/null | grep "release" | awk '{print $6}' | cut -d',' -f1 | tr -d '.')
if [ -z "${CUDA_VERSION}" ]; then
CUDA_VERSION="_none"
else
CUDA_VERSION="${CUDA_VERSION}"
fi
elif [ -f "/usr/local/cuda/version.txt" ]; then
# 尝试从CUDA安装目录获取版本
CUDA_VERSION=$(cat /usr/local/cuda/version.txt 2>/dev/null | grep "CUDA Version" | awk '{print $3}' | tr -d '.')
if [ -z "${CUDA_VERSION}" ]; then
CUDA_VERSION="_none"
fi
elif [ -d "/usr/local/cuda" ] && ls -l /usr/local/cuda 2>/dev/null | grep -q "cuda-"; then
# 尝试从符号链接获取版本
CUDA_LINK=$(ls -l /usr/local/cuda 2>/dev/null | grep -o "cuda-[0-9.]*" | head -n 1)
CUDA_VERSION=$(echo "${CUDA_LINK}" | cut -d'-' -f2 | tr -d '.')
if [ -z "${CUDA_VERSION}" ]; then
CUDA_VERSION="_none"
fi
fi
# 获取Ubuntu版本
UBUNTU_VERSION="_none"
if [ -f "/etc/os-release" ]; then
# 检查是否是Ubuntu
if grep -q "Ubuntu" /etc/os-release 2>/dev/null; then
UBUNTU_VERSION=$(grep "VERSION_ID" /etc/os-release 2>/dev/null | cut -d'"' -f2)
if [ -z "${UBUNTU_VERSION}" ]; then
UBUNTU_VERSION="_none"
fi
fi
elif [ -f "/etc/lsb-release" ]; then
# 尝试从lsb-release获取版本
if grep -q "Ubuntu" /etc/lsb-release 2>/dev/null; then
UBUNTU_VERSION=$(grep "DISTRIB_RELEASE" /etc/lsb-release 2>/dev/null | cut -d'=' -f2)
if [ -z "${UBUNTU_VERSION}" ]; then
UBUNTU_VERSION="_none"
fi
fi
fi
# 生成并返回标签
echo "cuda${CUDA_VERSION}_ubuntu${UBUNTU_VERSION}"
}
# 使用示例
CUDA_TAG=$(get_cuda_ubuntu_tag)
echo "Generated tag: ${CUDA_TAG}"