Spaces:
Sleeping
Sleeping
Update pages/2_Player_Comparison_Throw_Image.py
Browse files
pages/2_Player_Comparison_Throw_Image.py
CHANGED
|
@@ -47,20 +47,14 @@ def detect_and_predict_face(image_file, model):
|
|
| 47 |
|
| 48 |
expected_features = model.named_steps['scaler'].n_features_in_
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
target_height = 109
|
| 53 |
-
|
| 54 |
-
try:
|
| 55 |
-
resized_face = cv2.resize(face, (target_width, target_height)) # width first
|
| 56 |
-
except Exception as e:
|
| 57 |
-
return None, f"❌ Resize error: {e}"
|
| 58 |
-
|
| 59 |
-
# Debug: show resized shape
|
| 60 |
-
st.write(f"Resized shape: {resized_face.shape}") # Should be (109, 113)
|
| 61 |
|
| 62 |
flattened = resized_face.flatten().reshape(1, -1)
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
if flattened.shape[1] != expected_features:
|
| 66 |
return None, f"❌ Mismatch in feature count. Got {flattened.shape[1]}, expected {expected_features}"
|
|
@@ -73,6 +67,7 @@ def detect_and_predict_face(image_file, model):
|
|
| 73 |
|
| 74 |
|
| 75 |
|
|
|
|
| 76 |
# Get player details from the dataset
|
| 77 |
def get_player_details(df, player_name):
|
| 78 |
return df[df['Player'] == player_name].iloc[0]
|
|
|
|
| 47 |
|
| 48 |
expected_features = model.named_steps['scaler'].n_features_in_
|
| 49 |
|
| 50 |
+
# ✅ CORRECT: width=113, height=109 → 113*109 = 12289
|
| 51 |
+
resized_face = cv2.resize(face, (113, 109)) # <--- this is THE FIX
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
flattened = resized_face.flatten().reshape(1, -1)
|
| 54 |
+
|
| 55 |
+
# Debug output
|
| 56 |
+
st.write(f"Resized shape: {resized_face.shape}") # should be (109, 113)
|
| 57 |
+
st.write(f"Flattened shape: {flattened.shape}") # should be (1, 12289)
|
| 58 |
|
| 59 |
if flattened.shape[1] != expected_features:
|
| 60 |
return None, f"❌ Mismatch in feature count. Got {flattened.shape[1]}, expected {expected_features}"
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
+
|
| 71 |
# Get player details from the dataset
|
| 72 |
def get_player_details(df, player_name):
|
| 73 |
return df[df['Player'] == player_name].iloc[0]
|