Skip to content

Commit

Permalink
Merge branch 'release/v0.9.0' into 'main'
Browse files Browse the repository at this point in the history
Release: v0.9.0

See merge request sertiscorp/mle/edge/oneml-bootcamp!39
  • Loading branch information
Riccardo Gallina committed Sep 6, 2022
2 parents 59f78b8 + 4ef3700 commit d023f8b
Show file tree
Hide file tree
Showing 44 changed files with 416 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.0] - 2022-09-06
### Added
- FacePad apps and EKYC app for C++ -> [dd6fbf68](https://gitlab.com/sertiscorp/mle/edge/oneml-bootcamp/-/commit/dd6fbf686a6caf57316c5742f86c212bfbb3a778)

## [0.8.0] - 2022-07-12
### Added
- support for C#/.NET -> [05bda49c](https://gitlab.com/sertiscorp/mle/edge/oneml-bootcamp/-/commit/05bda49c69d4df098bc69aa035a3bf6d1d0a9fb1)
Expand Down
8 changes: 8 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ target_link_libraries(vehicle_detector PRIVATE oneml)
# face_verification executable
add_executable(face_verification ${CMAKE_CURRENT_SOURCE_DIR}/cpp/face_verification.cc)
target_link_libraries(face_verification PRIVATE oneml)

# ekyc executable
add_executable(ekyc ${CMAKE_CURRENT_SOURCE_DIR}/cpp/ekyc.cc)
target_link_libraries(ekyc PRIVATE oneml)

# face_pad executable
add_executable(face_pad ${CMAKE_CURRENT_SOURCE_DIR}/cpp/face_pad.cc)
target_link_libraries(face_pad PRIVATE oneml)
2 changes: 1 addition & 1 deletion apps/android-camera/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
minSdkVersion 23
targetSdkVersion 30
versionCode 8
versionName "v0.8.0"
versionName "v0.9.0"

ndk {
abiFilters targetAbi
Expand Down
2 changes: 1 addition & 1 deletion apps/android-simple/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
minSdkVersion 23
targetSdkVersion 30
versionCode 8
versionName "v0.8.0"
versionName "v0.9.0"
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
61 changes: 61 additions & 0 deletions apps/cpp/ekyc.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <iomanip>
#include <numeric>

#include "apps_config.h"
#include "oneml/public/oneml.h"

int main(int argc, char** argv) {
#ifdef _WIN32
_putenv_s("ONEML_CPP_MIN_LOG_LEVEL", "ERROR");
#else
setenv("ONEML_CPP_MIN_LOG_LEVEL", "ERROR", 1);
#endif

oneML::LicenseManager license_manager;
license_manager.activate_trial();

oneML::Utils utils(license_manager);
oneML::face::EKYC ekyc(license_manager);

// Images
oneML::Image img1;
oneML::Image img2;
const std::string path1(ASSETS_DIR_PATH "/face-detect-set/face/8.jpg");
const std::string path2(ASSETS_DIR_PATH "/face-detect-set/face/9.jpg");
utils.read_image_cv(path1, img1);
utils.read_image_cv(path2, img2);

// RUN
oneML::face::EKYCResult output;
oneML::face::EKYCOps ops{true, true};
ekyc.run(img1, img2, ops, ops, output);

oneML::face::Pose pose1;
oneML::face::Pose pose2;
oneML::face::BBox bbox1;
oneML::face::BBox bbox2;
oneML::face::FaceLandmark5 landmarks1;
oneML::face::FaceLandmark5 landmarks2;

auto status = output.get_return_status();
std::cout << "Status: " << status << std::endl;
std::cout << "Same: " << output.is_same_person() << std::endl;
std::cout << "Distance: " << output.get_distance() << std::endl;

output.get_bboxes(bbox1, bbox2);
output.get_landmarks(landmarks1, landmarks2);
output.get_face_poses(pose1, pose2);

std::cout << "Face 1" << std::endl;
std::cout << "BBox: " << bbox1 << std::endl;
std::cout << "Pose: " << pose1 << std::endl;
std::cout << "Landmarks: " << landmarks1 << std::endl;

std::cout << "Face 2" << std::endl;
std::cout << "BBox: " << bbox2 << std::endl;
std::cout << "Pose: " << pose2 << std::endl;
std::cout << "Landmarks: " << landmarks2 << std::endl;

oneML::UsageReport report = ekyc.get_usage();
report.to_log();
}
3 changes: 3 additions & 0 deletions apps/cpp/face_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ int main(int argc, char** argv) {
<< ")" << std::endl;
}
}

oneML::UsageReport report = detector.get_usage();
report.to_log();
}
3 changes: 3 additions & 0 deletions apps/cpp/face_embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ int main(int argc, char** argv) {
<< std::endl;
std::cout << "Embedding sum: " << std::fixed << std::setprecision(5)
<< std::accumulate(emb.begin(), emb.end(), decltype(emb)::value_type(0)) << std::endl;

oneML::UsageReport report = embedder.get_usage();
report.to_log();
}
3 changes: 3 additions & 0 deletions apps/cpp/face_id.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ int main(int argc, char** argv) {
std::vector<std::string> ids;
face_id.get_ids(ids);
std::cout << "Gallery size: " << ids.size() << std::endl;

oneML::UsageReport report = face_id.get_usage();
report.to_log();
}
52 changes: 52 additions & 0 deletions apps/cpp/face_pad.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <iomanip>

