Omarelrayes commited on
Commit
f4abeba
·
verified ·
1 Parent(s): ad46df7

Update app/configs.py

Browse files
Files changed (1) hide show
  1. app/configs.py +9 -13
app/configs.py CHANGED
@@ -1,5 +1,5 @@
1
  import mlflow
2
- import mlflow.tensorflow
3
 
4
  from pathlib import Path
5
  from typing import Dict, Any, List
@@ -20,7 +20,7 @@ CLASSIFICATION_MODEL_URI = "runs:/7766854bcd074c8e856aea7c47680bf4/model"
20
  SEGMENTATION_MODEL_URI = "runs:/35f0bea9bf774ed59f2298a897c8cdf5/model"
21
 
22
  # ======================
23
- # Lazy Loaded Models
24
  # ======================
25
 
26
  _classification_model = None
@@ -28,7 +28,7 @@ _segmentation_model = None
28
 
29
 
30
  # ======================
31
- # Classification Model
32
  # ======================
33
 
34
  def get_classification_model():
@@ -37,17 +37,17 @@ def get_classification_model():
37
  if _classification_model is None:
38
  print("Loading Classification Model...")
39
 
40
- _classification_model = mlflow.tensorflow.load_model(
41
  CLASSIFICATION_MODEL_URI
42
  )
43
 
44
- print("Classification Model Loaded Successfully")
45
 
46
  return _classification_model
47
 
48
 
49
  # ======================
50
- # Segmentation Model
51
  # ======================
52
 
53
  def get_segmentation_model():
@@ -56,11 +56,11 @@ def get_segmentation_model():
56
  if _segmentation_model is None:
57
  print("Loading Segmentation Model...")
58
 
59
- _segmentation_model = mlflow.tensorflow.load_model(
60
  SEGMENTATION_MODEL_URI
61
  )
62
 
63
- print("Segmentation Model Loaded Successfully")
64
 
65
  return _segmentation_model
66
 
@@ -74,15 +74,11 @@ model_classes = {
74
  1: "malignant"
75
  }
76
 
77
- # ======================
78
- # Request History
79
- # ======================
80
-
81
  request_history: List[Dict[str, Any]] = []
82
 
83
 
84
  # ======================
85
- # Storage Setup
86
  # ======================
87
 
88
  STORAGE_DIR = Path("storage")
 
1
  import mlflow
2
+ import mlflow.pyfunc
3
 
4
  from pathlib import Path
5
  from typing import Dict, Any, List
 
20
  SEGMENTATION_MODEL_URI = "runs:/35f0bea9bf774ed59f2298a897c8cdf5/model"
21
 
22
  # ======================
23
+ # Cached models
24
  # ======================
25
 
26
  _classification_model = None
 
28
 
29
 
30
  # ======================
31
+ # Classification
32
  # ======================
33
 
34
  def get_classification_model():
 
37
  if _classification_model is None:
38
  print("Loading Classification Model...")
39
 
40
+ _classification_model = mlflow.pyfunc.load_model(
41
  CLASSIFICATION_MODEL_URI
42
  )
43
 
44
+ print("Classification Model Loaded")
45
 
46
  return _classification_model
47
 
48
 
49
  # ======================
50
+ # Segmentation
51
  # ======================
52
 
53
  def get_segmentation_model():
 
56
  if _segmentation_model is None:
57
  print("Loading Segmentation Model...")
58
 
59
+ _segmentation_model = mlflow.pyfunc.load_model(
60
  SEGMENTATION_MODEL_URI
61
  )
62
 
63
+ print("Segmentation Model Loaded")
64
 
65
  return _segmentation_model
66
 
 
74
  1: "malignant"
75
  }
76
 
 
 
 
 
77
  request_history: List[Dict[str, Any]] = []
78
 
79
 
80
  # ======================
81
+ # Storage
82
  # ======================
83
 
84
  STORAGE_DIR = Path("storage")