chawin.chen
commited on
Commit
·
b6e06ad
1
Parent(s):
0446d17
fix
Browse files- api_routes.py +6 -1
api_routes.py
CHANGED
|
@@ -1096,9 +1096,14 @@ async def analyze_face(
|
|
| 1096 |
original_image_filename = f"{original_md5_hash}_original.webp"
|
| 1097 |
original_image_path = os.path.join(IMAGES_DIR, original_image_filename)
|
| 1098 |
save_image_high_quality(image, original_image_path, quality=SAVE_QUALITY, upload_to_bos=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1099 |
# 🔥 添加图片安全检测
|
| 1100 |
t1 = time.perf_counter()
|
| 1101 |
-
is_safe = await wx_access_token.check_image_security(
|
| 1102 |
logger.info(f"Checking image content safety, time: {time.perf_counter() - t1:.3f}s")
|
| 1103 |
if not is_safe:
|
| 1104 |
await _record_output_file(
|
|
|
|
| 1096 |
original_image_filename = f"{original_md5_hash}_original.webp"
|
| 1097 |
original_image_path = os.path.join(IMAGES_DIR, original_image_filename)
|
| 1098 |
save_image_high_quality(image, original_image_path, quality=SAVE_QUALITY, upload_to_bos=False)
|
| 1099 |
+
try:
|
| 1100 |
+
with open(original_image_path, "rb") as f:
|
| 1101 |
+
security_payload = f.read()
|
| 1102 |
+
except Exception:
|
| 1103 |
+
security_payload = contents
|
| 1104 |
# 🔥 添加图片安全检测
|
| 1105 |
t1 = time.perf_counter()
|
| 1106 |
+
is_safe = await wx_access_token.check_image_security(security_payload)
|
| 1107 |
logger.info(f"Checking image content safety, time: {time.perf_counter() - t1:.3f}s")
|
| 1108 |
if not is_safe:
|
| 1109 |
await _record_output_file(
|