Irgenija commited on
Commit
b796ff0
1 Parent(s): 9d1c77f

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +42 -0
  2. model.py +16 -0
  3. sign_language_resnet50.pth +3 -0
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - pytorch
5
+ ---
6
+
7
+ ### Description
8
+
9
+ This model with transfer learning is trained to recognise Sign Language.
10
+ The model was trained on the basis of ResNet50.
11
+ The dataset was used for training https://huggingface.co/datasets/aliciiavs/sign_language_image_dataset
12
+
13
+ In `model.py` file you can find class of custom model.
14
+ For using model you need download `model.py`, import from it class `CustomResNetModel`,
15
+ create an example of this class and load and apply model weight from file
16
+ `sign_language_resnet50.pth`
17
+ Model's metrics: `loss: 0.5739429252889922` `accuracy: 0.901717`
18
+
19
+ #### Example of code
20
+
21
+ ```
22
+ import torch
23
+ from huggingface_hub import hf_hub_download
24
+
25
+ from model import CustomResNetModel
26
+
27
+ device = "cuda" if torch.cuda.is_available() else "cpu"
28
+ model = CustomResNetModel(num_classes=24)
29
+ weight_path = hf_hub_download(
30
+ repo_id="Irgenija/sign_language_resnet50",
31
+ filename="sign_language_resnet50.pth",
32
+ )
33
+ if cls.device == "cpu":
34
+ checkpoint = torch.load(
35
+ weight_path, map_location=torch.device("cpu")
36
+ )
37
+ else:
38
+ checkpoint = torch.load(weight_path)
39
+ model.load_state_dict(checkpoint)
40
+ model = model.to(device) # Optional
41
+ model.eval()
42
+ ```
model.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from torch import nn
2
+ from torchvision import models
3
+
4
+
5
+ class CustomResNetModel(nn.Module):
6
+ """Custom model based on ResNet50."""
7
+
8
+ def __init__(self, num_classes=24):
9
+ super(CustomResNetModel, self).__init__()
10
+ self.model = models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V2)
11
+ for param in self.model.parameters():
12
+ param.requires_grad = False
13
+ self.model.fc = nn.Linear(self.model.fc.in_features, num_classes)
14
+
15
+ def forward(self, x):
16
+ return self.model(x)
sign_language_resnet50.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3493e265ec4d110d036dfe7fe79403fb0208956ab473f979d8ee0a7a49624c2
3
+ size 94560442