File size: 2,578 Bytes
69066c5 |
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 78 79 80 81 82 83 84 85 86 87 88 |
"""
Configuration file for NeuroSAM 3 application.
Contains all constants, default values, and configuration settings.
"""
import os
from typing import Optional
# Model Configuration
SAM_MODEL_ID: str = "facebook/sam3"
HF_TOKEN: Optional[str] = os.getenv("HF_TOKEN")
# Segmentation Thresholds (optimized for medical imaging)
DEFAULT_THRESHOLD: float = 0.1 # Detection confidence threshold
DEFAULT_MASK_THRESHOLD: float = 0.0 # Mask binarization threshold
# Threshold ranges for validation
MIN_THRESHOLD: float = 0.0
MAX_THRESHOLD: float = 1.0
MIN_MASK_THRESHOLD: float = 0.0
MAX_MASK_THRESHOLD: float = 1.0
# File Configuration
MAX_FILE_SIZE_MB: int = 500 # Maximum file size in MB
MAX_FILE_SIZE_BYTES: int = MAX_FILE_SIZE_MB * 1024 * 1024
ALLOWED_IMAGE_EXTENSIONS: tuple = ('.dcm', '.png', '.jpg', '.jpeg', '.tiff', '.tif')
ALLOWED_ANNOTATION_EXTENSIONS: tuple = ('.json', '.nii', '.nii.gz')
# Demo File Configuration
DEMO_DICOM_PATH: str = "demo_brain_mri.dcm"
# Cache Configuration
MAX_CACHE_SIZE: int = 100 # Maximum number of cached results
CACHE_TTL_SECONDS: int = 3600 # Cache time-to-live in seconds
# Image Processing Configuration
DEFAULT_COLORMAP: str = "spring"
DEFAULT_TRANSPARENCY: float = 0.5
DEFAULT_BRIGHTNESS: float = 1.0
DEFAULT_CONTRAST: float = 1.0
# CT Windowing Presets
CT_WINDOW_PRESETS: dict = {
"Brain (Grey Matter)": {"level": 40, "width": 80},
"Bone (Skull)": {"level": 500, "width": 2000},
"Default": {"level": 40, "width": 400},
}
# Multi-Mask Configuration
MIN_NUM_MASKS: int = 1
MAX_NUM_MASKS: int = 5
DEFAULT_NUM_MASKS: int = 3
# AMG (Automatic Mask Generator) Configuration
DEFAULT_POINTS_PER_SIDE: int = 32
MIN_POINTS_PER_SIDE: int = 8
MAX_POINTS_PER_SIDE: int = 64
DEFAULT_MIN_MASK_AREA: int = 100
# Advanced Transforms Configuration
DEFAULT_TARGET_SIZE: int = 1024
MIN_TARGET_SIZE: int = 256
MAX_TARGET_SIZE: int = 2048
DEFAULT_CLAHE_CLIP_LIMIT: float = 2.0
# Edge Detection Configuration
DEFAULT_EDGE_THRESHOLD: float = 0.1
DEFAULT_DILATION_SIZE: int = 3
# Coordinate Validation
MAX_COORDINATE_VALUE: int = 10000 # Reasonable upper limit for image coordinates
# GPU Configuration
GPU_DURATION_SECONDS: int = 60 # Duration for GPU allocation
# Logging Configuration
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
LOG_FORMAT: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
LOG_FILE: Optional[str] = os.getenv("LOG_FILE") # Optional log file path
# Output Configuration
OUTPUT_DPI: int = 100
OUTPUT_FORMAT: str = "PNG"
# NIFTI Export Configuration
NIFTI_DEFAULT_NAME: str = "segmentation"
|