|
|
import os
|
|
|
import logging
|
|
|
from pathlib import Path
|
|
|
|
|
|
class Config:
|
|
|
"""Configuration management for SmartHeal application"""
|
|
|
|
|
|
def __init__(self):
|
|
|
"""Initialize configuration with environment variables and defaults"""
|
|
|
|
|
|
|
|
|
self.MYSQL_CONFIG = {
|
|
|
"host": os.getenv("MYSQL_HOST", "sg-nme-web545.main-hosting.eu"),
|
|
|
"user": os.getenv("MYSQL_USER", "u124249738_SmartHealApp"),
|
|
|
"password": os.getenv("MYSQL_PASSWORD", "I^4y1b12y"),
|
|
|
"database": os.getenv("MYSQL_DATABASE", "u124249738_SmartHealAppDB"),
|
|
|
"port": int(os.getenv("MYSQL_PORT", 3306))
|
|
|
}
|
|
|
|
|
|
|
|
|
self.UPLOADS_DIR = os.getenv("UPLOADS_DIR", "uploads")
|
|
|
self.MODELS_DIR = os.getenv("MODELS_DIR", "models")
|
|
|
|
|
|
|
|
|
self.HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
self.OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
|
|
|
|
|
|
self.YOLO_MODEL_PATH = os.getenv("YOLO_MODEL_PATH", "src/best.pt")
|
|
|
self.SEG_MODEL_PATH = os.getenv("SEG_MODEL_PATH", "src/segmentation_model.h5")
|
|
|
|
|
|
self.MEDGEMMA_MODEL = os.getenv("MEDGEMMA_MODEL", "google/medgemma-4b-it")
|
|
|
self.WOUND_CLASSIFICATION_MODEL = os.getenv("WOUND_CLASSIFICATION_MODEL", "Hemg/Wound-classification")
|
|
|
self.EMBEDDING_MODEL = os.getenv("EMBEDDING_MODEL", "sentence-transformers/all-MiniLM-L6-v2")
|
|
|
|
|
|
|
|
|
self.PIXELS_PER_CM = int(os.getenv("PIXELS_PER_CM", "37"))
|
|
|
self.MAX_NEW_TOKENS = int(os.getenv("MAX_NEW_TOKENS", "512"))
|
|
|
self.DATASET_ID = os.getenv("DATASET_ID", "")
|
|
|
self.GUIDELINE_PDFS = [
|
|
|
os.path.join("src", "eHealth in Wound Care.pdf"),
|
|
|
os.path.join("src", "IWGDF Guideline.pdf"),
|
|
|
os.path.join("src", "evaluation.pdf")
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
self.DEBUG = os.getenv("DEBUG", "False").lower() == "true"
|
|
|
self.LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
|
|
|
|
|
|
|
|
|
self._create_directories()
|
|
|
|
|
|
logging.info("✅ Configuration initialized")
|
|
|
|
|
|
def _create_directories(self):
|
|
|
"""Create required directories if they don't exist"""
|
|
|
directories = [self.UPLOADS_DIR, self.MODELS_DIR]
|
|
|
|
|
|
for directory in directories:
|
|
|
if not os.path.exists(directory):
|
|
|
os.makedirs(directory, exist_ok=True)
|
|
|
logging.info(f"Created directory: {directory}")
|
|
|
|
|
|
def get_mysql_config(self):
|
|
|
"""Get MySQL configuration dictionary"""
|
|
|
return self.MYSQL_CONFIG.copy()
|
|
|
|
|
|
def get_upload_path(self, filename):
|
|
|
"""Get full path for uploaded file"""
|
|
|
return os.path.join(self.UPLOADS_DIR, filename)
|
|
|
|
|
|
def get_model_path(self, model_name):
|
|
|
"""Get full path for model file"""
|
|
|
return os.path.join(self.MODELS_DIR, model_name)
|
|
|
|