Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- main/helper.py +4 -3
main/helper.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
# Helper functions for the model inference api
|
| 2 |
-
|
| 3 |
import yaml
|
| 4 |
import joblib
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
# load yaml files to get model meta data.
|
| 8 |
try:
|
| 9 |
-
|
|
|
|
| 10 |
model_metadata = yaml.safe_load(f)
|
| 11 |
except:
|
| 12 |
raise FileNotFoundError("Failed to load file having model metadata")
|
|
@@ -15,7 +16,7 @@ except:
|
|
| 15 |
def load_model():
|
| 16 |
""" Loads ML model from location path and returns the model. """
|
| 17 |
try:
|
| 18 |
-
with open(Path("
|
| 19 |
model = joblib.load(f)
|
| 20 |
return model
|
| 21 |
|
|
|
|
| 1 |
# Helper functions for the model inference api
|
| 2 |
+
import os
|
| 3 |
import yaml
|
| 4 |
import joblib
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
# load yaml files to get model meta data.
|
| 8 |
try:
|
| 9 |
+
print(os.getcwd())
|
| 10 |
+
with open(Path("model/registered_model_meta.yaml"), 'r') as f:
|
| 11 |
model_metadata = yaml.safe_load(f)
|
| 12 |
except:
|
| 13 |
raise FileNotFoundError("Failed to load file having model metadata")
|
|
|
|
| 16 |
def load_model():
|
| 17 |
""" Loads ML model from location path and returns the model. """
|
| 18 |
try:
|
| 19 |
+
with open(Path("model/python_model.pkl"), "rb") as f:
|
| 20 |
model = joblib.load(f)
|
| 21 |
return model
|
| 22 |
|