config.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from pathlib import Path
  2. from typing import Dict
  3. # 定义一个模型的配置结构
  4. class CardModelConfig:
  5. pth_path: str
  6. class_dict: dict
  7. img_size: dict
  8. confidence: float
  9. input_channels: int
  10. class Settings:
  11. API_prefix: str = "/api/card_inference"
  12. BASE_PATH = Path(__file__).parent.parent.absolute()
  13. # 使用一个字典来管理所有卡片检测模型
  14. # key (如 'outer_box') 将成为 API 路径中的 {inference_type}
  15. CARD_MODELS_CONFIG: Dict[str, CardModelConfig] = {
  16. "pokemon_outer_box": {
  17. "pth_path": "Model/pokemon_outer_box.pth",
  18. "class_dict": {1: 'outer_box'},
  19. "img_size": {'width': 1280, 'height': 1280},
  20. "confidence": 0.5,
  21. "input_channels": 3,
  22. },
  23. "pokemon_inner_box": {
  24. "pth_path": "Model/pokemon_inner_box.pth",
  25. "class_dict": {1: 'inner_box'},
  26. "img_size": {'width': 1280, 'height': 1280},
  27. "confidence": 0.5,
  28. "input_channels": 3,
  29. },
  30. "pokemon_back_corner_defect": {
  31. "pth_path": "Model/pokemon_back_corner_defect.pth",
  32. "class_dict": {
  33. 1: 'wear', 2: 'wear_and_impact', 3: 'impact',
  34. 4: 'damaged', 5: 'wear_and_stain',
  35. },
  36. "img_size": {'width': 512, 'height': 512},
  37. "confidence": 0.5,
  38. "input_channels": 3,
  39. },
  40. "pokemon_front_corner_reflect_defect": {
  41. "pth_path": "Model/pokemon_front_corner_reflect_defect.pth",
  42. "class_dict": {"1": "impact", "2": "wear_and_impact", "3": "wear"},
  43. "img_size": {'width': 512, 'height': 512},
  44. "confidence": 0.5,
  45. "input_channels": 3,
  46. },
  47. "pokemon_front_corner_no_reflect_defect": {
  48. "pth_path": "Model/pokemon_front_corner_no_reflect_defect.pth",
  49. "class_dict": {"1": "wear", "2": "wear_and_impact", "3": "impact", "4": "damaged"},
  50. "img_size": {'width': 512, 'height': 512},
  51. "confidence": 0.5,
  52. "input_channels": 3,
  53. },
  54. "pokemon_front_face_no_reflect_defect": {
  55. "pth_path": "Model/pokemon_front_face_no_reflect_defect.pth",
  56. "class_dict": {"1": "scratch", "2": "pit", "3": "stain"},
  57. "img_size": {'width': 512, 'height': 512},
  58. "confidence": 0.5,
  59. "input_channels": 3,
  60. },
  61. }
  62. settings = Settings()
  63. print(settings.BASE_PATH)