Halcon奇异值检测

该方法属于无监督式的深度学习方法,优点:

1 无需标注

2 只训练正样本

3 可以在CPU下进行训练

4 具有较快的推断速度

适用场景:适合缺陷较为明显的项目

注意:设置的ImageWidth、ImageHeight ,以及自己采的图,尽量是32的倍数

精确率和召回率说明
https://www.jianshu.com/p/4434ea11c16c

  • 读取模型
    read_dl_model (‘E:/整条/model_final.hdl’, DLModelHandle)
  • 设置阈值(模型训练后得到)
    InferenceClassificationThreshold := 0.183618
    InferenceSegmentationThreshold := 0.236205
  • 用模型中已设定的尺寸缩放
    get_dl_model_param (DLModelHandle, ‘image_width’, ImageWidth)
    get_dl_model_param (DLModelHandle, ‘image_height’, ImageHeight)
    create_dl_preprocess_param (‘anomaly_detection’, ImageWidth, ImageHeight, 3, [], [], ‘constant_values’, ‘full_domain’, [], [], [], [], DLPreprocessParam)
  • 创建类别标签字典(不起作用,但是必须有)
    create_dict (DLDatasetInfo)
    set_dict_tuple (DLDatasetInfo, ‘class_names’, [‘ok’,‘ng’])
    set_dict_tuple (DLDatasetInfo, ‘class_ids’, [‘0’,‘1’])
  • 创建字典,承载窗体信息
    create_dict (WindowDict)
  • 读图
    list_files (‘E:/整条/ng’, [‘files’,‘follow_links’,‘recursive’], ImageFiles)
    tuple_regexp_select (ImageFiles, [’\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$’,‘ignore_case’], ImageFiles)
    for Index := 0 to |ImageFiles| - 1 by 1
    read_image (Image, ImageFiles[Index])
    • Image Acquisition 01: Do something
      gen_dl_samples_from_images (Image, DLSample)
      preprocess_dl_samples(DLSample, DLPreprocessParam)
      preprocess_dl_samples_bottle (DLSample)
      apply_dl_model (DLModelHandle, DLSample, [], DLResult)
      threshold_dl_anomaly_results (InferenceSegmentationThreshold, InferenceClassificationThreshold, DLResult)
    • 展示结果
      dev_display_dl_data (DLSample, DLResult, DLDatasetInfo, [‘anomaly_result’,‘anomaly_image’], [], WindowDict)
      dev_disp_text (‘Press F5 (continue)’, ‘window’, ‘bottom’, ‘center’, ‘black’, [], [])
      stop ()

endfor
dev_close_window_dict (WindowDict)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值