当前位置: 首页 > news >正文

阿里巴巴的网站建设与维护网络宣传的方法渠道

阿里巴巴的网站建设与维护,网络宣传的方法渠道,短链接生成器原理,做web网站原型8月AI实战:工业视觉缺陷检测 –基于tflite的yolov8模型优化和推理 操作视频见B站连接:aidlux模型优化工业缺陷检测~~完美用我的华为手机实现缺陷检测的推理bilibiliaidlux模型优化工业缺陷检测~~完美用我…

8月AI实战:工业视觉缺陷检测

–基于tflite的yolov8模型优化和推理

操作视频见B站连接:aidlux模型优化+工业缺陷检测~~完美用我的华为手机实现缺陷检测的推理bilibiliaidlux模型优化+工业缺陷检测~~完美用我的华为手机实现缺陷检测的推理

1 模型优化

将onnx模型转化为tflite模型

打开网站:http://aimo.aidlux.com/
输入试用账号和密码:账号:AIMOTC001 ,密码:AIMOTC001

通过页面中的提示AI Model Optimizer,依次执行步骤①上传模型②选择目标平台③参数设置④转换结果。

通过上述①-④可将onnx模型转为tflite模型

模型转换过程包含如下日志信息

2023-09-07 19:47:05,969 - INFO : Optimization started.
2023-09-07 19:47:05,970 - INFO : [ONNX-SIM] Clean ONNX Model input node.
2023-09-07 19:47:06,733 - INFO : [ONNX2TFLITE] Start converting to TFLITE.
2023-09-07 19:47:28,511 - INFO : Model optimization done.

2 推理的py文件

模型采用课程中提供的yolov8_slimneck_SIOU.ONNX,转化完模型路径及名称,如下

# 模型
model_path = "/home/lesson3/yolov8_slimneck_SIOU_tflite/yolov8_slimneck_SIOU_fp32.tflite"
# 测试图片路径
image_path = "/home/lesson3/test"

模型推理过程包含如下步骤:

  1. 初始化aidlite类并创建aidlite对象
aidlite = aidlite_gpu.aidlite()
print("ok")
  1. 加载模型
value = aidlite.ANNModel(model_path, [640 * 640 * 3 * 4], [8400 * 11 * 4], 4, 0)
print("gpu:", value)

包含遍历每一张图片

for root, dirs, files in os.walk(image_path):num = 0for file in files:file = os.path.join(root, file)frame = cv2.imread(file)x_scale = frame.shape[1] / 640y_scale = frame.shape[0] / 640

将图片转换为模型输入的640*640尺寸

img = cv2.resize(frame, (640, 640))
# img_copy=img.co
img = img / 255.0
img = np.expand_dims(img, axis=0)
img = img.astype(dtype=np.float32)
print(img.shape)
  1. 传入模型输入数据
aidlite.setInput_Float32(img)
  1. 执行推理
start = time.time()
aidlite.invoke()
end = time.time()
timerValue = 1000 * (end - start)
print("infer time(ms):{0}", timerValue)
  1. 获取输出
pred = aidlite.getOutput_Float32(0)
# print(pred.shape)
pred = np.array(pred)
print(pred.shape)
pred = np.reshape(pred, (8400, 11))
print(pred.shape)  # shape=(8400,11)
  1. 后处理,解析输出
boxes, scores, classes = postProcess(pred, confThresh, NmsThresh)
  1. 绘制保存图像
ret_img = draw(frame, x_scale, y_scale, boxes, scores, classes)
ret_img = ret_img[:, :, ::-1]
num += 1
image_file_name = "/home/result/res" + str(num) + ".jpg"

​ 8. 保存图片

cv2.imwrite(image_file_name, ret_img)
http://www.dinnco.com/news/77242.html

相关文章:

  • 网站建设的id调用怎么操作有没有推广app的平台
  • 武汉网站seo外包推广普通话ppt课件
  • 用什么语言能写网站吗谈谈你对互联网营销的认识
  • 可以做关键词优化的免费网站关键词排名优化
  • php网站开发的成功经历seo需要掌握什么技能
  • 企业域名邮箱张家口网站seo
  • 资源库网站开发什么搜索引擎搜索最全
  • 安阳门户网站优化网站的意思
  • 生态养殖网站模板深圳英文站seo
  • 淄博网站建设选择臻动传媒海南百度推广代理商
  • 做网站招标网站优化seo是什么意思
  • 微信版网站开发seo代理计费系统
  • 美国人做网站seo基础课程
  • wordpress发布的文章如何不显示东莞百度推广优化公司
  • 怎么创作自己的网站手机建站系统
  • 汽车品牌大全汽车网济南网络优化网址
  • 找人做网站注意长沙seo网络营销推广
  • 自制响应式网站游戏广告投放平台
  • 做网站建设哪家公司靠谱李勇seo博客
  • asp 开发的大型网站徐州seo外包平台
  • 购物网站建设所需软件优化关键词具体要怎么做
  • 贵阳网站制作贵阳网站建设哪家好5118大数据平台官网
  • 上海网站建设建站郑州seo排名优化
  • 营销网站建设实训总结百度小说排行榜风云榜
  • 做视频免费模板下载网站关键词排名推广软件
  • 网站适配手机屏幕泉州百度关键词优化
  • 公司网站必须做可信认证吗seo页面代码优化
  • 怎么做门户网站网页设计作品集
  • 自己做网站前端开发精准广告投放
  • 新疆宏远建设集团网站文件外链生成网站