--- language: - en license: mit library_name: pytorch tags: - computer-vision - image-classification - resnet - sign-language - handsign metrics: - accuracy pipeline_tag: image-classification --- # ResNet-18 American Sign Language (ASL) Classifier This repository contains pre-trained PyTorch weights for a **ResNet-18** model fine-tuned for American Sign Language (ASL) alphabetic hand sign classification (static letters A through Y, excluding motion-based letters J and Z). - **Overall Test Accuracy**: **98.48%** on 7,172 test images. - **Framework**: PyTorch - **Base Architecture**: ResNet-18 (ImageNet pre-trained) - **Transfer Learning Strategy**: Frozen `layer1`-`layer3`, fine-tuned `layer4` + custom head: - `Linear(512, 256)` -> `BatchNorm1d(256)` -> `ReLU` -> `Dropout(0.3)` -> `Linear(256, 24)` --- ## Model Usage ```python import torch import torchvision.models as models import torch.nn as nn from PIL import Image from torchvision import transforms from huggingface_hub import hf_hub_download # 1. Define Model Architecture model = models.resnet18() model.fc = nn.Sequential( nn.Linear(512, 256), nn.BatchNorm1d(256), nn.ReLU(), nn.Dropout(0.3), nn.Linear(256, 24) ) # 2. Download and Load Model Weights weights_path = hf_hub_download(repo_id="Vecrist/resnet18-handsign-classifier", filename="ResNet-18_9848AccModel_weights.pth") model.load_state_dict(torch.load(weights_path, map_location="cpu")) model.eval() # 3. Preprocess Image transform = transforms.Compose([ transforms.Resize((224, 224)), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ]) # 4. Predict # img = Image.open("path_to_handsign_image.jpg").convert("RGB") # outputs = model(transform(img).unsqueeze(0)) # predicted_class_idx = outputs.argmax(dim=1).item() ``` --- ## Dataset & Training Details - **Dataset**: Kaggle Hand Sign Images dataset (static alphabet signs). - **Optimizer**: Adam with differential learning rates (`0.0001` for `layer4`, `0.001` for FC head). - **Batch Size**: 64 - **Loss Function**: `CrossEntropyLoss` - **Data Augmentations**: `RandomResizedCrop(224)`, `RandomHorizontalFlip`, ImageNet Normalization.