فهرست منبع

修改update的bug

AnlaAnla 4 هفته پیش
والد
کامیت
5360d3d5f9
2فایلهای تغییر یافته به همراه11 افزوده شده و 9 حذف شده
  1. 8 8
      Test/img_score_and_insert.py
  2. 3 1
      app/api/images.py

+ 8 - 8
Test/img_score_and_insert.py

@@ -8,21 +8,21 @@ from datetime import datetime
 
 # --- 配置区域 ---
 # 1. 服务 URL
-INFERENCE_SERVICE_URL = "http://127.0.0.1:7744"
-STORAGE_SERVICE_URL = "http://127.0.0.1:7745"
+# INFERENCE_SERVICE_URL = "http://127.0.0.1:7744"
+# STORAGE_SERVICE_URL = "http://127.0.0.1:7745"
 
-# INFERENCE_SERVICE_URL = "http://192.168.31.243:7744"
-# STORAGE_SERVICE_URL = "http://192.168.31.243:7745"
+INFERENCE_SERVICE_URL = "http://192.168.31.243:7744"
+STORAGE_SERVICE_URL = "http://192.168.31.243:7745"
 
 # 2. 要处理的卡片信息
 formate_time = datetime.now().strftime("%Y-%m-%d_%H:%M")
 CARD_NAME = f"卡 {formate_time}"
 
 # 3. 四张卡片图片的本地路径
-front_face_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250919_1500_no_reflect_nature_defect\15_front_coaxial_1_0.jpg"
-front_edge_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250919_1500_no_reflect_nature_defect\15_front_ring_0_1.jpg"
-back_face_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250919_1500_no_reflect_nature_defect\15_back_coaxial_1_0.jpg"
-back_edge_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250919_1500_no_reflect_nature_defect\15_back_ring_0_1.jpg"
+front_face_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250915_1643_no_reflect_hand_defect\7_front_coaxial_1_0.jpg"
+front_edge_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250915_1643_no_reflect_hand_defect\7_front_ring_0_1.jpg"
+back_face_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250915_1643_no_reflect_hand_defect\7_back_coaxial_1_0.jpg"
+back_edge_img_path = r"C:\Code\ML\Image\Card\_250915_many_capture_img\_250915_1643_no_reflect_hand_defect\7_back_ring_0_1.jpg"
 IMAGE_PATHS = [
     front_edge_img_path,
     front_face_img_path,

+ 3 - 1
app/api/images.py

@@ -147,7 +147,7 @@ async def update_image_modified_json(
         cursor = db_conn.cursor(dictionary=True)
 
         # 1️ 获取图片信息
-        cursor.execute(f"SELECT image_type FROM {settings.DB_IMAGE_TABLE_NAME} WHERE id = %s", (id,))
+        cursor.execute(f"SELECT image_type, card_id FROM {settings.DB_IMAGE_TABLE_NAME} WHERE id = %s", (id,))
         row = cursor.fetchone()
         if not row:
             raise HTTPException(status_code=404, detail=f"ID为 {id} 的图片未找到。")
@@ -158,6 +158,7 @@ async def update_image_modified_json(
         if not score_type:
             raise HTTPException(status_code=400, detail=f"未知的 image_type: {image_type}")
 
+        logger.info("开始计算分数")
         # 2️ 调用远程计算接口
         try:
             response = await run_in_threadpool(
@@ -173,6 +174,7 @@ async def update_image_modified_json(
             logger.error(f"分数计算接口返回错误: {response.status_code}, {response.text}")
             raise HTTPException(status_code=response.status_code,
                                 detail=f"分数计算接口返回错误: {response.text}")
+        logger.info("分数计算完成")
 
         # 3️ 保存结果到数据库
         recalculated_json_str = json.dumps(response.json(), ensure_ascii=False)