ning8429 commited on
Commit
fc86ba5
·
verified ·
1 Parent(s): 14c5f38

Update api_server.py

Browse files
Files changed (1) hide show
  1. api_server.py +26 -26
api_server.py CHANGED
@@ -88,33 +88,33 @@ def predict():
88
 
89
  # 返回處理後的圖像
90
  return send_file(img_io, mimetype='image/png')
91
- '''
92
- saved_images = []
93
 
94
- # 儲存辨識後的圖片到指定資料夾
95
- for result in results:
96
- # 保存完整圖片
97
- yolo_path = f'{YOLO_DIR}/results_{Path(result.path).name}'
98
- result.save(yolo_path)
99
- saved_images.append(yolo_path)
100
-
101
- # 保存裁剪後的圖片(僅當 save_crop 返回有效的路徑時才加入)
102
- cropped_images = result.save_crop(YOLO_DIR) # 有些 YOLO 版本 save_crop 不返回值
103
- if cropped_images: # 確保不會對 None 進行迭代
104
- if isinstance(cropped_images, list): # 如果它返回一個列表
105
- saved_images.extend(cropped_images)
106
- else:
107
- saved_images.append(cropped_images)
108
-
109
- end_time = time.time()
110
- inference_time = end_time - start_time
111
-
112
- # 返回辨識結果的文件路徑以及推理時間
113
- return jsonify({
114
- 'saved_images': saved_images,
115
- 'inference_time': inference_time
116
- }), 200
117
- '''
118
 
119
 
120
  # # dictionary is not a JSON: https://www.quora.com/What-is-the-difference-between-JSON-and-a-dictionary
 
88
 
89
  # 返回處理後的圖像
90
  return send_file(img_io, mimetype='image/png')
91
+
92
+ # saved_images = []
93
 
94
+ # # 儲存辨識後的圖片到指定資料夾
95
+ # for result in results:
96
+ # # 保存完整圖片
97
+ # yolo_path = f'{YOLO_DIR}/results_{Path(result.path).name}'
98
+ # result.save(yolo_path)
99
+ # saved_images.append(yolo_path)
100
+
101
+ # # 保存裁剪後的圖片(僅當 save_crop 返回有效的路徑時才加入)
102
+ # cropped_images = result.save_crop(YOLO_DIR) # 有些 YOLO 版本 save_crop 不返回值
103
+ # if cropped_images: # 確保不會對 None 進行迭代
104
+ # if isinstance(cropped_images, list): # 如果它返回一個列表
105
+ # saved_images.extend(cropped_images)
106
+ # else:
107
+ # saved_images.append(cropped_images)
108
+
109
+ # end_time = time.time()
110
+ # inference_time = end_time - start_time
111
+
112
+ # # 返回辨識結果的文件路徑以及推理時間
113
+ # return jsonify({
114
+ # 'saved_images': saved_images,
115
+ # 'inference_time': inference_time
116
+ # }), 200
117
+
118
 
119
 
120
  # # dictionary is not a JSON: https://www.quora.com/What-is-the-difference-between-JSON-and-a-dictionary