Abedinho commited on
Commit
273d677
1 Parent(s): 9020533

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -3,12 +3,8 @@ import tensorflow as tf
3
  import numpy as np
4
  from tensorflow.keras.preprocessing import image
5
 
6
- # Laden der Modelle
7
- model_cnn = tf.keras.models.load_model('exercise_classification_model.h5')
8
- model_resnet50 = tf.keras.models.load_model('exercise_classification_model_resnet50.h5')
9
-
10
  # Klassenlabels (ersetzen Sie durch Ihre spezifischen Klassen)
11
- class_labels = ['bench_press', 'deadlift', 'hip_thrust', 'lat_pulldown', 'pull_up', 'squat', 'tricep_dips']
12
 
13
  def preprocess(img):
14
  img = img.resize((150, 150))
@@ -17,6 +13,19 @@ def preprocess(img):
17
  img_array /= 255.0
18
  return img_array
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  def predict_cnn(img):
21
  img_array = preprocess(img)
22
  prediction = model_cnn.predict(img_array)
 
3
  import numpy as np
4
  from tensorflow.keras.preprocessing import image
5
 
 
 
 
 
6
  # Klassenlabels (ersetzen Sie durch Ihre spezifischen Klassen)
7
+ class_labels = ['Bench Press', 'deadlift', 'hip_thrust', 'lat_pulldown', 'pull_up', 'squat', 'tricep_dips']
8
 
9
  def preprocess(img):
10
  img = img.resize((150, 150))
 
13
  img_array /= 255.0
14
  return img_array
15
 
16
+ # Laden der Modelle
17
+ try:
18
+ model_cnn = tf.keras.models.load_model('exercise_classification_model.h5')
19
+ print("CNN model loaded successfully")
20
+ except Exception as e:
21
+ print(f"Error loading CNN model: {e}")
22
+
23
+ try:
24
+ model_resnet50 = tf.keras.models.load_model('exercise_classification_model_resnet50.h5')
25
+ print("ResNet50 model loaded successfully")
26
+ except Exception as e:
27
+ print(f"Error loading ResNet50 model: {e}")
28
+
29
  def predict_cnn(img):
30
  img_array = preprocess(img)
31
  prediction = model_cnn.predict(img_array)