Commit
·
0aa26c7
1
Parent(s):
e548270
Update app_swin.py
Browse files- app_swin.py +8 -2
app_swin.py
CHANGED
@@ -50,6 +50,14 @@ CLASSES = ['afternoon', 'animal', 'bad', 'beautiful', 'big', 'bird', 'blind', 'c
|
|
50 |
'sick', 'skirt', 'slow', 'small', 'suit', 'sunday', 't_shirt', 'tall', 'thursday', 'time', 'today', 'tomorrow', 'tuesday', 'ugly', 'warm', 'wednesday', 'week', 'wet',
|
51 |
'wide', 'year', 'yesterday', 'young']
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Set the device (GPU or CPU)
|
54 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
55 |
# pretrained Model
|
@@ -314,8 +322,6 @@ def translate_sign_language(gesture):
|
|
314 |
|
315 |
# Identify the hand gesture
|
316 |
predicted_prod_label = predicted_prod_label.squeeze(0)
|
317 |
-
|
318 |
-
idx_to_label = model_pretrained_2.config.id2label
|
319 |
gesture_translation = idx_to_label[predicted_prod_label.cpu().numpy().item()] # Convert to a scalar
|
320 |
|
321 |
return gesture_translation , prod_video_path # frame_generator
|
|
|
50 |
'sick', 'skirt', 'slow', 'small', 'suit', 'sunday', 't_shirt', 'tall', 'thursday', 'time', 'today', 'tomorrow', 'tuesday', 'ugly', 'warm', 'wednesday', 'week', 'wet',
|
51 |
'wide', 'year', 'yesterday', 'young']
|
52 |
|
53 |
+
idx_to_label = {0: 'afternoon', 1: 'animal', 2: 'bad', 3: 'beautiful', 4: 'big', 5: 'bird', 6: 'blind', 7: 'cat', 8: 'cheap', 9: 'clothing', 10: 'cold', 11: 'cow',
|
54 |
+
12: 'curved', 13: 'deaf', 14: 'dog', 15: 'dress', 16: 'dry', 17: 'evening', 18: 'expensive', 19: 'famous', 20: 'fast', 21: 'female', 22: 'fish',
|
55 |
+
23: 'flat', 24: 'friday', 25: 'good', 26: 'happy', 27: 'hat', 28: 'healthy', 29: 'horse', 30: 'hot', 31: 'hour', 32: 'light', 33: 'long', 34: 'loose',
|
56 |
+
35: 'loud', 36: 'minute', 37: 'monday', 38: 'month', 39: 'morning', 40: 'mouse', 41: 'narrow', 42: 'new', 43: 'night', 44: 'old', 45: 'pant',
|
57 |
+
46: 'pocket', 47: 'quiet', 48: 'sad', 49: 'saturday', 50: 'second', 51: 'shirt', 52: 'shoes', 53: 'short', 54: 'sick', 55: 'skirt', 56: 'slow',
|
58 |
+
57: 'small', 58: 'suit', 59: 'sunday', 60: 't_shirt', 61: 'tall', 62: 'thursday', 63: 'time', 64: 'today', 65: 'tomorrow', 66: 'tuesday', 67: 'ugly',
|
59 |
+
68: 'warm', 69: 'wednesday', 70: 'week', 71: 'wet', 72: 'wide', 73: 'year', 74: 'yesterday', 75: 'young'}
|
60 |
+
|
61 |
# Set the device (GPU or CPU)
|
62 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
63 |
# pretrained Model
|
|
|
322 |
|
323 |
# Identify the hand gesture
|
324 |
predicted_prod_label = predicted_prod_label.squeeze(0)
|
|
|
|
|
325 |
gesture_translation = idx_to_label[predicted_prod_label.cpu().numpy().item()] # Convert to a scalar
|
326 |
|
327 |
return gesture_translation , prod_video_path # frame_generator
|