Spaces:
Sleeping
Sleeping
File size: 3,072 Bytes
47488ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
import os
from kidney_classification.constants import *
from kidney_classification.utils.common import read_yaml, create_directories, save_json
from kidney_classification.entity.config_entity import (
DataIngestionConfig,
PrepareBaseModelConfig,
TrainingConfig,
EvaluationConfig,
)
class ConfigurationManager:
def __init__(
self, config_filepath=CONFIG_FILE_PATH, params_filepath=PARAMS_FILE_PATH
):
self.config = read_yaml(config_filepath)
self.params = read_yaml(params_filepath)
create_directories([self.config.artifacts_root])
def get_data_ingestion_config(self) -> DataIngestionConfig:
config = self.config.data_ingestion
create_directories([config.root_dir])
data_ingestion_config = DataIngestionConfig(
root_dir=config.root_dir,
source_URL=config.source_URL,
local_data_file=config.local_data_file,
unzip_dir=config.unzip_dir,
)
return data_ingestion_config
def get_prepare_base_model_config(self) -> PrepareBaseModelConfig:
config = self.config.prepare_base_model
create_directories([config.root_dir])
prepare_base_model_config = PrepareBaseModelConfig(
root_dir=Path(config.root_dir),
base_model_path=Path(config.base_model_path),
updated_base_model_path=Path(config.updated_base_model_path),
params_image_size=self.params.IMAGE_SIZE,
params_include_top=self.params.INCLUDE_TOP,
params_weights=self.params.WEIGHTS,
params_classes=self.params.CLASSES,
)
return prepare_base_model_config
def get_training_config(self) -> TrainingConfig:
training = self.config.training
prepare_base_model = self.config.prepare_base_model
params = self.params
training_data = os.path.join(
self.config.data_ingestion.unzip_dir,
"CT-KIDNEY-DATASET-Normal-Cyst-Tumor-Stone",
)
create_directories([Path(training.root_dir)])
training_config = TrainingConfig(
root_dir=Path(training.root_dir),
trained_model_path=Path(training.trained_model_path),
updated_base_model_path=Path(prepare_base_model.updated_base_model_path),
training_data=Path(training_data),
params_epochs=params.EPOCHS,
params_batch_size=params.BATCH_SIZE,
params_image_size=params.IMAGE_SIZE,
)
return training_config
def get_evaluation_config(self) -> EvaluationConfig:
eval_config = EvaluationConfig(
path_of_model="artifacts/training/model.h5",
training_data="artifacts/data_ingestion/CT-KIDNEY-DATASET-Normal-Cyst-Tumor-Stone",
mlflow_uri="https://dagshub.com/Shrey-patel-07/Kidney-Disease-Classifcation.mlflow",
all_params=self.params,
params_image_size=self.params.IMAGE_SIZE,
params_batch_size=self.params.BATCH_SIZE,
)
return eval_config
|