WebashalarForML commited on
Commit
91f8b58
·
verified ·
1 Parent(s): 6c4d91a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -16
app.py CHANGED
@@ -48,6 +48,8 @@ UPLOAD_FOLDER = "uploads/"
48
  DATA_FOLDER = "data/"
49
  MODEL_FOLDER = "models/"
50
 
 
 
51
  # Define the model directory and label encoder directory
52
  MODEL_DIR = r'./Model'
53
  LABEL_ENCODER_DIR = r'./Label_encoders' # Renamed for clarity
@@ -77,37 +79,44 @@ os.makedirs(app.config['MODEL_FOLDER'], exist_ok=True)
77
  # ------------------------------
78
 
79
  # Prediction analysis models loaded from Hugging Face.
80
- file_path_1 = hf_hub_download(
81
  repo_id="WebashalarForML/Diamond_model_",
82
  filename="models_list/mkble/StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl",
83
  cache_dir=MODEL_FOLDER
84
  )
85
- with open(file_path_1, "rb") as f:
86
- makable_model = pickle.load(f)
 
87
 
88
- file_path_2 = hf_hub_download(
89
  repo_id="WebashalarForML/Diamond_model_",
90
  filename="models_list/grd/StackingRegressor_best_pipeline_grd_0_to_1.01.pkl",
91
  cache_dir=MODEL_FOLDER
92
  )
93
- with open(file_path_2, "rb") as f:
94
- grade_model = pickle.load(f)
 
 
95
 
96
- file_path_3 = hf_hub_download(
97
  repo_id="WebashalarForML/Diamond_model_",
98
  filename="models_list/bygrad/StackingRegressor_best_pipeline_bygrad_0_to_1.01.pkl",
99
  cache_dir=MODEL_FOLDER
100
  )
101
- with open(file_path_3, "rb") as f:
102
- bygrade_model = pickle.load(f)
 
 
103
 
104
- file_path_4 = hf_hub_download(
105
  repo_id="WebashalarForML/Diamond_model_",
106
  filename="models_list/gia/StackingRegressor_best_pipeline_gia_0_to_1.01.pkl",
107
  cache_dir=MODEL_FOLDER
108
  )
109
- with open(file_path_4, "rb") as f:
110
- gia_model = pickle.load(f)
 
 
111
 
112
 
113
  print("makable_model type:", type(makable_model))
@@ -115,10 +124,10 @@ print("grade_model type:", type(grade_model))
115
  print("bygrade_model type:", type(bygrade_model))
116
  print("gia_model type:", type(gia_model))
117
 
118
- gia_model = load("models/StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl")
119
- grade_model = load("models/StackingRegressor_best_pipeline_grd_0_to_1.01.pkl")
120
- bygrade_model = load("models/StackingRegressor_best_pipeline_bygrad_0_to_1.01.pkl")
121
- makable_model = load("models/StackingRegressor_best_pipeline_gia_0_to_1.01.pkl")
122
 
123
 
124
  # Classification models loaded using joblib.
 
48
  DATA_FOLDER = "data/"
49
  MODEL_FOLDER = "models/"
50
 
51
+ os.makedirs(MODEL_FOLDER, exist_ok=True)
52
+
53
  # Define the model directory and label encoder directory
54
  MODEL_DIR = r'./Model'
55
  LABEL_ENCODER_DIR = r'./Label_encoders' # Renamed for clarity
 
79
  # ------------------------------
80
 
81
  # Prediction analysis models loaded from Hugging Face.
82
+ src_path = hf_hub_download(
83
  repo_id="WebashalarForML/Diamond_model_",
84
  filename="models_list/mkble/StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl",
85
  cache_dir=MODEL_FOLDER
86
  )
87
+ dst_path = os.path.join(MODEL_FOLDER, "StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl")
88
+ shutil.copy(src_path, dst_path)
89
+ makable_model = load(dst_path)
90
 
91
+ src_path = hf_hub_download(
92
  repo_id="WebashalarForML/Diamond_model_",
93
  filename="models_list/grd/StackingRegressor_best_pipeline_grd_0_to_1.01.pkl",
94
  cache_dir=MODEL_FOLDER
95
  )
96
+ dst_path = os.path.join(MODEL_FOLDER, "StackingRegressor_best_pipeline_grd_0_to_1.01.pkl")
97
+ shutil.copy(src_path, dst_path)
98
+ grade_model = load(dst_path)
99
+
100
 
101
+ src_path = hf_hub_download(
102
  repo_id="WebashalarForML/Diamond_model_",
103
  filename="models_list/bygrad/StackingRegressor_best_pipeline_bygrad_0_to_1.01.pkl",
104
  cache_dir=MODEL_FOLDER
105
  )
106
+ dst_path = os.path.join(MODEL_FOLDER, "StackingRegressor_best_pipeline_bygrad_0_to_1.01.pkl")
107
+ shutil.copy(src_path, dst_path)
108
+ bygrade_model = load(dst_path)
109
+
110
 
111
+ src_path = hf_hub_download(
112
  repo_id="WebashalarForML/Diamond_model_",
113
  filename="models_list/gia/StackingRegressor_best_pipeline_gia_0_to_1.01.pkl",
114
  cache_dir=MODEL_FOLDER
115
  )
116
+ dst_path = os.path.join(MODEL_FOLDER, "StackingRegressor_best_pipeline_gia_0_to_1.01.pkl")
117
+ shutil.copy(src_path, dst_path)
118
+ gia_model = load(dst_path)
119
+
120
 
121
 
122
  print("makable_model type:", type(makable_model))
 
124
  print("bygrade_model type:", type(bygrade_model))
125
  print("gia_model type:", type(gia_model))
126
 
127
+ #gia_model = load("models/StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl")
128
+ #grade_model = load("models/StackingRegressor_best_pipeline_grd_0_to_1.01.pkl")
129
+ #bygrade_model = load("models/StackingRegressor_best_pipeline_bygrad_0_to_1.01.pkl")
130
+ #makable_model = load("models/StackingRegressor_best_pipeline_gia_0_to_1.01.pkl")
131
 
132
 
133
  # Classification models loaded using joblib.