AamirMalik commited on
Commit
5641c82
·
verified ·
1 Parent(s): 6107dcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -4,16 +4,10 @@ import mediapipe as mp
4
  import numpy as np
5
  import tensorflow as tf
6
  import tempfile
7
-
8
- # Load gesture classification model
9
- #model = tf.keras.models.load_model('gesture_model.h5')
10
- # Load model directly
11
- #from transformers import AutoModel
12
- #model = AutoModel.from_pretrained("joonsong/gesture_model_2")
13
  from transformers import AutoModelForImageClassification
14
- # Load the model directly from Hugging Face Hub
15
- model = AutoModelForImageClassification.from_pretrained("joonsong/gesture_model_2")
16
 
 
 
17
 
18
  # Mediapipe initialization
19
  mp_hands = mp.solutions.hands
@@ -23,8 +17,8 @@ mp_draw = mp.solutions.drawing_utils
23
  # Function for gesture classification
24
  def classify_gesture(landmarks):
25
  landmarks = np.array(landmarks).reshape(1, -1)
26
- prediction = model.predict(landmarks)
27
- return np.argmax(prediction)
28
 
29
  # Streamlit UI
30
  def main():
 
4
  import numpy as np
5
  import tensorflow as tf
6
  import tempfile
 
 
 
 
 
 
7
  from transformers import AutoModelForImageClassification
 
 
8
 
9
+ # Load gesture classification model from Hugging Face Hub
10
+ model = AutoModelForImageClassification.from_pretrained("nateraw/gesture-classification")
11
 
12
  # Mediapipe initialization
13
  mp_hands = mp.solutions.hands
 
17
  # Function for gesture classification
18
  def classify_gesture(landmarks):
19
  landmarks = np.array(landmarks).reshape(1, -1)
20
+ prediction = model(landmarks)
21
+ return np.argmax(prediction.logits.detach().numpy())
22
 
23
  # Streamlit UI
24
  def main():