-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
56 lines (47 loc) · 1.69 KB
/
config.py
File metadata and controls
56 lines (47 loc) · 1.69 KB
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
import os
from typing import Dict, Any
class Config:
"""Application configuration management"""
# Model configuration
MODEL_NAME = "yolov5s"
MODEL_CONFIDENCE_THRESHOLD = 0.5
MODEL_IMAGE_SIZE = 640
# API configuration
API_TITLE = "PCB Defect Detection API"
API_DESCRIPTION = "AI-powered system for detecting defects in PCB images"
API_VERSION = "1.0.0"
MAX_BATCH_SIZE = 10
MAX_FILE_SIZE_MB = 50
# Rate limiting
RATE_LIMIT_SINGLE = "100/minute"
RATE_LIMIT_BATCH = "20/minute"
# Logging configuration
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
LOG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
# Paths
MODEL_PATH = os.getenv("MODEL_PATH", "models/trained_model.pt")
DATA_PATH = "data"
# Performance settings
INFERENCE_TIMEOUT = 30
ENABLE_GPU = os.getenv("ENABLE_GPU", "false").lower() == "true"
@classmethod
def get_model_config(cls) -> Dict[str, Any]:
"""Get model-specific configuration"""
return {
"name": cls.MODEL_NAME,
"confidence_threshold": cls.MODEL_CONFIDENCE_THRESHOLD,
"image_size": cls.MODEL_IMAGE_SIZE,
"path": cls.MODEL_PATH,
"enable_gpu": cls.ENABLE_GPU
}
@classmethod
def get_api_config(cls) -> Dict[str, Any]:
"""Get API-specific configuration"""
return {
"title": cls.API_TITLE,
"description": cls.API_DESCRIPTION,
"version": cls.API_VERSION,
"max_batch_size": cls.MAX_BATCH_SIZE,
"max_file_size_mb": cls.MAX_FILE_SIZE_MB,
"inference_timeout": cls.INFERENCE_TIMEOUT
}