Files
ailai_image_point_diff/cls_main(框架完成rknn还没训练)/readme.md

49 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# yolov11_cls_inference README
## 概述
该模块用于对米厂输入图像执行二分类推理,用于判断机械臂夹爪是否夹紧。
类别定义:
0 → 夹具未夹紧 (False)
1 → 夹具夹紧 (True)
rknn模型只加载一次复用全局实例提高推理效率。
## 调用示例
您可以直接调用 yolov11_cls_inference 函数,以便集成到其他项目中:
示例 1: 测试仅获取单张图片的类别和布尔值
```bash
from yolov11_cls_inference import yolov11_cls_inference
import cv2
# 读取图像
bgr_image = cv2.imread("11.jpg")
rgb_image = cv2.cvtColor(bgr_image, cv2.COLOR_BGR2RGB)
# 调用推理函数
class_id, bool_value = yolov11_cls_inference(
model_path="yolov11_cls.rknn",
raw_image=rgb_image,
target_size=(640, 640)
)
print(f"类别ID: {class_id}, 布尔值: {bool_value}")
```
示例 2: 直接在其他项目中集成使用
```bash
from yolov11_cls_inference import yolov11_cls_inference
# raw_image 已经读取或处理好的图像
class_id, bool_value = yolov11_cls_inference(model_path="yolov11_cls.rknn", raw_image=raw_image)
if bool_value:
print("夹具夹紧")
else:
print("夹具未夹紧")
```