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

Update app/configs.py

Browse files
Files changed (1) hide show
  1. app/configs.py +33 -27
app/configs.py CHANGED
@@ -1,83 +1,89 @@
1
  import mlflow
2
- import mlflow.pyfunc
3
 
4
  from pathlib import Path
5
  from typing import Dict, Any, List
6
 
 
 
 
7
 
8
  MLFLOW_URI = "https://omarelrayes-mlflow-server.hf.space"
 
9
 
10
- mlflow.set_tracking_uri(
11
- MLFLOW_URI
12
- )
13
 
 
14
 
15
- CLASSIFICATION_MODEL_URI = (
16
- "https://omarelrayes-mlflow-server.hf.space/"
17
- "artifacts/1/efcf3f12eacc409daffe6a50888fa759/artifacts/model"
18
- )
19
-
20
-
21
- SEGMENTATION_MODEL_URI = (
22
- "https://omarelrayes-mlflow-server.hf.space/"
23
- "artifacts/1/85a78da18bc94263848e61825b9e5104/artifacts/model"
24
- )
25
 
 
 
 
26
 
27
  _classification_model = None
28
  _segmentation_model = None
29
 
30
 
 
 
 
31
 
32
  def get_classification_model():
33
-
34
  global _classification_model
35
 
36
  if _classification_model is None:
37
-
38
  print("Loading Classification Model...")
39
 
40
- _classification_model = mlflow.pyfunc.load_model(
41
  CLASSIFICATION_MODEL_URI
42
  )
43
 
44
- print("Classification Loaded")
45
 
46
  return _classification_model
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"
75
  }
76
 
 
 
 
 
77
  request_history: List[Dict[str, Any]] = []
78
 
79
 
80
- from pathlib import Path
 
 
81
 
82
  STORAGE_DIR = Path("storage")
83
  IMAGES_DIR = STORAGE_DIR / "images"
 
1
  import mlflow
2
+ import mlflow.tensorflow
3
 
4
  from pathlib import Path
5
  from typing import Dict, Any, List
6
 
7
+ # ======================
8
+ # MLflow Setup
9
+ # ======================
10
 
11
  MLFLOW_URI = "https://omarelrayes-mlflow-server.hf.space"
12
+ mlflow.set_tracking_uri(MLFLOW_URI)
13
 
14
+ # ======================
15
+ # Model URIs
16
+ # ======================
17
 
18
+ CLASSIFICATION_MODEL_URI = "runs:/7766854bcd074c8e856aea7c47680bf4/model"
19
 
20
+ SEGMENTATION_MODEL_URI = "runs:/35f0bea9bf774ed59f2298a897c8cdf5/model"
 
 
 
 
 
 
 
 
 
21
 
22
+ # ======================
23
+ # Lazy Loaded Models
24
+ # ======================
25
 
26
  _classification_model = None
27
  _segmentation_model = None
28
 
29
 
30
+ # ======================
31
+ # Classification Model
32
+ # ======================
33
 
34
  def get_classification_model():
 
35
  global _classification_model
36
 
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():
 
54
  global _segmentation_model
55
 
 
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
 
67
 
68
+ # ======================
69
+ # Classes
70
+ # ======================
71
 
72
  model_classes = {
73
  0: "benign",
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")
89
  IMAGES_DIR = STORAGE_DIR / "images"