|
|
"""Minimal configuration.""" |
|
|
|
|
|
import os |
|
|
from dataclasses import dataclass |
|
|
|
|
|
|
|
|
@dataclass |
|
|
class Paths: |
|
|
"""File paths.""" |
|
|
input_folder: str |
|
|
output_folder: str |
|
|
boundingbox_dir: str = "" |
|
|
|
|
|
def __post_init__(self): |
|
|
self.input_folder = os.path.abspath(self.input_folder) |
|
|
self.output_folder = os.path.abspath(self.output_folder) |
|
|
|
|
|
|
|
|
@dataclass |
|
|
class OutputSettings: |
|
|
"""Output settings.""" |
|
|
save_images: bool = True |
|
|
plot_dpi: int = 100 |
|
|
|
|
|
|
|
|
class Config: |
|
|
"""Minimal config.""" |
|
|
|
|
|
def __init__(self): |
|
|
self.paths = Paths(input_folder="", output_folder="") |
|
|
self.output = OutputSettings() |
|
|
|
|
|
def get_device(self) -> str: |
|
|
"""Get device.""" |
|
|
import torch |
|
|
return "cuda" if torch.cuda.is_available() else "cpu" |
|
|
|
|
|
def validate(self) -> bool: |
|
|
"""Validate.""" |
|
|
if self.paths.input_folder and not os.path.exists(self.paths.input_folder): |
|
|
raise FileNotFoundError(f"Input folder not found: {self.paths.input_folder}") |
|
|
return True |