Instructions to use smrzn/gesture-music-convnextv2-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use smrzn/gesture-music-convnextv2-tiny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="smrzn/gesture-music-convnextv2-tiny") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("smrzn/gesture-music-convnextv2-tiny") model = AutoModelForImageClassification.from_pretrained("smrzn/gesture-music-convnextv2-tiny", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download README.md from smrzn/gesture-music-convnextv2-tiny: direct link, hf CLI and curl.
- Browser
- Download file 5.21 kB
-
https://huggingface.co/smrzn/gesture-music-convnextv2-tiny/resolve/main/README.md
- Command line
-
hf download hf://smrzn/gesture-music-convnextv2-tiny/README.md
-
curl -L -o README.md https://huggingface.co/smrzn/gesture-music-convnextv2-tiny/resolve/main/README.md
license: cc-by-sa-4.0
library_name: transformers
pipeline_tag: image-classification
base_model: facebook/convnextv2-tiny-1k-224
datasets:
- cj-mills/hagrid-sample-30k-384p
tags:
- hand-gesture
- gesture-recognition
- image-classification
- hagrid
- convnextv2
metrics:
- accuracy
- f1
- precision
- recall
model-index:
- name: gesture-music-convnextv2-tiny
results:
- task:
type: image-classification
dataset:
name: HaGRID sample 384p, MediaPipe hand crops (held-out test split)
type: cj-mills/hagrid-sample-30k-384p
metrics:
- type: accuracy
value: 0.904
- type: f1
value: 0.9056
name: Macro F1
- type: precision
value: 0.9114
name: Macro precision
- type: recall
value: 0.9038
name: Macro recall
Gesture Music: ConvNeXt V2-tiny hand-gesture classifier
A fine-tuned facebook/convnextv2-tiny-1k-224 (27.9 M parameters) that names 18 hand gestures from a cropped picture of a hand. It is the model used in our webcam app that turns hand gestures into piano chords (MediaPipe finds and crops the hand, this model names the gesture, and the gesture picks the chord).
Made for the DPS970 (AI for Software Developers) final project at Seneca Polytechnic. It is a class prototype, not a production system.
Classes (18): call, dislike, fist, four, like, mute, ok, one, palm, peace, peace_inverted, rock, stop, stop_inverted, three, three2, two_up, two_up_inverted.
Important: it expects a tight hand crop
The model was trained on square crops around a single hand, not on full photos. Crop with MediaPipe Hand Landmarker: take the 21 landmark points, draw a square around them with 25% extra margin, crop, and resize to 256 x 256 (the model then resizes to 224). On full-frame photos the accuracy will be much lower.
from transformers import pipeline
clf = pipeline("image-classification", model="smrzn/gesture-music-convnextv2-tiny")
print(clf("hand_crop.jpg", top_k=3)) # e.g. [{'label': 'fist', 'score': 0.97}, ...]
Training data and method
- Data:
cj-mills/hagrid-sample-30k-384p, a 384p sample (31,833 photos) of HaGRID. Every photo was cropped to the hand with MediaPipe; MediaPipe found a hand in 90.0% (28,663 photos) and the rest were dropped. - Split: stratified 70/15/15 with seed 42: 20,066 train / 4,324 validation / 4,273 test (hand-found photos). The exact indices are in
eval/split_found_seed42.json. - Fine-tuning: all layers, ImageNet normalisation, 224 px, mixed precision (fp16), learning rate 5e-5 with warm-up and cosine decay, batch 32, up to 10 epochs with early stopping (patience 3). Augmentation: random crop/zoom, rotation up to 10 degrees, colour jitter, and no horizontal flip (a mirrored
peace_invertedwould look likepeace). - Model selection: best epoch by validation macro F1 (epoch 3; training stopped after epoch 6 because it began to overfit).
Results (held-out test split, 4,273 hand crops)
| Metric | Value |
|---|---|
| Accuracy | 0.9040 |
| Macro precision | 0.9114 |
| Macro recall | 0.9038 |
| Macro F1 | 0.9056 |
| Speed, 1 image, Tesla T4 GPU | 7.8 ms |
| Speed, 1 image, Kaggle CPU | 124 ms |
Validation: accuracy 0.9082, macro F1 0.9099. See eval/ for the confusion matrix, per-class results and training curves. A larger ViT-base sibling scored 0.9067 macro F1, statistically tied, at 3x the size, so we ship this one.
Common mix-ups: like, dislike, three, two_up are sometimes read as one; three and four are confused with each other. When the model is wrong it is usually unsure: on a small check of 180 test photos, ignoring answers below 50% confidence kept 87% of predictions and 98% of those were correct.
Limitations
- Trained on photos from one dataset; a laptop webcam (lighting, background, camera quality, distance) looks different, so live accuracy will be lower than the test score.
- The scores assume MediaPipe found the hand (about 90% of photos); they are not end-to-end accuracy.
- Accuracy may vary with lighting, background and skin tone; we have not measured this.
- Only these 18 gestures; no "no gesture" class (the app treats "no hand found" as silence).
License and credits
- Released under CC BY-SA 4.0, following the license of the training data. The base model, ConvNeXt V2 by Meta, is Apache-2.0.
- Data: HaGRID: Kapitanov, Kvanchiani, Nagaev, Kraynov, Vasiliev, "HaGRID: HAnd Gesture Recognition Image Dataset", WACV 2024, pp. 4572-4581, arXiv:2206.08219, github.com/hukenovs/hagrid (CC BY-SA 4.0). Sample from cj-mills/hagrid-sample-30k-384p.
- Idea: inspired by Eric Wei's Gesture Synth.