niol08 commited on
Commit
c7b4b0e
·
verified ·
1 Parent(s): fc07d9f

Update src/model_loader.py

Browse files
Files changed (1) hide show
  1. src/model_loader.py +44 -44
src/model_loader.py CHANGED
@@ -1,45 +1,45 @@
1
-
2
- from keras.models import load_model
3
- from graph import zeropad, zeropad_output_shape
4
- from pathlib import Path
5
- import joblib
6
- from download_models import ensure_models_downloaded
7
-
8
- def load_mitbih_model():
9
- ensure_models_downloaded()
10
- return load_model(
11
- "models/MLII-latest.keras",
12
- custom_objects={
13
- "zeropad": zeropad,
14
- "zeropad_output_shape": zeropad_output_shape
15
- },
16
- compile=False
17
- )
18
-
19
- def load_pcg_model():
20
- ensure_models_downloaded()
21
- model_path = Path("models/pcg_model.h5")
22
- if not model_path.exists():
23
- raise FileNotFoundError(f"PCG model not found at {model_path.resolve()}")
24
-
25
- model = load_model(model_path, compile=False)
26
- model.compile()
27
- return model
28
-
29
- def load_emg_model():
30
- ensure_models_downloaded()
31
- model_path = Path("models/emg_classifier_txt.h5")
32
- if not model_path.exists():
33
- raise FileNotFoundError(f"EMG model not found at {model_path.resolve()}")
34
- model = load_model(model_path, compile=False)
35
- model.compile()
36
- return model
37
-
38
-
39
- def load_vag_model():
40
- ensure_models_downloaded()
41
- p = Path("models/vag_feature_classifier.pkl")
42
- if not p.exists():
43
- raise FileNotFoundError(f"No VAG model at {p.resolve()}")
44
- return joblib.load(p)
45
 
 
1
+
2
+ from keras.models import load_model
3
+ from graph import zeropad, zeropad_output_shape
4
+ from pathlib import Path
5
+ import joblib
6
+
7
+
8
+ def load_mitbih_model():
9
+
10
+ return load_model(
11
+ "models/MLII-latest.keras",
12
+ custom_objects={
13
+ "zeropad": zeropad,
14
+ "zeropad_output_shape": zeropad_output_shape
15
+ },
16
+ compile=False
17
+ )
18
+
19
+ def load_pcg_model():
20
+
21
+ model_path = Path("models/pcg_model.h5")
22
+ if not model_path.exists():
23
+ raise FileNotFoundError(f"PCG model not found at {model_path.resolve()}")
24
+
25
+ model = load_model(model_path, compile=False)
26
+ model.compile()
27
+ return model
28
+
29
+ def load_emg_model():
30
+
31
+ model_path = Path("models/emg_classifier_txt.h5")
32
+ if not model_path.exists():
33
+ raise FileNotFoundError(f"EMG model not found at {model_path.resolve()}")
34
+ model = load_model(model_path, compile=False)
35
+ model.compile()
36
+ return model
37
+
38
+
39
+ def load_vag_model():
40
+
41
+ p = Path("models/vag_feature_classifier.pkl")
42
+ if not p.exists():
43
+ raise FileNotFoundError(f"No VAG model at {p.resolve()}")
44
+ return joblib.load(p)
45