#include "apps_config.h"
#include "oneml/public/oneml.h"

int main(int argc, char** argv) {
#ifdef _WIN32
_putenv_s("ONEML_CPP_MIN_LOG_LEVEL", "ERROR");
#else
setenv("ONEML_CPP_MIN_LOG_LEVEL", "ERROR", 1);
#endif

oneML::LicenseManager license_manager;
license_manager.activate_trial();

oneML::Utils utils(license_manager);
oneML::face::FacePad pad_rgb(oneML::face::PadType::Rgb, license_manager);
oneML::face::FacePad pad_paper(oneML::face::PadType::Paper, license_manager);

// PAD RGB
// image
oneML::Image img;
std::string path(ASSETS_DIR_PATH "/pad-rgb-set/spoof/1.jpg");
utils.read_image_cv(path, img);

// RUN
oneML::face::FacePadResult output;
pad_rgb.classify(img, output);

std::cout << "status: " << output.get_return_status() << std::endl;
std::cout << "Spoof probability: " << std::fixed << std::setprecision(6)
<< output.get_spoof_prob() << std::endl;
std::cout << "Spoof classification: " << output.is_spoof() << std::endl;

oneML::UsageReport report = pad_rgb.get_usage();
report.to_log();

// PAD PAPER
path = ASSETS_DIR_PATH "/pad-paper-set/spoof/1.jpg";
utils.read_image_cv(path, img);

// RUN
pad_paper.classify(img, output);

std::cout << "status: " << output.get_return_status() << std::endl;
std::cout << "Spoof probability: " << std::fixed << std::setprecision(6)
<< output.get_spoof_prob() << std::endl;
std::cout << "Spoof classification: " << output.is_spoof() << std::endl;

report = pad_paper.get_usage();
report.to_log();
}
6 changes: 6 additions & 0 deletions apps/cpp/face_verification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,10 @@ int main(int argc, char** argv) {

std::pair<oneML::ReturnStatus, bool> is_same2 = face_id.is_the_same_person(img3, img4);
std::cout << "Is the same person (george_robertson): " << is_same2.second << std::endl;

oneML::UsageReport report = detector.get_usage();
report.to_log();

report = face_id.get_usage();
report.to_log();
}
3 changes: 3 additions & 0 deletions apps/cpp/vehicle_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ int main() {
std::cout << bboxes[i] << std::endl;
}
}

oneML::UsageReport report = detector.get_usage();
report.to_log();
}
3 changes: 3 additions & 0 deletions apps/csharp/FaceDetectorApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ static void Main(string[] args) {
Console.WriteLine("Landmark " + j + ": (" + landmark.x[j].ToString(precision) + ", " + landmark.y[j].ToString(precision) + ")");
}
}

UsageReport report = detector.GetUsage();
report.ToLog();
}
}
3 changes: 3 additions & 0 deletions apps/csharp/FaceEmbedderApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ static void Main(string[] args) {
FaceEmbedderResult result2 = embedder.Embed(img, true);
Console.WriteLine("Flipped Image Embedding");
PrintEmbedding(result2);

UsageReport report = embedder.GetUsage();
report.ToLog();
}
}
3 changes: 3 additions & 0 deletions apps/csharp/FaceIdApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,8 @@ static void Main(string[] args) {
// getIds
IdList idList = faceId.GetIds();
Console.WriteLine("Gallery size: " + idList.Count());

UsageReport report = faceId.GetUsage();
report.ToLog();
}
}
38 changes: 38 additions & 0 deletions apps/csharp/FacePadApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using OneML.Face;

