GlassyWing / text-detection-ocr

Chinese text detection and recognition based on CTPN + DENSENET using Keras and Tensor Flow,使用keras和tensorflow基于CTPN+Densenet实现的中文文本检测和识别
Apache License 2.0
285 stars 116 forks source link

Time cost unacceptable!!!!To big #23

Closed jackCplusplus closed 4 years ago

jackCplusplus commented 4 years ago

Hi There! OS:

   win 10
   anaconda 4.8.3
   CUDA 9.0 Cudnn7.6.5
   Nvidia  driver 445.87

Demo:

import time
import dlocr

if __name__ == '__main__':
    ocr = dlocr.get_or_create()
    start = time.time()

    bboxes, texts = ocr.detect("C:\\PycharmProjects\\text-detection-ocr-master\\asset\\demo_ctpn.png")
    print('\n'.join(texts))
    print(f"cost: {(time.time() - start) * 1000}ms")

log:

Using TensorFlow backend.
2020-05-31 14:59:01.218166: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-05-31 14:59:01.311524: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties: 
name: GeForce GTX 1070 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.683
pciBusID: 0000:09:00.0
totalMemory: 8.00GiB freeMemory: 6.62GiB
2020-05-31 14:59:01.311826: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0
2020-05-31 14:59:52.947413: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-31 14:59:52.947594: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958]      0 
2020-05-31 14:59:52.947706: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0:   N 
2020-05-31 14:59:52.951287: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6386 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070 Ti, pci bus id: 0000:09:00.0, compute capability: 6.1)
156/卞之琳代表作
儿翻动了一下。她还不敢断定不是在梦里,弯起了臂,把乳头边的孩子拢紧了一
点儿,一只手轻轻地抚摩他的小身体,爱的想把他一口吞在肚子里,免被什么魔
鬼见了,一把抓了去,于是她又愁了,于是她又悲了,可是没有忘了哭声,便不
觉哼起来了:
妈在这儿呢,心肝儿睡罢,
别闹啦,别闹哭了妈妈。……
她真也要哭了。可是又觉得好笑:怎么她这样孩子气的,不,简直变成孩子
了——把自己的孩子当作自己的母亲了!不,有什么可笑呢!她反过来一想,这
倒也有道理,她仿佛从不曾有过-一个母亲,至少不记得有过。小时候从小邻居们
的母亲身上看出来,母亲好比一个鸟巢:不论逢到落荫,下雪,或是刮风,小鸟
有这个地方好躲。你觉得闷损得很罢?来!做个好梦去罢,向这含笑的巢门里-一
钻!不错,她小时候,什么叫做挨饿,什么叫做受寒,她是很懂得的。没事的时
候,一个人坐在门槛上,等天黑,也是常有的事。她也想找个巢儿,可是在哪儿
呢?坏脾气的父亲给她的常是打,托寄养的伯父给她的常是骂,伯母给她的常常
是白眼。要是巢儿,她自然得不到这些东西的。后来人大了,她却还常有觅巢的
痴念。她的丈夫待她还不算坏,可是他终年难得有几次在家,就是回来的时候,
对于酒似乎比对于她要关心的多。然而他却给了她一个小巢了。现在她有时候觉
得日子过得太慢,那再不要独自坐在门槛上,瞪着眼看天了,只要看凯儿的小口
cost: 4948.700428009033ms

Process finished with exit code 0

cost: 4948.700428009033ms ,Time is too expensive, have you encountered this situation?

GlassyWing commented 4 years ago

The first inference will cost lot, because of Resource allocation, you can test more times with for-loop

jackCplusplus commented 4 years ago

Thanks! what u told is true!