| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- from pathlib import Path
- # 定义一个模型的配置结构
- class CardModelConfig:
- pth_path: str
- class_dict: dict
- img_size: dict
- confidence: float
- input_channels: int
- class Settings:
- API_prefix: str = "/api/card_inference"
- BASE_PATH = Path(__file__).parent.parent.absolute()
- # 使用一个字典来管理所有卡片检测模型
- # key (如 'outer_box') 将成为 API 路径中的 {inference_type}
- CARD_MODELS_CONFIG: dict[str, CardModelConfig] = {
- "outer_box": {
- "pth_path": "Model/outer_box.pth",
- "class_dict": {1: 'outer_box'},
- "img_size": {'width': 1280, 'height': 1280},
- "confidence": 0.5,
- "input_channels": 3,
- },
- "inner_box": {
- "pth_path": "Model/inner_box.pth",
- "class_dict": {1: 'inner_box'},
- "img_size": {'width': 1280, 'height': 1280},
- "confidence": 0.5,
- "input_channels": 3,
- },
- "back_defect": {
- "pth_path": "Model/back_defect.pth",
- "class_dict": {
- 1: 'wear', 2: 'wear_and_impact', 3: 'impact',
- 4: 'damaged', 5: 'wear_and_stain',
- },
- "img_size": {'width': 512, 'height': 512},
- "confidence": 0.5,
- "input_channels": 3,
- },
- "no_reflect_front_defect": {
- "pth_path": "Model/no_reflect_front_defect.pth",
- "class_dict": {1: 'scratch',
- 2: 'pit',
- 3: 'stain'},
- "img_size": {'width': 512, 'height': 512},
- "confidence": 0.5,
- "input_channels": 3,
- }
- }
- settings = Settings()
- print(settings.BASE_PATH)
|