File size: 3,137 Bytes
185c377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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"""
        
        # Database configuration
        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))
        }
        
        # Application directories
        self.UPLOADS_DIR = os.getenv("UPLOADS_DIR", "uploads")
        self.MODELS_DIR = os.getenv("MODELS_DIR", "models")
        
        # AI/ML configuration
        self.HF_TOKEN = os.getenv("HF_TOKEN")
        self.OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
        
        # AI Model Configuration
        # AI Model Configuration
        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")
        
        # AI Processing Configuration
        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")
        ]

        
        # Application settings
        self.DEBUG = os.getenv("DEBUG", "False").lower() == "true"
        self.LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
        
        # Create required directories
        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)