| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- from pathlib import Path
- from typing import Dict
- # 定义一个模型的配置结构
- 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] = {
- "pokemon_outer_box": {
- "pth_path": "Model/pokemon_outer_box.pth",
- "class_dict": {1: 'outer_box'},
- "img_size": {'width': 1280, 'height': 1280},
- "confidence": 0.5,
- "input_channels": 3,
- },
- "pokemon_inner_box": {
- "pth_path": "Model/pokemon_inner_box.pth",
- "class_dict": {1: 'inner_box'},
- "img_size": {'width': 1280, 'height': 1280},
- "confidence": 0.5,
- "input_channels": 3,
- },
- "pokemon_back_corner_defect": {
- "pth_path": "Model/pokemon_back_corner_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,
- },
- "pokemon_front_corner_reflect_defect": {
- "pth_path": "Model/pokemon_front_corner_reflect_defect.pth",
- "class_dict": {"1": "impact", "2": "wear_and_impact", "3": "wear"},
- "img_size": {'width': 512, 'height': 512},
- "confidence": 0.5,
- "input_channels": 3,
- },
- "pokemon_front_corner_no_reflect_defect": {
- "pth_path": "Model/pokemon_front_corner_no_reflect_defect.pth",
- "class_dict": {"1": "wear", "2": "wear_and_impact", "3": "impact", "4": "damaged"},
- "img_size": {'width': 512, 'height': 512},
- "confidence": 0.5,
- "input_channels": 3,
- },
- "pokemon_front_face_no_reflect_defect": {
- "pth_path": "Model/pokemon_front_face_no_reflect_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)
|