{"id":15651026,"url":"https://github.com/pinto0309/hand-gesture-recognition-using-onnx","last_synced_at":"2025-10-11T00:12:14.928Z","repository":{"id":97172904,"uuid":"531814816","full_name":"PINTO0309/hand-gesture-recognition-using-onnx","owner":"PINTO0309","description":"This is a hand gesture recognition program that replaces the entire MediaPipe process with ONNX. Simultaneous detection of multiple palms and a simple tracker are additionally implemented. In addition, a simple MLP can learn and recognize gestures.","archived":false,"fork":false,"pushed_at":"2022-12-05T06:08:48.000Z","size":6109,"stargazers_count":56,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T18:33:15.260Z","etag":null,"topics":["onnx","onnxruntime","python","pytorch","tensorflow","tflite"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PINTO0309.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-02T06:52:33.000Z","updated_at":"2025-04-18T19:49:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"52a7b3d8-5432-4456-8c01-5896674b5329","html_url":"https://github.com/PINTO0309/hand-gesture-recognition-using-onnx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PINTO0309/hand-gesture-recognition-using-onnx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fhand-gesture-recognition-using-onnx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fhand-gesture-recognition-using-onnx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fhand-gesture-recognition-using-onnx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fhand-gesture-recognition-using-onnx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PINTO0309","download_url":"https://codeload.github.com/PINTO0309/hand-gesture-recognition-using-onnx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fhand-gesture-recognition-using-onnx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005649,"owners_count":26083940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["onnx","onnxruntime","python","pytorch","tensorflow","tflite"],"created_at":"2024-10-03T12:36:40.093Z","updated_at":"2025-10-11T00:12:14.884Z","avatar_url":"https://github.com/PINTO0309.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Japanese / [WIP] English]\n\n---\n# hand-gesture-recognition-using-onnx\n[Kazuhito00/hand-gesture-recognition-using-mediapipe](https://github.com/Kazuhito00/hand-gesture-recognition-using-mediapipe) [@Kazuhito00](https://github.com/Kazuhito00) を引用させていただき、MediaPipeの実装を全てONNXにリプレースしたリポジトリです。簡易なMLPでハンドサインとフィンガージェスチャーを認識するサンプルプログラムです。とりあえず動く、ということしか確認していません。\n\nhttps://user-images.githubusercontent.com/33194443/189632510-1823cd54-bc36-4889-ac14-adc16deba9b8.mp4\n\n本リポジトリは以下の内容を含みます。\n- サンプルプログラム\n- ハンドディテクションモデル (改造ONNX)\n- 手のひらランドマークディテクションモデル (改造ONNX)\n- ハンドサイン認識モデル (改造ONNX)\n- フィンガージェスチャー認識モデル (改造ONNX)\n- ハンドサイン認識用学習データ、および、学習用ノートブック\n- フィンガージェスチャー認識用学習データ、および、学習用ノートブック\n\n# Requirements\n- onnxruntime 1.12.0 or onnxruntime-gpu 1.12.0\n- opencv-contrib-python 4.6.0.66 or Later\n- Tensorflow 2.10.0 (学習後にONNXファイルを再作成する場合のみ)\n- PyTorch 1.12.0 (学習後にONNXファイルを再作成する場合のみ)\n- tf2onnx 1.12.0 or Later (学習後にONNXファイルを再作成する場合のみ)\n- simple-onnx-processing-tools 1.0.54 or Later (学習後にONNXファイルを再作成する場合のみ)\n- scikit-learn 0.23.2 or Later (学習時に混同行列を表示したい場合のみ)\n- matplotlib 3.3.2 or Later (学習時に混同行列を表示したい場合のみ)\n\n# Demo\nWebカメラを使ったデモの実行方法は以下です。\n```bash\npython app.py\n```\n\nデモ実行時には、以下のオプションが指定可能です。\n```\n--device\n    カメラデバイス番号の指定 (デフォルト：0)\n\n--width\n    カメラキャプチャ時の横幅 (デフォルト：640)\n\n--height\n    カメラキャプチャ時の縦幅 (デフォルト：480)\n\n--min_detection_confidence\n    検出信頼値の閾値 (デフォルト：0.6)\n\n--disable_image_flip\n    入力映像の左右反転を無効化\n```\n\n# Directory\n```\n.\n│  app.py\n│  keypoint_classification.ipynb\n│  point_history_classification.ipynb\n│  requirements.txt\n│  README.md\n│\n├─model\n│  ├─keypoint_classifier\n│  │  │  tflite_to_onnx.sh\n│  │  │  make_argmax.py\n│  │  │  keypoint.csv\n│  │  │  keypoint_classifier.hdf5\n│  │  │  keypoint_classifier.py\n│  │  │  keypoint_classifier.tflite\n│  │  │  keypoint_classifier.onnx\n│  │  └─ keypoint_classifier_label.csv\n│  │\n│  └─point_history_classifier\n│      │  tflite_to_onnx.sh\n│      │  make_argmax.py\n│      │  point_history.csv\n│      │  point_history_classifier.hdf5\n│      │  point_history_classifier.py\n│      │  point_history_classifier.tflite\n│      │  point_history_classifier.onnx\n│      └─ point_history_classifier_label.csv\n│\n└─utils\n    │  cvfpscalc.py\n    └─ utils.py\n```\n### app.py\n推論用のサンプルプログラムです。\u003cbr\u003eまた、ハンドサイン認識用の学習データ(キーポイント)、\u003cbr\u003e\nフィンガージェスチャー認識用の学習データ(人差指の座標履歴)を収集することもできます。\n\n### keypoint_classification.ipynb\nハンドサイン認識用のモデル訓練用スクリプトです。\n\n### point_history_classification.ipynb\nフィンガージェスチャー認識用のモデル訓練用スクリプトです。\n\n### model/keypoint_classifier\nハンドサイン認識に関わるファイルを格納するディレクトリです。\u003cbr\u003e\n以下のファイルが格納されます。\n- tfliteのONNX変換スクリプト (tflite_to_onnx.sh)\n- ONNX部品生成プログラム (make_argmax.py)\n- 学習用データ (keypoint.csv)\n- 学習済モデル (keypoint_classifier.tflite)\n- 学習済モデル (keypoint_classifier.onnx)\n- ラベルデータ (keypoint_classifier_label.csv)\n- 推論用クラス (keypoint_classifier.py)\n\n### model/point_history_classifier\nフィンガージェスチャー認識に関わるファイルを格納するディレクトリです。\u003cbr\u003e\n以下のファイルが格納されます。\n- tfliteのONNX変換スクリプト (tflite_to_onnx.sh)\n- ONNX部品生成プログラム (make_argmax.py)\n- 学習用データ (point_history.csv)\n- 学習済モデル (point_history_classifier.tflite)\n- 学習済モデル (point_history_classifier.onnx)\n- ラベルデータ (point_history_classifier_label.csv)\n- 推論用クラス (point_history_classifier.py)\n\n### utils/cvfpscalc.py\nFPS計測用のモジュールです。\n\n### utils/utils.py\n画像加工用の関数群です。\n\n# Training\nハンドサイン認識、フィンガージェスチャー認識は、\u003cbr\u003e学習データの追加、変更、モデルの再トレーニングが出来ます。\n\n### ハンドサイン認識トレーニング方法\n#### 1.学習データ収集\n「k」を押すと、キーポイントの保存するモードになります（「MODE:Logging Key Point」と表示される）\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102235423-aa6cb680-3f35-11eb-8ebd-5d823e211447.jpg\" width=\"60%\"\u003e\u003cbr\u003e\u003cbr\u003e\n「0」～「9」を押すと「model/keypoint_classifier/keypoint.csv」に以下のようにキーポイントが追記されます。\u003cbr\u003e\n1列目：押下した数字(クラスIDとして使用)、2列目：trackid、3列目以降：キーポイント座標\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102345725-28d26280-3fe1-11eb-9eeb-8c938e3f625b.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\nキーポイント座標は以下の前処理を④まで実施したものを保存します。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102242918-ed328c80-3f3d-11eb-907c-61ba05678d54.png\" width=\"80%\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102244114-418a3c00-3f3f-11eb-8eef-f658e5aa2d0d.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\n初期状態では、パー(クラスID：0)、グー(クラスID：1)、指差し(クラスID：2)の3種類の学習データが入っています。\u003cbr\u003e\n必要に応じて3以降を追加したり、csvの既存データを削除して、学習データを用意してください。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102348846-d0519400-3fe5-11eb-8789-2e7daec65751.jpg\" width=\"25%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102348855-d2b3ee00-3fe5-11eb-9c6d-b8924092a6d8.jpg\" width=\"25%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102348861-d3e51b00-3fe5-11eb-8b07-adc08a48a760.jpg\" width=\"25%\"\u003e\n\n#### 2.モデル訓練\n「[keypoint_classification.ipynb](keypoint_classification.ipynb)」をJupyter Notebookで開いて上から順に実行してください。\u003cbr\u003e\n学習データのクラス数を変更する場合は「NUM_CLASSES = 3」の値を変更し、\u003cbr\u003e「model/keypoint_classifier/keypoint_classifier_label.csv」のラベルを適宜修正してください。\u003cbr\u003e\u003cbr\u003e\n\n#### X.モデル構造\n「[keypoint_classification.ipynb](keypoint_classification.ipynb)」で用意しているモデルのイメージは以下です。\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102246723-69c76a00-3f42-11eb-8a4b-7c6b032b7e71.png\" width=\"50%\"\u003e\u003cbr\u003e\u003cbr\u003e\n\n### フィンガージェスチャー認識トレーニング方法\n#### 1.学習データ収集\n「h」を押すと、指先座標の履歴を保存するモードになります（「MODE:Logging Point History」と表示される）\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102249074-4d78fc80-3f45-11eb-9c1b-3eb975798871.jpg\" width=\"60%\"\u003e\u003cbr\u003e\u003cbr\u003e\n「0」～「9」を押すと「model/point_history_classifier/point_history.csv」に以下のようにキーポイントが追記されます。\u003cbr\u003e\n1列目：押下した数字(クラスIDとして使用)、2列目：trackid、3列目以降：座標履歴\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102345850-54ede380-3fe1-11eb-8d04-88e351445898.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\nキーポイント座標は以下の前処理を④まで実施したものを保存します。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102244148-49e27700-3f3f-11eb-82e2-fc7de42b30fc.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\n初期状態では、静止(クラスID：0)、時計回り(クラスID：1)、反時計回り(クラスID：2)、移動(クラスID：4)の\u003cbr\u003e4種類の学習データが入っています。\u003cbr\u003e\n必要に応じて5以降を追加したり、csvの既存データを削除して、学習データを用意してください。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350939-02b0c080-3fe9-11eb-94d8-54a3decdeebc.jpg\" width=\"20%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350945-05131a80-3fe9-11eb-904c-a1ec573a5c7d.jpg\" width=\"20%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350951-06444780-3fe9-11eb-98cc-91e352edc23c.jpg\" width=\"20%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350942-047a8400-3fe9-11eb-9103-dbf383e67bf5.jpg\" width=\"20%\"\u003e\n\n#### 2.モデル訓練\n「[point_history_classification.ipynb](point_history_classification.ipynb)」をJupyter Notebookで開いて上から順に実行してください。\u003cbr\u003e\n学習データのクラス数を変更する場合は「NUM_CLASSES = 4」の値を変更し、\u003cbr\u003e「model/point_history_classifier/point_history_classifier_label.csv」のラベルを適宜修正してください。\u003cbr\u003e\u003cbr\u003e\n\n#### X.モデル構造\n「[point_history_classification.ipynb](point_history_classification.ipynb)」で用意しているモデルのイメージは以下です。\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102246771-7481ff00-3f42-11eb-8ddf-9e3cc30c5816.png\" width=\"50%\"\u003e\u003cbr\u003e\n「LSTM」を用いたモデルは以下です。\u003cbr\u003e使用する際には「use_lstm = False」を「True」に変更してください\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102246817-8368b180-3f42-11eb-9851-23a7b12467aa.png\" width=\"60%\"\u003e\n\n# Application example\n- None\n\n# Reference\n- [Kazuhito00/hand-gesture-recognition-using-mediapipe](https://github.com/Kazuhito00/hand-gesture-recognition-using-mediapipe)\n- [geaxgx/depthai_hand_tracker](https://github.com/geaxgx/depthai_hand_tracker)\n- [PINTO0309/simple-onnx-processing-tools](https://github.com/PINTO0309/simple-onnx-processing-tools)\n- https://github.com/PINTO0309/PINTO_model_zoo/tree/main/033_Hand_Detection_and_Tracking\n\n# Acknowledgments\n- hand-gesture-recognition-using-mediapipe: 高橋かずひと (https://twitter.com/KzhtTkhs)\n  - [Apache-2.0 License](https://github.com/Kazuhito00/hand-gesture-recognition-using-mediapipe/blob/main/LICENSE)\n- depthai_hand_tracker: geaxgx (https://github.com/geaxgx/depthai_hand_tracker)\n  - [MIT License](https://github.com/geaxgx/depthai_hand_tracker/blob/main/LICENSE.txt)\n\n# Author\n- hand-gesture-recognition-using-onnx: Katsuya Hyodo\n  - [Apache-2.0 License](LICENSE)\n\n# ToDo\n- [x] LSTM ONNX\n- [ ] BPF (body_pre_focusing) の実装\n- [ ] 変数とループの整理\n- [ ] CSVロギングの見直し\n- [ ] DeepSort\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fhand-gesture-recognition-using-onnx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinto0309%2Fhand-gesture-recognition-using-onnx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fhand-gesture-recognition-using-onnx/lists"}