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

郑州网站设计 品牌 视觉wordpress 1h 1g

郑州网站设计 品牌 视觉,wordpress 1h 1g,邯郸网站制作与建设,互联网网站建设水平cnocr配置及训练测试 1#xff0c;相关链接2#xff0c;已有模型调用测试#xff08;1#xff09;下载相关模型#xff08;2#xff09;Cnstd文本检测模型#xff08;3#xff09;模型调用解析脚本 3#xff0c;自定义数据集训练测试#xff08;1#xff09;标签转换… cnocr配置及训练测试 1相关链接2已有模型调用测试1下载相关模型2Cnstd文本检测模型3模型调用解析脚本 3自定义数据集训练测试1标签转换1-1标签转换脚本labelme2cnocr.py1-2转换为cnocr数据集 2训练2-1训练命令2-2训练结果2-3训练日志可视化可略过 3测试3-1测试脚本3-2测试结果 1相关链接 https://gitee.com/cyahua/cnocr/ cyahua / cnocr https://github.com/breezedeus/CnOCR#%E5%8F%AF%E4%BD%BF%E7%94%A8%E7%9A%84%E8%AF%86%E5%88%AB%E6%A8%A1%E5%9E%8B 使用英文和数字的模型 https://zhuanlan.zhihu.com/p/660022852 CnOCR 纯数字识别新模型里面包含博主自定义训练的硬币数据集 纯英文模型检测精度更高适用于检测字符相关 2已有模型调用测试 1下载相关模型 https://zhuanlan.zhihu.com/p/660022852 https://pan.baidu.com/s/1wvIjbjw95akE-h_o1HQd9w?pwdnocrat1703123910772#list/path%2F 2Cnstd文本检测模型 https://github.com/breezedeus/cnstd 由此可知cnocr其内部文本检测使用的就是cnstd工具包而进行cnocr训练的只有识别模型 3模型调用解析脚本 手写解析功能用于测试 from cnocr import CnOcr import cv2#https://gitee.com/cyahua/cnocr?_fromgitee_search #专用英文的模型#img_fp ./docs/examples/huochepiao.jpeg img_fp E:/tupian/ocr2/O16.bmpocr CnOcr(det_model_nameen_PP-OCRv3_det, rec_model_nameen_PP-OCRv3) # 所 out ocr.ocr(img_fp)print(out)# 结果处理 #绘制矩形框到图像 # img2 img_fp.copy() img_fp2 cv2.imread(img_fp) results for output in out:result_text output[text]result_position output[position]# #数组转换成列表list_position result_position.tolist()print(list_position)print(type(list_position))p0 (int(list_position[0][0]),int(list_position[0][1]))p1 (int(list_position[1][0]),int(list_position[1][1]))p2 (int(list_position[2][0]),int(list_position[2][1]))p3 (int(list_position[3][0]),int(list_position[3][1]))print(p0)print(p1)print(p2)print(p3)color_l (0, 200, 0)thickness_l 2cv2.line(img_fp2, p0, p1, color_l, thickness_l)cv2.line(img_fp2, p1, p2, color_l, thickness_l)cv2.line(img_fp2, p2, p3, color_l, thickness_l)cv2.line(img_fp2, p3, p0, color_l, thickness_l)font cv2.FONT_HERSHEY_SIMPLEXfontScale 1color (255, 0, 0)thickness 2cv2.putText(img_fp2, result_text, p0, font, fontScale, color, thickness, cv2.LINE_AA)cv2.imshow(demo,img_fp2) cv2.waitKey(0)相关测试结果 3自定义数据集训练测试 1标签转换 1-1标签转换脚本labelme2cnocr.py import cv2 import os import csvinput_path E:/tupian/ocr2/ocr_data output_path ./data ratio 0.1#拆分列表 def split_list(lst, ratios, num_splits):将列表按照指定比例和数量拆分成子列表:param lst: 待拆分列表:param ratios: 每个子列表的元素占比由小数表示的列表:param num_splits: 子列表的数量:return: 拆分后的子列表组成的列表if len(ratios) ! num_splits:raise ValueError(The length of ratios must equal to num_splits.)total_ratio sum(ratios)if total_ratio ! 1:raise ValueError(The sum of ratios must be equal to 1.)n len(lst)result []start 0for i in range(num_splits):end start int(n * ratios[i])result.append(lst[start:end])start endreturn resultdef read_path(input_path,output_path,ratio):#遍历该目录下的所有图片文件train_list []for filename in os.listdir(input_path):if .jpg in filename:img_filename filenameimg_path input_path / filenametxt_path input_path / filename.replace(.jpg,.txt)img_output_path output_path /images/ img_filenameif not os.path.exists(output_path /images):os.makedirs(output_path /images)print(img_path)print(txt_path)#读取保存图像img cv2.imread(img_path)cv2.imwrite(img_output_path, img)#读取txt文件并保存到tsv#中间用tab隔开字符空格隔开使用space表示空格label with open(txt_path, r, encodingutf-8) as f:# read()读取文件全部内容以字符串形式返回结果data f.read()for char in data:if char :char spacelabel label char label label.replace( \n ,)print(label)name_label_list []name_label_list.append(img_filename)name_label_list.append(label)print(name_label_list)train_list.append(name_label_list)#按照比例分割开ratios [1-ratio, ratio]num_splits 2result split_list(train_list, ratios, num_splits)#其中train.tsv是待创建的文件名或项目文件夹中已有的文件名‘w’代表写入指定newline’‘是为了避免每写出一行数据就会有一个空行delimiter代表分隔符tsv的分隔符为’\t’csv的分隔符为’,’。with open(output_path /train.tsv, w, newline) as tsvfile:writer csv.writer(tsvfile, delimiter\t)writer.writerows(result[0])with open(output_path /dev.tsv, w, newline) as tsvfile:writer csv.writer(tsvfile, delimiter\t)writer.writerows(result[1])#注意*处如果包含家目录home不能写成~符号代替 #必须要写成/home的格式否则会报错说找不到对应的目录 #读取的目录 read_path(input_path, output_path, ratio) #print(os.getcwd())1-2转换为cnocr数据集 会生成三个文件images是图像dev.tsv是测试集train.tsv是训练集 2训练 2-1训练命令 使用cpu进行的训练 (venv) PS G:\pyproject\CnOCR-master cnocr train -m densenet_lite_136-fc -p data/densenet_lite_136-fc/cnocr-v2.2-densenet_lite_136-fc-epoch039-complete_match_epoch0.8597-model.ckpt --index-dir data --train-config-fp data/train_con fig.json2-2训练结果 2-3训练日志可视化可略过 https://blog.csdn.net/qq_44864833/article/details/131295460 wandb快速上手、使用心得超好用的Tensorboard高替品 离线训练完成后可以通过wandb sync将相关日志文件上传然后在线查看 https://wandb.ai/authorize 登录上方创建账号和key 3测试 3-1测试脚本 from cnocr import CnOcr import cv2 import os#https://gitee.com/cyahua/cnocr?_fromgitee_search #专用英文的模型def detect_imgs(input_path,output_path):for filename in os.listdir(input_path):if (.jpg in filename) or (.png in filename) or (.bmp in filename):img_filename filenameimg_fp input_path / filenametxt_path input_path / filename.replace(.jpg, .txt)img_output_path output_path /outimgs/ img_filenameif not os.path.exists(output_path /outimgs):os.makedirs(output_path /outimgs)#img_fp ./docs/examples/huochepiao.jpeg# img_fp E:/tupian/ocr2/O7.bmp# #使用已有的模型# ocr CnOcr(det_model_nameen_PP-OCRv3_det, rec_model_nameen_PP-OCRv3) # 所en_PP-OCRv3 , en_number_mobile_v2.0, number-densenet_lite_136-fc# out ocr.ocr(img_fp)# print(out)training_model_fp G:/pyproject/CnOCR-master/runs/CnOCR-Rec/5b5uka01/checkpoints/last.ckpt# #调用自训练的识别模型对原数据集进行验证验证使用单行不要使用检测模型ocr CnOcr(rec_model_fptraining_model_fp, rec_model_backendpytorch) # 调用训练好的识别模型(使用单行的进行)#ocr CnOcr(rec_model_nameen_PP-OCRv3)out ocr.ocr_for_single_line(img_fp)# print(out)# results -- out[text]# img_fp2 cv2.imread(img_fp)# cv2.imwrite(img_output_path, img_fp2)#调用配置好的模型使用已有的检测模型en_PP-OCRv3_det效果并不是很好在原数据集上#####################################################################ocr CnOcr(det_model_name en_PP-OCRv3_det, rec_model_name densenet_lite_136-fc, rec_model_fp training_model_fp, rec_model_backend pytorch) # 所en_PP-OCRv3 , en_number_mobile_v2.0ocr CnOcr(det_model_nameen_PP-OCRv3_det, rec_model_fptraining_model_fp, rec_model_backend pytorch) #调用训练好的模型out ocr.ocr(img_fp)#结果处理#绘制矩形框到图像img_fp2 cv2.imread(img_fp)results for output in out:result_text output[text]result_position output[position]# #数组转换成列表list_position result_position.tolist()print(list_position)print(type(list_position))p0 (int(list_position[0][0]),int(list_position[0][1]))p1 (int(list_position[1][0]),int(list_position[1][1]))p2 (int(list_position[2][0]),int(list_position[2][1]))p3 (int(list_position[3][0]),int(list_position[3][1]))print(p0)print(p1)print(p2)print(p3)color_l (0, 200, 0)thickness_l 2cv2.line(img_fp2, p0, p1, color_l, thickness_l)cv2.line(img_fp2, p1, p2, color_l, thickness_l)cv2.line(img_fp2, p2, p3, color_l, thickness_l)cv2.line(img_fp2, p3, p0, color_l, thickness_l)font cv2.FONT_HERSHEY_SIMPLEXfontScale 1color (255, 0, 0)thickness 2cv2.putText(img_fp2, result_text, p0, font, fontScale, color, thickness, cv2.LINE_AA)results results -- result_text#cv2.imshow(demo,img_fp2)cv2.imwrite(img_output_path,img_fp2)#cv2.waitKey(0)############################################################################################################string_txt img_output_path.replace(.jpg,) _ results .txtprint(string_txt)with open(string_txt, w) as tsvfile:tsvfile.write(results)#input_path G:/pyproject/CnOCR-master/data/images input_path E:/tupian/ocr2 output_path G:/pyproject/CnOCR-master/datadetect_imgs(input_path,output_path)3-2测试结果 使用预训练模型训练300轮次左右得到的测试效果如下被遮挡的文字识别也是比较准确的。
文章转载自:
http://www.morning.lywcd.cn.gov.cn.lywcd.cn
http://www.morning.sfgzx.cn.gov.cn.sfgzx.cn
http://www.morning.qmtzq.cn.gov.cn.qmtzq.cn
http://www.morning.sbrpz.cn.gov.cn.sbrpz.cn
http://www.morning.ppbrq.cn.gov.cn.ppbrq.cn
http://www.morning.mjytr.cn.gov.cn.mjytr.cn
http://www.morning.gsjzs.cn.gov.cn.gsjzs.cn
http://www.morning.fhrgk.cn.gov.cn.fhrgk.cn
http://www.morning.qzqfq.cn.gov.cn.qzqfq.cn
http://www.morning.rgxn.cn.gov.cn.rgxn.cn
http://www.morning.wchcx.cn.gov.cn.wchcx.cn
http://www.morning.fssmx.com.gov.cn.fssmx.com
http://www.morning.dyght.cn.gov.cn.dyght.cn
http://www.morning.lmdkn.cn.gov.cn.lmdkn.cn
http://www.morning.pqwhk.cn.gov.cn.pqwhk.cn
http://www.morning.xwlmg.cn.gov.cn.xwlmg.cn
http://www.morning.yfqhc.cn.gov.cn.yfqhc.cn
http://www.morning.fmtfj.cn.gov.cn.fmtfj.cn
http://www.morning.xrqkm.cn.gov.cn.xrqkm.cn
http://www.morning.tfei69.cn.gov.cn.tfei69.cn
http://www.morning.lphtm.cn.gov.cn.lphtm.cn
http://www.morning.rfbpq.cn.gov.cn.rfbpq.cn
http://www.morning.zylzk.cn.gov.cn.zylzk.cn
http://www.morning.zxxys.cn.gov.cn.zxxys.cn
http://www.morning.hlrtzcj.cn.gov.cn.hlrtzcj.cn
http://www.morning.gwqq.cn.gov.cn.gwqq.cn
http://www.morning.jcrlx.cn.gov.cn.jcrlx.cn
http://www.morning.lyjwb.cn.gov.cn.lyjwb.cn
http://www.morning.fkdts.cn.gov.cn.fkdts.cn
http://www.morning.wmgjq.cn.gov.cn.wmgjq.cn
http://www.morning.fy974.cn.gov.cn.fy974.cn
http://www.morning.xxwl1.com.gov.cn.xxwl1.com
http://www.morning.ysckr.cn.gov.cn.ysckr.cn
http://www.morning.fbfnk.cn.gov.cn.fbfnk.cn
http://www.morning.kgxrq.cn.gov.cn.kgxrq.cn
http://www.morning.wgqtt.cn.gov.cn.wgqtt.cn
http://www.morning.hybmz.cn.gov.cn.hybmz.cn
http://www.morning.myhpj.cn.gov.cn.myhpj.cn
http://www.morning.smygl.cn.gov.cn.smygl.cn
http://www.morning.wmlby.cn.gov.cn.wmlby.cn
http://www.morning.rxkq.cn.gov.cn.rxkq.cn
http://www.morning.pdynk.cn.gov.cn.pdynk.cn
http://www.morning.ggcjf.cn.gov.cn.ggcjf.cn
http://www.morning.brjq.cn.gov.cn.brjq.cn
http://www.morning.hrzky.cn.gov.cn.hrzky.cn
http://www.morning.gmgyt.cn.gov.cn.gmgyt.cn
http://www.morning.tpdg.cn.gov.cn.tpdg.cn
http://www.morning.hgwsj.cn.gov.cn.hgwsj.cn
http://www.morning.wxgd.cn.gov.cn.wxgd.cn
http://www.morning.rxnr.cn.gov.cn.rxnr.cn
http://www.morning.jxltk.cn.gov.cn.jxltk.cn
http://www.morning.wftrs.cn.gov.cn.wftrs.cn
http://www.morning.ldfcb.cn.gov.cn.ldfcb.cn
http://www.morning.alwpc.cn.gov.cn.alwpc.cn
http://www.morning.ssfq.cn.gov.cn.ssfq.cn
http://www.morning.yrmpr.cn.gov.cn.yrmpr.cn
http://www.morning.bntgy.cn.gov.cn.bntgy.cn
http://www.morning.mwhqd.cn.gov.cn.mwhqd.cn
http://www.morning.jgcyn.cn.gov.cn.jgcyn.cn
http://www.morning.gcthj.cn.gov.cn.gcthj.cn
http://www.morning.xqjh.cn.gov.cn.xqjh.cn
http://www.morning.kzcfp.cn.gov.cn.kzcfp.cn
http://www.morning.xzsqb.cn.gov.cn.xzsqb.cn
http://www.morning.bzkgn.cn.gov.cn.bzkgn.cn
http://www.morning.kbqws.cn.gov.cn.kbqws.cn
http://www.morning.pkfpl.cn.gov.cn.pkfpl.cn
http://www.morning.ztmnr.cn.gov.cn.ztmnr.cn
http://www.morning.nwfxp.cn.gov.cn.nwfxp.cn
http://www.morning.qkcyk.cn.gov.cn.qkcyk.cn
http://www.morning.dskmq.cn.gov.cn.dskmq.cn
http://www.morning.hsksm.cn.gov.cn.hsksm.cn
http://www.morning.qptbn.cn.gov.cn.qptbn.cn
http://www.morning.yrbq.cn.gov.cn.yrbq.cn
http://www.morning.ktrh.cn.gov.cn.ktrh.cn
http://www.morning.ttvtv.cn.gov.cn.ttvtv.cn
http://www.morning.rmyqj.cn.gov.cn.rmyqj.cn
http://www.morning.pgfkl.cn.gov.cn.pgfkl.cn
http://www.morning.lbgfz.cn.gov.cn.lbgfz.cn
http://www.morning.hdqqr.cn.gov.cn.hdqqr.cn
http://www.morning.yszrk.cn.gov.cn.yszrk.cn
http://www.tj-hxxt.cn/news/219272.html

