Spaces:
Sleeping
Sleeping
Update app/configs.py
Browse files- app/configs.py +39 -13
app/configs.py
CHANGED
|
@@ -1,48 +1,74 @@
|
|
| 1 |
import mlflow
|
| 2 |
import mlflow.pyfunc
|
| 3 |
-
from typing import Optional
|
|
|
|
| 4 |
|
| 5 |
MLFLOW_URI = "https://omarelrayes-mlflow-server.hf.space"
|
| 6 |
|
| 7 |
-
mlflow.set_tracking_uri(
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
CLASSIFICATION_MODEL_URI = "runs:/efcf3f12eacc409daffe6a50888fa759/model"
|
| 10 |
-
SEGMENTATION_MODEL_URI = "runs:/d5de5322822b45349b7bd311e747c794/model"
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
local_path = mlflow.artifacts.download_artifacts(uri)
|
| 20 |
|
| 21 |
-
print(f"Model downloaded to: {local_path}")
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
def get_classification_model():
|
|
|
|
| 27 |
global _classification_model
|
| 28 |
|
|
|
|
| 29 |
if _classification_model is None:
|
|
|
|
| 30 |
print("Loading Classification Model...")
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
return _classification_model
|
| 34 |
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
def get_segmentation_model():
|
|
|
|
| 37 |
global _segmentation_model
|
| 38 |
|
|
|
|
| 39 |
if _segmentation_model is None:
|
|
|
|
| 40 |
print("Loading Segmentation Model...")
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
return _segmentation_model
|
| 44 |
|
| 45 |
|
|
|
|
|
|
|
| 46 |
model_classes = {
|
| 47 |
0: "benign",
|
| 48 |
1: "malignant"
|
|
|
|
| 1 |
import mlflow
|
| 2 |
import mlflow.pyfunc
|
| 3 |
+
from typing import Optional
|
| 4 |
+
|
| 5 |
|
| 6 |
MLFLOW_URI = "https://omarelrayes-mlflow-server.hf.space"
|
| 7 |
|
| 8 |
+
mlflow.set_tracking_uri(
|
| 9 |
+
MLFLOW_URI
|
| 10 |
+
)
|
| 11 |
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
CLASSIFICATION_MODEL_URI = (
|
| 14 |
+
"runs:/efcf3f12eacc409daffe6a50888fa759/model"
|
| 15 |
+
)
|
| 16 |
|
| 17 |
|
| 18 |
+
SEGMENTATION_MODEL_URI = (
|
| 19 |
+
"runs:/d5de5322822b45349b7bd311e747c794/model"
|
| 20 |
+
)
|
| 21 |
|
|
|
|
| 22 |
|
|
|
|
| 23 |
|
| 24 |
+
_classification_model = None
|
| 25 |
+
_segmentation_model = None
|
| 26 |
+
|
| 27 |
|
| 28 |
|
| 29 |
def get_classification_model():
|
| 30 |
+
|
| 31 |
global _classification_model
|
| 32 |
|
| 33 |
+
|
| 34 |
if _classification_model is None:
|
| 35 |
+
|
| 36 |
print("Loading Classification Model...")
|
| 37 |
+
|
| 38 |
+
_classification_model = mlflow.pyfunc.load_model(
|
| 39 |
+
CLASSIFICATION_MODEL_URI
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
print("Classification Model Loaded")
|
| 43 |
+
|
| 44 |
|
| 45 |
return _classification_model
|
| 46 |
|
| 47 |
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
def get_segmentation_model():
|
| 52 |
+
|
| 53 |
global _segmentation_model
|
| 54 |
|
| 55 |
+
|
| 56 |
if _segmentation_model is None:
|
| 57 |
+
|
| 58 |
print("Loading Segmentation Model...")
|
| 59 |
+
|
| 60 |
+
_segmentation_model = mlflow.pyfunc.load_model(
|
| 61 |
+
SEGMENTATION_MODEL_URI
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
print("Segmentation Model Loaded")
|
| 65 |
+
|
| 66 |
|
| 67 |
return _segmentation_model
|
| 68 |
|
| 69 |
|
| 70 |
+
|
| 71 |
+
|
| 72 |
model_classes = {
|
| 73 |
0: "benign",
|
| 74 |
1: "malignant"
|