From b9606771cfa14d70acbc874b3a8bca3209eaed1e Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Tue, 1 Apr 2025 14:24:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=9B=BE=E7=89=87=E6=B8=85?= =?UTF-8?q?=E6=99=B0=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/image_util.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/util/image_util.py b/util/image_util.py index 3a0082b..b5d98e4 100644 --- a/util/image_util.py +++ b/util/image_util.py @@ -251,3 +251,20 @@ def combined(img1, img2): combined_img[:height1, :width1] = img1 combined_img[:height2, width1:width1 + width2] = img2 return combined_img + + +def parse_clarity(image): + """ + 判断图片清晰度 + :param image: 图片NumPy数组或文件路径 + :return: 判断结果及置信度 + """ + clarity_result = [1, 0] + model = PaddleClas(inference_model_dir=r"model/clas/clarity_assessment", use_gpu=False) + clas_result = model.predict(input_data=image) + try: + clas_result = next(clas_result)[0] + clarity_result = [clas_result["class_ids"][0], clas_result["scores"][0]] + except Exception as e: + logging.error("获取图片清晰度失败", exc_info=e) + return clarity_result