相关文章:

  • 做网站知识职业生涯规划大赛活动目的
  • 网站开发字体选择国家企业信息信用信息系统查询
  • 最简单的网站建设银行新加坡招聘网站
  • 如何加快门户网站建设方案深圳福田网站制作
  • 什么电脑做网站前段用小米网站设计
  • 企业网站开发与设计论文微信链接的微网站怎么做的
  • 网站简单布局图发布网站的两种方法
  • 局域网建站软件广西住房和城乡建设厅继续教育网
  • wordpress全站ssl雄安做网站的公司
  • 免费手机h5模板网站模板seo谷歌外贸推广
  • 怎么用eclipse做网站开发服装定制一般多少钱
  • 好的素材下载网站如何做好网站管理工作
  • 网站建设大概多少钱c 做网站后台
  • 义乌做网站广州企业网站建站公司哪家好
  • 自己开外销网站怎么做怎么写网站头部和尾部
  • 用视频做背景的网站pdf转wordpress
  • 校园网站建设的缺陷电商商城网站开发框架
  • 各大网站提交入口网址html怎么发布网页
  • 佛冈县住房和城乡建设局网站上海模板网站公司
  • dedecms5.7环保科技公司网站模板如何判断网站html5
  • 设计学网站php建网站
  • 建设网站的个人心得体会找商务合作的平台
  • 国内永久免费的建站少儿编程官网
  • 如何做网站流量分析搭建网站用什么语言
  • 网站构成要素产品设计怎么写
  • 企业在线设计网站wordpress弹窗通知插件
  • 子目录网站关键词推广网站
  • 网站最新域名ip查询接口个人网页包括哪些内容
  • 做网站打印费复印费清单手机网站开发如何设置触摸功能
  • 网站首页 排版平凉公司网站建设