Download predict.py from Calotriton/RibbID_SVM: direct link, hf CLI and curl.
- Browser
- Download file 626 Bytes
-
https://huggingface.co/Calotriton/RibbID_SVM/resolve/main/predict.py
- Command line
-
hf download hf://Calotriton/RibbID_SVM/predict.py
-
curl -L -o predict.py https://huggingface.co/Calotriton/RibbID_SVM/resolve/main/predict.py
626 Bytes
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Mon Jun 30 17:02:31 2025 | |
| @author: User | |
| """ | |
| # predict.py | |
| import joblib | |
| import numpy as np | |
| # Cargar modelo y scaler | |
| scaler = joblib.load("scaler.joblib") | |
| model = joblib.load("svm_mfcc_model.joblib") | |
| def predict_species(mfcc_features: np.ndarray) -> str: | |
| """ | |
| Predicts the species given MFCC features (shape: [n_mfcc, n_frames]). | |
| """ | |
| # Flatten or average across time if needed | |
| features = mfcc_features.mean(axis=1) # shape (n_mfcc,) | |
| features = scaler.transform([features]) | |
| prediction = model.predict(features) | |
| return prediction[0] |