-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create config boilerplate for apps (#11)
- Loading branch information
Showing
11 changed files
with
135 additions
and
23 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
src/spira_training/apps/feature_engineering/configs/audio_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from pathlib import Path | ||
|
||
from pydantic import BaseModel | ||
|
||
class DatasetPaths(BaseModel): | ||
patients_csv: Path | ||
controls_csv: Path | ||
noises_csv: Path | ||
|
||
class AudioConfig(BaseModel): | ||
dataset_paths: DatasetPaths | ||
hop_length: int | ||
normalize: bool |
31 changes: 31 additions & 0 deletions
31
src/spira_training/apps/feature_engineering/configs/audio_feature_transformer_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class AudioFeatureTransformerOptions(BaseModel): | ||
use_noise: bool | ||
use_overlapping: bool | ||
use_padding: bool | ||
use_mixture: bool | ||
|
||
class NoisyAudioFeatureTransformerConfig(BaseModel): | ||
num_noise_control: int | ||
num_noise_patient: int | ||
noise_max_amp: float | ||
noise_min_amp: float | ||
|
||
class OverlappedAudioFeatureTransformerConfig(BaseModel): | ||
window_length: int | ||
step_size: int | ||
|
||
class MixedAudioFeatureTransformerConfig(BaseModel): | ||
alpha: float | ||
beta: float | ||
|
||
class AudioFeatureTransformersCollection(BaseModel): | ||
noisy_audio: NoisyAudioFeatureTransformerConfig | ||
overlapped_audio: OverlappedAudioFeatureTransformerConfig | ||
mixed_audio: MixedAudioFeatureTransformerConfig | ||
|
||
class AudioFeatureTransformerConfig(BaseModel): | ||
options: AudioFeatureTransformerOptions | ||
audio_feature_transformers: AudioFeatureTransformersCollection |
43 changes: 43 additions & 0 deletions
43
src/spira_training/apps/feature_engineering/configs/audio_processor_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class AudioProcessorType(BaseModel): | ||
MFCC = "mfcc" | ||
SPECTROGRAM = "spectrogram" | ||
MELSPECTROGRAM = "melspectrogram" | ||
|
||
class MFCCAudioProcessorConfig: | ||
sample_rate: int | ||
num_mels: int | ||
num_mfcc: int | ||
log_mels: bool | ||
n_fft: int | ||
win_length: int | ||
|
||
class SpectrogramAudioProcessorConfig: | ||
sample_rate: int | ||
num_mels: int | ||
mel_fmin: float | ||
mel_fmax: None | ||
num_mfcc: int | ||
log_mels: bool | ||
n_fft: int | ||
num_freq: int | ||
win_length: int | ||
|
||
class MelspectrogramAudioProcessorConfig: | ||
sample_rate: int | ||
num_mels: int | ||
mel_fmin: float | ||
mel_fmax: None | ||
num_mfcc: int | ||
log_mels: bool | ||
n_fft: int | ||
num_freq: int | ||
win_length: int | ||
|
||
class AudioProcessorConfig(BaseModel): | ||
feature_type: AudioProcessorType | ||
mfcc: MFCCAudioProcessorConfig | ||
spectrogram: SpectrogramAudioProcessorConfig | ||
melspectrogram: MelspectrogramAudioProcessorConfig |
10 changes: 10 additions & 0 deletions
10
src/spira_training/apps/feature_engineering/configs/feature_engineering_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from pydantic import BaseModel | ||
|
||
from audio_config import AudioConfig | ||
from audio_processor_config import AudioProcessorConfig | ||
from audio_feature_transformer_config import AudioFeatureTransformerConfig | ||
|
||
class FeatureEngineeringConfig(BaseModel): | ||
audio: AudioConfig | ||
audio_processor: AudioProcessorConfig | ||
audio_feature_transformer: AudioFeatureTransformerConfig |
8 changes: 3 additions & 5 deletions
8
...training/apps/feature_engineering/main.py → ...eature_engineering/feature_engineering.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
from src.spira_training.apps.feature_engineering.app.app import App | ||
from src.spira_training.shared.core.services.feature_engineering_service import FeatureEngineeringService | ||
from src.spira_training.shared.core.services.randomizer import Randomizer | ||
from src.spira_training.shared.ports.config_loader import ConfigLoader | ||
from src.spira_training.shared.ports.dataset_repository import DatasetRepository | ||
|
||
|
||
def main(): | ||
config = ConfigLoader.load() | ||
randomizer = Randomizer.initialize_random() | ||
dataset_repository = DatasetRepository() | ||
service = FeatureEngineeringService(config, randomizer, dataset_repository) | ||
|
||
app = App(config, randomizer, dataset_repository) | ||
app.execute() | ||
service.execute() | ||
|
||
if __name__ == "__main__": | ||
main() |
2 changes: 2 additions & 0 deletions
2
src/spira_training/apps/model_evaluation/model_evaluation_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ModelEvaluationConfig(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
src/spira_training/apps/model_publish/model_publish_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ModelPublishConfig: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
from src.spira_training.apps.feature_engineering.configs.feature_engineering_config import FeatureEngineeringConfig | ||
from src.spira_training.apps.model_evaluation.model_evaluation_config import ModelEvaluationConfig | ||
from src.spira_training.apps.model_publish.model_publish_config import ModelPublishConfig | ||
|
||
|
||
class Config: | ||
pass | ||
feature_engineering_config: FeatureEngineeringConfig | ||
model_trainer_config: ModelTrainerConfig | ||
model_evaluation_config: ModelEvaluationConfig | ||
model_publish_config: ModelPublishConfig |
22 changes: 22 additions & 0 deletions
22
src/spira_training/shared/core/services/feature_engineering_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from src.spira_training.apps.feature_engineering.configs.feature_engineering_config import FeatureEngineeringConfig | ||
from src.spira_training.shared.core.interfaces.random import Random | ||
from src.spira_training.shared.ports import dataset_repository | ||
from src.spira_training.shared.ports.dataset_repository import DatasetRepository | ||
|
||
class FeatureEngineeringService: | ||
def __init__(self, config: FeatureEngineeringConfig, randomizer: Random, dataset_repository: DatasetRepository): | ||
self.config = config | ||
self.randomizer = randomizer | ||
self.dataset_repository = dataset_repository | ||
|
||
def execute(self) -> None: | ||
patients_inputs, controls_inputs, noises = self._load_data(self.config) | ||
dataset = self._generate_dataset(self.config, self.randomizer, patients_inputs, controls_inputs, noises) | ||
dataset_repository.save_dataset(dataset, self.config.paths.dataset) | ||
|
||
def _load_data(self, config: FeatureEngineeringConfig): | ||
pass | ||
|
||
def _generate_dataset(self): | ||
pass | ||
|