参考链接:https://github.com/argman/EAST (项目来源)

https://github.com/opencv/opencv/issues/12491  (遇到的问题)

      https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/   (opencv加载)

文字检测有很多比较好的现成的模型比如yolov3,pesnet,pennet,east。不一一赘述,讲一下自己跑通east的过程。

https://github.com/argman/EAST链接中下载项目,windows下,各种包的版本要正确否则会出一些乱七八糟的错误。

运行EAST/eval.py。没有什么特别的问题要说,我在cpu下单张640*480的图能够达到每张0.4秒左右,还是非常优秀的。中英文数字都可。

但是源代码是ckpt,非常大,转成pb会稍微小点。添加:

##生成pb模型,但需要修改model.py
output_graph_def = tf.graph_util.convert_variables_to_constants(self.sess, # The session is used to retrieve the weights
tf.get_default_graph().as_graph_def(), # The graph_def is used to retrieve the nodes
["feature_fusion/Conv_7/Sigmoid", "feature_fusion/concat_3"]
)
output_graph='D:\\work\\video\\hand_tracking_no_op\\hand_tracking\\EAST\\east_icdar2015_resnet_v1_50_rbox\\out.pb'
with tf.gfile.GFile(output_graph, "wb") as f:
f.write(output_graph_def.SerializeToString())
print("%d ops in the final graph." % len(output_graph_def.node)) 位置在eval.py中的 saver.restore(self.sess, model_path)后面。注意如果你想要opencv加载pb还要修改model.py中的内容,这个在后面一篇文章中会讲到。
生成后用tf加载,方法跟加载ckpt相似:
import os
os.environ['CUDA_VISIBLE_DEVICES'] = FLAGS.gpu_list try:
os.makedirs(FLAGS.output_dir)
except OSError as e:
if e.errno != 17:
raise print("load_graph")
graph = load_graph(FLAGS.checkpoint_path) input_images = graph.get_tensor_by_name(
'import/input_images:0') f_score = graph.get_tensor_by_name('import/feature_fusion/Conv_7/Sigmoid:0')
f_geometry = graph.get_tensor_by_name(
'import/feature_fusion/concat_3:0') with tf.Session(graph=graph) as sess: im_fn_list = get_images()
for im_fn in im_fn_list:
im = cv2.imread(im_fn)[:, :, ::-1]
start_time = time.time()
im_resized, (ratio_h, ratio_w) = resize_image(im) timer = {'net': 0, 'restore': 0, 'nms': 0}
start = time.time() #file_writer = tf.summary.FileWriter('tmp/log', sess.graph) score, geometry = sess.run([f_score, f_geometry], feed_dict={
input_images: [im_resized]})
timer['net'] = time.time() - start boxes, timer = detect(score_map=score, geo_map=geometry, timer=timer)
print('{} : net {:.0f}ms, restore {:.0f}ms, nms {:.0f}ms'.format(
im_fn, timer['net']*1000, timer['restore']*1000, timer['nms']*1000)) if boxes is not None:
boxes = boxes[:, :8].reshape((-1, 4, 2))
boxes[:, :, 0] /= ratio_w
boxes[:, :, 1] /= ratio_h duration = time.time() - start_time
print('[timing] {}'.format(duration)) # save to file
if boxes is not None:
res_file = os.path.join(
FLAGS.output_dir,
'{}.txt'.format(
os.path.basename(im_fn).split('.')[0])) with open(res_file, 'w') as f:
for box in boxes:
# to avoid submitting errors
box = sort_poly(box.astype(np.int32))
if np.linalg.norm(box[0] - box[1]) < 5 or np.linalg.norm(box[3]-box[0]) < 5:
continue
f.write('{},{},{},{},{},{},{},{}\r\n'.format(
box[0, 0], box[0, 1], box[1, 0], box[1, 1], box[2, 0], box[2, 1], box[3, 0], box[3, 1],
))
cv2.polylines(im[:, :, ::-1], [box.astype(np.int32).reshape((-1, 1, 2))], True, color=(255, 255, 0), thickness=1)
if not FLAGS.no_write_images:
img_path = os.path.join(FLAGS.output_dir, os.path.basename(im_fn))
cv2.imwrite(img_path, im[:, :, ::-1]) 以上就是EAST的ckpt转pb用tf加载啦。
下一篇讲opencv加载east的pb。

