1.0.2 • Published 9 months ago

@vominhmanh/etik_ai_edge_tool v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

getting started

version

  • Node version: 20.11.1

install

    1. clone etik_ai_edge_tool về, đặt ngang hàng với project của bạn.
    1. cd etik_ai_edge_tool --> npm run typescript and npm install
    1. đi đến project của bạn: cd /path/to/your-project
    1. cài đặt project bằng npm install ../etik_ai_edge_tool hoặc yarn add ../etik_ai_edge_tool
    1. copy model_tfjs từ thư viện và cho vào public folder của project của bạn: etik_ai_edge_tool/src/model_tfjs >>> public folder of project

disable fs, path, crypto

Đối với projects vuejs

  • chỉnh sửa cài đặt trong webpack.config.js như sau:
module.exports = {
  resolve: {
    modules: [...],
    fallback: {
      fs: false,
      path: false,
      crypto: false
    }
  }
};

Đối với projects reactjs

  • ReactJS không có file webpack.config.js tại root folder. Vì vậy, cần cài bổ sung react-app-rewired để ghi đè webpack.config.js.
    1. Install react-app-rewired: npm install react-app-rewired
    1. Create a file named config-overrides.js in the ROOT of your client/React project. NOT SRC the ROOT.
    1. Add the following code, which ignores fs if it's not found in any of the dependencies you are using.
module.exports = function override(config, env) {
    console.log("React app rewired works!")
    config.resolve.fallback = {
        fs: false,
        path: false,
        crypto: false
    };
    return config;
};
    1. Replace react-scripts in the scripts section of package.json with react-app-rewired. Example:
// Other stuff above such as dependencies section
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
  },
// Other stuff below such as eslintConfig or browserslist section

Usage

  • B0: import * as moocAiTool from "etik_ai_edge_tool"
  • B1: khởi tạo và load model

    • gọi hàm moocAiTool.initialFace(videoElm) để khởi tạo tool face
    • gọi hàm moocAiTool.initialCard(videoElm) để khởi tạo tool card.
    • trong đó videoElm là HTMLVideoElement của webcam
  • B2: executeLoop: gọi hàm output = moocAiTool.executeFace(poseThreshold) hoặc output = moocAiTool.executeCard() để lấy output predict từ video

Example

  • Xem proj ví dụ tại: etik_ai_edge_tool/example

Output

output face có dạng

{
    "codes": [
        0
    ],
    "messages": [
        "Phát hiện khuôn mặt thành công."
    ],
    "pose": {
        "yaw": "center" | "right" | "left",  
        "pitch": "center" | "up" | "down"
    },
    "pose_estimation_number": {
        "yaw": -15.622733828311134,   
        "pitch": -6.149055266655619,
        "roll": -3.7043146585367506
    }
}

tham khảo định nghĩa yaw, pitch, roll:

https://github.com/Mostafa-Nafie/Head-Pose-Estimation

code output

  • 0: thành công
  • 12: Có nhiều hơn một khuôn mặt
  • 14: Khuôn mặt quá nhỏ so với khung hình
  • 15:: Khuôn mặt quá to so với khung hình

mã lỗi khi phát hiện:

Nếu có lỗi thì pose và pose estimation sẽ có giá trị null

  • 1: lỗi tay che
  • 2: lỗi khẩu trang
  • 3: lỗi kính râm
  • 4: lỗi vật che phủ
  • 10: lỗi đầu vào không hợp lệ
  • 11: LỗiKhông tìm thấy khuôn mặt
  • 13: Lỗi Khuôn mặt không thẳng.

output card có dạng

{
    "code": 0
    "message: "thành công.",
    "label_id": 0->25,
    "label_text": string tương ứng,  
}

list output card:

output body có dạng

{
    "code": 0
    "message: "thành công.",
}

list body code:

  • 0: thành công
  • 16: Error: không phát hiện người

docs model card-validation:

https://docs.google.com/spreadsheets/d/1Rk562r-z2ZKQ6VJ8dMiy2oxtQRzH7xOnMvqKS4P5VH8/edit?pli=1&gid=1456191172#gid=1456191172