dyagnosys-free / app /config.py
vitorcalvi's picture
1
18c46ab
# config.py
"""
File: config.py
Description: Configuration file for the AI-Driven Multimodal Emotional State Analysis application.
License: MIT License
"""
import toml
from typing import Dict
from types import SimpleNamespace
def flatten_dict(prefix: str, d: Dict) -> Dict:
"""
Recursively flattens a nested dictionary, concatenating keys with underscores.
"""
result = {}
for k, v in d.items():
if isinstance(v, dict):
result.update(flatten_dict(f"{prefix}{k}_", v))
else:
result[f"{prefix}{k}"] = v
return result
# Load configuration from 'config.toml' if it exists
try:
config = toml.load("config.toml")
except FileNotFoundError:
config = {}
print("Warning: 'config.toml' not found. Using default configuration.")
# Flatten the configuration dictionary
config_data_dict = flatten_dict("", config)
# Convert the dictionary to a SimpleNamespace for easy attribute access
config_data = SimpleNamespace(**config_data_dict)
# Define emotion labels
DICT_EMO = {
0: "Neutral",
1: "Happiness",
2: "Sadness",
3: "Surprise",
4: "Fear",
5: "Disgust",
6: "Anger",
}
# Define colors for plotting or UI elements
COLORS = {
0: 'blue',
1: 'orange',
2: 'green',
3: 'red',
4: 'purple',
5: 'brown',
6: 'pink'
}