惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Google DeepMind News
Google DeepMind News
S
Schneier on Security
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
Security Latest
Security Latest
Jina AI
Jina AI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recorded Future
Recorded Future
T
Tor Project blog
有赞技术团队
有赞技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News | PayPal Newsroom
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
Forbes - Security
Forbes - Security
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
NISL@THU
NISL@THU
C
Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Google DeepMind News
Google DeepMind News
Project Zero
Project Zero
IT之家
IT之家
T
Threatpost
Cyberwarzone
Cyberwarzone
O
OpenAI News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
J
Java Code Geeks
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
月光博客
月光博客
Latest news
Latest news
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 广阔之海

Halcon的三角函数 Halcon轮廓插值方法 C# 控件选项变化事件处理 深度学习执行速度不稳定的解决方法 Halcon 画一个时钟 Halcon 解方程(solve_matrix) C# 使用Serilog日志框架 Halcon 生成标定板 Halcon 中的形态学 Halcon的提取中心线算法 C# 消灭switch的面向映射编程 C#中Task的用法 Halcon 通过坐标轴过滤点云数据 Halcon图像投影映射 C# 获取MySql的数据库结构信息 C# HttpClient的使用方法总结 MySql字符集导致特殊字符保存出错问题处理 Asp.Net Core 动态生成WebApi Asp.Net Core WebApi中集成Jwt认证
Halcon - 深度学习 - 目标分类
广阔之海 · 2023-06-30 · via 博客园 - 广阔之海
*********************************************
* Halcon-深度学习-分类测试
* 这是一个例子,通过读取桃子和梨的图片集来进行模型训练,
* 得到一个可以识别桃子或是梨的深度学习识别器
*********************************************
dev_close_window ()
dev_update_off ()
set_system ('seed_rand', 42)
get_system ('example_dir', PathExample)
ImageBaseFolder := PathExample + '/images/food/'
ImageFolder := ImageBaseFolder + ['peach','pear']
OutputDir := './images/classify/'
************
* 预处理
************
read_dl_dataset_classification(ImageFolder, 'last_folder', DLDataSet)
read_dl_model ('pretrained_dl_classifier_compact.hdl', DLModelHandle)
get_dict_tuple(DLDataSet, 'class_names', ClassNames)
set_dl_model_param(DLModelHandle, 'class_names', ClassNames)
* 分割数据集,70%用作训练,15%用作验证,剩下作为测试
split_dl_dataset(DLDataSet, 70, 15, [])
create_dl_preprocess_param_from_model(DLModelHandle, 'none', 'full_domain', [], [], [], DLPreprocessParam)
create_dict(PreprocessSettings)
set_dict_tuple(PreprocessSettings, 'overwrite_files', true)
preprocess_dl_dataset(DLDataSet, OutputDir, DLPreprocessParam, PreprocessSettings, DLDatasetFileName)
************
* 训练模型
************
* 每次迭代的训练样本数,值过大可能会报内存不足
set_dl_model_param(DLModelHandle, 'batch_size', 64)
* 学习率,会影响识别准确率
set_dl_model_param(DLModelHandle, 'learning_rate', 0.001)
set_dl_model_param(DLModelHandle, 'runtime_init', 'immediately')
create_dl_train_param(DLModelHandle, 20, 1, 'true', 41, [], [], TrainParam)
train_dl_model(DLDataSet, DLModelHandle, TrainParam, 0, TrainResults, TrainInfos, EvaluationInfos)
* 训练完成后将模型写入文件
write_dl_model(DLModelHandle, './trainModel.hdl')
stop ()
************
* 分类识别测试
************
dev_clear_window ()
dev_open_window (0, 0, 256, 256, 'black', WindowHandle)
set_display_font (WindowHandle, 20, '黑体', 'false', 'false')
* 读取训练模型
read_dl_model('./trainModel.hdl', DLModelHandle)
create_dl_preprocess_param_from_model(DLModelHandle, 'none', 'full_domain', [], [], [], DLPreprocessParam)
list_files('./images/test/', 'files', Files)
for I := 0 to |Files|-1 by 1
read_image (Image, Files[I])
    * 对测试图片进行识别
    gen_dl_samples_from_images(Image, DLSample)
    preprocess_dl_samples(DLSample, DLPreprocessParam)
    apply_dl_model(DLModelHandle, DLSample, [], DLResult)
    get_dict_tuple(DLResult, 'classification_class_names', ClassNames)
    dev_display(Image)
    dev_disp_text('识别结果:' + ClassNames[0], 'window', 'top', 'center', 'red', ['box'], ['false'])
    stop()
endfor