文字检测模型EAST应用详解 ckpt pb的tf加载,opencv加载的更多相关文章

  1. Kaggle网站流量预测任务第一名解决方案:从模型到代码详解时序预测

    Kaggle网站流量预测任务第一名解决方案:从模型到代码详解时序预测 2017年12月13日 17:39:11 机器之心V 阅读数:5931   近日,Artur Suilin 等人发布了 Kaggl ...

  2. Java内存模型相关原则详解

    在<Java内存模型(JMM)详解>一文中我们已经讲到了Java内存模型的基本结构以及相关操作和规则.而Java内存模型又是围绕着在并发过程中如何处理原子性.可见性以及有序性这三个特征来构 ...

  3. CSS3盒模型display:box详解

    display:box;box-flex是css3新添加的盒子模型属性,它的出现可以解决我们通过N多结构.css实现的布局方式.经典的一个布局应用就是布局的垂直等高.水平均分.按比例划分. 目前box ...

  4. 基于模型的特征选择详解 (Embedded & Wrapper)

    目录 基于模型的特征选择详解 (Embedded & Wrapper) 1. 线性模型和正则化(Embedded方式) 2. 基于树模型的特征选择(Embedded方式) 3. 顶层特征选择算 ...

  5. Kubernetes服务pod的健康检测liveness和readiness详解

    Kubernetes服务pod的健康检测liveness和readiness详解 接下来给大家讲解下在K8S上,我们如果对我们的业务服务进行健康检测. Health Check.restartPoli ...

  6. OSI模型各层详解

    1. OSI概述 1.1 模拟器说明 1.1.1 模拟器的作用 搭建实验环境进行测试. 1.1.2 模拟器的类型 PT:一般是学校中使用,命令不完整,且不能抓包 GNS3:思科(CCNA,CCNP), ...

  7. 不止面试02-JVM内存模型面试题详解

    第一部分:面试题 本篇文章我们将尝试回答以下问题: 描述一下jvm的内存结构 描述一下jvm的内存模型 谈一下你对常量池的理解 什么情况下会发生栈内存溢出?和内存溢出有什么不同? String str ...

  8. DJango模型Meta选项详解

    Django模型之Meta选项详解 MEAT选项 Django模型类的Meta是一个内部类,它用于定义一些Django模型类的行为特性.而可用的选项大致包含以下几类 abstract 这个属性是定义当 ...

  9. 第三十五节,目标检测之YOLO算法详解

    Redmon, J., Divvala, S., Girshick, R., Farhadi, A.: You only look once: Unified, real-time object de ...

随机推荐

  1. 移动端H5调试

    背景:开发PC页面的时候使用chrome浏览器的开发者工具,可以很容易的捕获到页面的dom元素,并且可以修改样式,方便调试:但是手机上却很麻烦,因为手机上没有办法直接打开开发者工具查看元素.其实可以通 ...

  2. postman设置全局变量及参数化

    笔者第一次记录使用过程,仅供参考 测试过程中接口的前缀都是一样的,所以我们可以将这个前缀作为全局变量来使用 首先,打开postman点击这里的小齿轮设置 在这里就可以进行变量的一个添加,添加好之后记住 ...

  3. Oracle 11g中创建实例

    1.打开“所有程序” -> “Oracle -OraDb11g_home1” -> “配置移植工具” -> “Database Configuration  Assistant”. ...

  4. .Net Core2.2 使用 AutoMapper进行实体转换

    一.遇到的问题 在. Core Api 的编写中,我们经常会对一些功能点进行新增编辑操作,同时我们有时也会进行查询,但是我们查询的表的数据与我们返回的数据相差甚大,这是我们有需要自己手动进行类型的转换 ...

  5. Tainted canvases may not be exported的问题解决

    项目里使用到用canvas生成海报,在toDataURL报了这个错误Tainted canvases may not be exported. 原因就在于使用了跨域的图片,所以说是被污染的画布.解决方 ...

  6. yum,rpm等失效,使用系统安装包ISO文件降级程序恢复系统

    linux平台:REHL6.7 故障原因:由于不小心使用命令yum update nss误升级了工作平台中nss系列工具包导致系统中yum 和 rpm命令执行都报错. 由于yum rpm命令都不好用使 ...

  7. Java 对象容器

    一.ArrayList 容器 1.记事本 package booknote; import java.util.ArrayList; public class NoteBook { private A ...

  8. ajax请求以及递归

    function f1() { console.log("hello"); f1(); }; f1();//浏览器崩溃,因为没有结束条件——死循环 改进如下: var i=0; f ...

  9. 2020非常全的软件测试linux常用命令全集,linux面试题及参考答案

    一.前言: 作为一名软件测试工程师,我相信大部分的人都和Linux打过交道,因为我们的服务器一般都是装的Linux操作系统,包括各种云服务器也都是用的Linux,目前主流是CentOS7,那么对于一个 ...

  10. SpringCloud(三)之我学 Hystrix

    1.断路器 在消费服务的启动类,添加注解:@EnableCircuitBreaker,在消费服务的调用类上,添加注解:@HystrixCommand(fallbackMethod = "&q ...