Instructions to use Abuzaid01/asl-sign-language-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Abuzaid01/asl-sign-language-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Abuzaid01/asl-sign-language-classifier") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, ASLResNet processor = AutoImageProcessor.from_pretrained("Abuzaid01/asl-sign-language-classifier") model = ASLResNet.from_pretrained("Abuzaid01/asl-sign-language-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload model.py with huggingface_hub
Browse files
model.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
from torchvision import models
|
| 4 |
+
|
| 5 |
+
class ASLResNet(nn.Module):
|
| 6 |
+
def __init__(self, num_classes):
|
| 7 |
+
super(ASLResNet, self).__init__()
|
| 8 |
+
|
| 9 |
+
# Load pre-trained ResNet-50
|
| 10 |
+
self.model = models.resnet50(pretrained=True)
|
| 11 |
+
|
| 12 |
+
# Replace classifier head
|
| 13 |
+
num_features = self.model.fc.in_features
|
| 14 |
+
self.model.fc = nn.Sequential(
|
| 15 |
+
nn.Dropout(0.3),
|
| 16 |
+
nn.Linear(num_features, 512),
|
| 17 |
+
nn.BatchNorm1d(512),
|
| 18 |
+
nn.ReLU(),
|
| 19 |
+
nn.Dropout(0.2),
|
| 20 |
+
nn.Linear(512, num_classes)
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
def forward(self, x):
|
| 24 |
+
return self.model(x)
|