计算机视觉(特别是OCR)变得非常缓慢 [英] Computer Vision (OCR specifically) has become very slow

查看:243
本文介绍了计算机视觉(特别是OCR)变得非常缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用OCR服务,这很棒。但是今天当我上传图片时,我需要大约15秒钟才能收到回复。过去不到1秒钟。此外,当我在此页面上的测试表单上上传相同的图像
时(我无法共享链接,但是微软/
认知服务/ en-us / computer-vision-api)< span lang ="EN"> 我很快就得到了结果。  我在我的正常应用程序中尝试过,但也使用了curl命令
进行测试,结果类似(慢)。 / p>

为什么我的API密钥结果现在变慢了?还有其他人遇到过这种情况吗?关于如何修复它的任何建议?



谢谢,


Justin




解决方案

有关更多信息,我有一个程序上传相同的图像进行多次分析。现在每次OCR调用需要40到57秒:

 ########### Python 2.7 ######## ##### 
导入httplib,urllib,base64

headers = {
#基本授权示例
#'授权':'基本%s'%base64 .encodestring('{username}:{password}'),
'Content-type':'application / json',
}

params = urllib.urlencode({
#指定您的订阅密钥
'subscription-key':'***',
#根据需要指定可选参数的值
'language':'unk',
'sensseOrientation':'true',
})

导入timeit
all = []
while(True):
start = timeit.default_timer()
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request(" POST"," / vision / v1 / ocr?%s"%params," {'Url':'https://dl.dropboxusercontent.com/u/1649204/1.jpg'}",h eaders)
response = conn.getresponse()
data = response.read()
#print(data)
conn.close()
total = timeit。 default_timer() - 开始
all.append(总计)
print" this one:",total,"总平均值:",总和(全部)/ len(全部)
如果len(全部)> 15:
退出()

除了例外e:
print(" [Errno {0}] {1}" .format(e.errno,e。 strerror))

输出:

这一个:56.8245482852总平均值:56.8245482852 
这个:50.5558305523总平均值:53.6901894188
这一个:40.8799573937总平均值:49.4201120771
这一个:43.973192223总平均值:48.0583821136
这一个:40.6850083243总平均值:46.5837073557
这一个:52.1188436133总体平均值:47.5062300653
这一个:46.2044174422总平均值:47.3202568334

但是,当我使用相同的图像时API控制台(抱歉无法粘贴链接),时间大多是<1s,但有些是4s范围,有些高达30s(都使用相同的图像)。



谢谢,


Justin



I've been using the OCR service, and it is great. However today when I upload an image it takes around 15 seconds before I get my response. It used to take less than 1 second. Also, when I upload the same image on the test form on this page (I am unable to share a link, but microsoft/cognitive-services/en-us/computer-vision-api) I get the results quickly. I have tried in my normal application, but also used the curl command to test, with similar (slow) results.

Is there any reason why my results with my API key are slow now? Is anyone else experiencing this? Any suggestions on how I could fix it?

Thanks,

Justin


解决方案

For a little more information, I had a program upload the same image for analysis multiple times. It is now taking between 40 and 57 seconds per OCR call:

########### Python 2.7 #############
import httplib, urllib, base64

headers = {
   # Basic Authorization Sample
   # 'Authorization': 'Basic %s' % base64.encodestring('{username}:{password}'),
   'Content-type': 'application/json',
}

params = urllib.urlencode({
   # Specify your subscription key
   'subscription-key': '***',
   # Specify values for optional parameters, as needed
   'language': 'unk',
   'detectOrientation ': 'true',
})

import timeit
all = []
while (True):
    start = timeit.default_timer()
    try:
       conn = httplib.HTTPSConnection('api.projectoxford.ai')
       conn.request("POST", "/vision/v1/ocr?%s" % params, "{'Url':'https://dl.dropboxusercontent.com/u/1649204/1.jpg'}", headers)
       response = conn.getresponse()
       data = response.read()
       #print(data)
       conn.close()
       total = timeit.default_timer() - start
       all.append(total)
       print "this one: ", total, "   overall average: ", sum(all)/len(all)
       if len(all) > 15:
           exit()

    except Exception as e:
       print("[Errno {0}] {1}".format(e.errno, e.strerror))

Output:

this one:  56.8245482852    overall average:  56.8245482852
this one:  50.5558305523    overall average:  53.6901894188
this one:  40.8799573937    overall average:  49.4201120771
this one:  43.973192223    overall average:  48.0583821136
this one:  40.6850083243    overall average:  46.5837073557
this one:  52.1188436133    overall average:  47.5062300653
this one:  46.2044174422    overall average:  47.3202568334

However, when I use the same image on the API console (sorry can't paste a link), the times are mostly <1s, but some are in the 4s range, and some are as high as 30s (all using the same image).

Thanks,

Justin


这篇关于计算机视觉(特别是OCR)变得非常缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