class FacePadApp {
static void Main(string[] args) {
LicenseManager manager = new LicenseManager();
manager.ActivateTrial();

FacePad pad_rgb = new FacePad(PadType.Rgb, manager);
FacePad pad_paper = new FacePad(PadType.Paper, manager);
Utils utils = new Utils(manager);

// PAD RGB
string basePath = @"../../../assets/images/";
string path = basePath + @"pad-rgb-set/spoof/1.jpg";
Image image = utils.ReadImageCV(path);
FacePadResult result = pad_rgb.Classify(image);

string precision = "F6";
Console.WriteLine("Status: " + result.GetReturnStatus());
Console.WriteLine("Spoof probability: " + result.GetSpoofProb().ToString(precision));
Console.WriteLine("Spoof classification: " + result.IsSpoof());

UsageReport report = pad_rgb.GetUsage();
report.ToLog();

// PAD PAPER
path = basePath + @"pad-paper-set/spoof/1.jpg";
image = utils.ReadImageCV(path);
result = pad_paper.Classify(image);

Console.WriteLine("Status: " + result.GetReturnStatus());
Console.WriteLine("Spoof probability: " + result.GetSpoofProb().ToString(precision));
Console.WriteLine("Spoof classification: " + result.IsSpoof());

report = pad_paper.GetUsage();
report.ToLog();
}
}
6 changes: 6 additions & 0 deletions apps/csharp/FaceVerificationApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,11 @@ static void Main(string[] args) {

bool same2 = faceId.IsTheSamePerson(img3, img4);
Console.WriteLine("Is the same person (george_robertson): " + BooleanToInt(same2));

UsageReport report = detector.GetUsage();
report.ToLog();

report = faceId.GetUsage();
report.ToLog();
}
}
11 changes: 11 additions & 0 deletions apps/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ For example,
export LD_LIBRARY_PATH="/workspace/oneml-bootcamp/assets/binaries/x86_64/lib:$LD_LIBRARY_PATH"
```

Same for the folder containing the C# wrapper library:
```
export LD_LIBRARY_PATH="/path/to/oneml-bootcamp/assets/binaries/<target_arch>/bindings/csharp/<module>/build:$LD_LIBRARY_PATH"
```
For example,
```
export LD_LIBRARY_PATH="/workspace/oneml-bootcamp/assets/binaries/x86_64/bindings/csharp/face/build:$LD_LIBRARY_PATH"
```

Run the app:
```
dotnet new console -o MyApp
cd MyApp
cp ../<app_name>.cs Program.cs
cp /path/to/oneml-bootcamp/assets/binaries/<target_arch>/bindings/csharp/<module>/oneml/*.cs .
dotnet run
```

Expand All @@ -24,6 +34,7 @@ Or:
dotnet new console -o MyApp
cd MyApp
cp ../<app_name>.cs Program.cs
cp /path/to/oneml-bootcamp/assets/binaries/<target_arch>/bindings/csharp/<module>/oneml/*.cs .
dotnet build
bin/Debug/net6.0/MyApp
```
2 changes: 2 additions & 0 deletions apps/csharp/VehicleDetectorApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ static void Main(string[] args) {
Console.WriteLine(print);
}

UsageReport report = detector.GetUsage();
report.ToLog();
}
}
4 changes: 3 additions & 1 deletion apps/golang/face_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func main() {

// load Image
filePath := path.Join(testAssetPath, "face-detect-set/face/0.jpg")
fmt.Println(filePath)
input := oneMLUtils.ReadImageCV(filePath)

result := faceDetector.Detect(input)
Expand All @@ -39,4 +38,7 @@ func main() {
fmt.Printf("Landmark %d: (%.6f, %.6f)\n", j, landmarks.GetX().Get(j), landmarks.GetY().Get(j))
}
}

report := faceDetector.GetUsage()
report.ToLog()
}
4 changes: 3 additions & 1 deletion apps/golang/face_embedder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func main() {
for i := 0; i < int(embed.Size()); i++ {
sum += embed.Get(i)
}

fmt.Printf("Embedding sum: %.5f\n", sum)

report := faceEmbedder.GetUsage()
report.ToLog()
}
3 changes: 3 additions & 0 deletions apps/golang/face_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,7 @@ func main() {
// GetIds
ids := faceId.GetIds()
fmt.Println("Gallery size:", ids.Size())

report := faceId.GetUsage()
report.ToLog()
}
Loading

0 comments on commit d023f8b

Please sign in to comment.