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_inverted would look like peace).
  • 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

Downloads last month
20
Safetensors
Model size
27.9M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for smrzn/gesture-music-convnextv2-tiny

Finetuned
(62)
this model

Dataset used to train smrzn/gesture-music-convnextv2-tiny

Paper for smrzn/gesture-music-convnextv2-tiny

Evaluation results

  • accuracy on HaGRID sample 384p, MediaPipe hand crops (held-out test split)
    self-reported
    0.904
  • Macro F1 on HaGRID sample 384p, MediaPipe hand crops (held-out test split)
    self-reported
    0.906
  • Macro precision on HaGRID sample 384p, MediaPipe hand crops (held-out test split)
    self-reported
    0.911
  • Macro recall on HaGRID sample 384p, MediaPipe hand crops (held-out test split)
    self-reported
    0.904