Skip to content

Commit 37d816b

Browse files
committed
use environment variable to set the insightface dylib
1 parent d5550fd commit 37d816b

7 files changed

Lines changed: 159 additions & 203 deletions

File tree

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[build]
22
rustflags = ["-C", "link-arg=-Wl,-rpath,@executable_path/../lib"]
3+
4+
[env]
5+
INSIGHTFACE_PATH = "/Users/marcintha/workspace/baklava/insightface/cpp-package/inspireface/build/inspireface-macos/InspireFace"

.github/workflows/ci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: [push]
44

55
env:
66
CXXFLAGS: "-std=c++17"
7+
INSIGHTFACE_PATH: "${{ github.workspace }}/insightface/cpp-package/inspireface/build/inspireface-macos/InspireFace"
78

89
jobs:
910
clippy:
@@ -13,6 +14,8 @@ jobs:
1314
with:
1415
submodules: recursive
1516
# buuld the inspire-face sdk for the target env
17+
- name: print
18+
run: echo $INSIGHTFACE_PATH
1619
- name: build the cpp project
1720
working-directory: insightface/cpp-package/inspireface
1821
run: bash command/build.sh

Cargo.lock

Lines changed: 1 addition & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ version = "0.1.0"
55
edition = "2021"
66
authors = ["Marc Intha-amnouay <marc.inthaamnouay@gmail.com>"]
77
keywords = ["insightface", "face-comparison", "inspireface"]
8+
exclude = ["face1_test.png", "face2_test.png", "insightface"]
89

910
[dependencies]
1011
cxx = "1.0"
1112
autocxx = "0.30.0"
1213

1314
[build-dependencies]
1415
autocxx-build = "0.30.0"
15-
miette = { version = "5", features = ["fancy"] }
1616

1717
[dev-dependencies]
1818
reqwest = { version = "0.12.23", features = ["blocking"] }

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@
22

33
A small project that wrap the [InsightFace SDK](https://github.com/deepinsight/insightface) in order to perform face comparison. It uses a fork of InsightFace in order to implement some convenient method to be exposed for Rust that can be found [here](https://github.com/shigedangao/insightface). The implementation is based on the sample provided by the insightface team. [c example link](https://github.com/deepinsight/insightface/blob/master/cpp-package/inspireface/cpp/sample/api/sample_face_comparison.c)
44

5-
## Usage
5+
## Usage from crates.io
66

7-
To use the library you'll need to specify the model that will be used. These models are the same that are used by the InsightFace library. The models can be found [here](https://github.com/HyperInspire/InspireFace?tab=readme-ov-file#resource-package-list)
7+
> [!IMPORTANT]
8+
> This guide required you to download the `insightface` library and to follow the instructions in orders.
9+
10+
1. To use the library you'll need to specify the model that will be used. These models are the same that are used by the InsightFace library. The models can be found [here](https://github.com/HyperInspire/InspireFace?tab=readme-ov-file#resource-package-list)
11+
12+
2. Clone the insightface's fork repository using this [link](https://github.com/shigedangao/insightface) and build the `insightface` library with the command
13+
14+
```sh
15+
cd insightface/cpp-package/inspireface && git clone --recurse-submodules https://github.com/tunmx/inspireface-3rdparty.git 3rdparty
16+
cd insightface/cpp-package/inspireface && bash command/build.sh
17+
```
18+
19+
3. Specify the path to the `insightface` library in your `Cargo.toml` by adding this into your `.cargo/config.toml`:
20+
21+
```toml
22+
[env]
23+
INSIGHTFACE_PATH = "<path to>/insightface/cpp-package/inspireface/build/inspireface-<arch>/InspireFace"
24+
```
825

926
Thereafter the library can be add as follows in your `Cargo.toml`:
1027

@@ -52,12 +69,20 @@ git submodule update --init --recursive
5269
cd insightface/cpp-package/inspireface && git clone --recurse-submodules https://github.com/tunmx/inspireface-3rdparty.git 3rdparty
5370
```
5471

55-
3. Build the project
72+
3. Replace the `build.rs` by the `build_local.rs`. This `build_local.rs` will build the project locally and copy the resulting `dylib` into the target directory.
73+
74+
4. Build the project
5675

5776
```sh
5877
cargo build
5978
```
6079

80+
5. Make sure that everything works fine by running the unit tests with
81+
82+
```sh
83+
cargo test
84+
```
85+
6186
## Recompile insightface
6287

6388
If you wish to recompile the InsightFace - `rm -rf ./insightface/cpp-package/inspireface/build`

0 commit comments

Comments
 (0)