我正在研究从图像中提取文本(OCR),它应该使用 EAST 在边界框上显示文本。由于 EAST 是 .PB 文件,并且我正在 Jupyter 笔记本上工作。我无法读取该文件。 [net = cv2.dnn.readNet(args["east"]
导致错误:OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp:3780: 错误: (-2:未指定错误) 无法确定文件的原始框架: C:/Python/resnet_v1_50.ckpt in function 'cv::dnn::dnn4_v20190122::readNet)
。有人可以帮忙解决这个问题吗?
我尝试使用 Fantaisie Software 等软件打开/转换 .pb 文件为其他格式,但它们是付费软件,所以我失败了。有没有免费的软件可以读取模型。另外,我无法打开两层layerNames = ["feature_fusion/Conv_7/Sigmoid","feature_fusion/concat_3"]
。
import numpy as np
import cv2
from imutils.object_detection import non_max_suppression
import pytesseract
from matplotlib import pyplot as plt
args = {"image":"C:/Users/temp/Desktop/download.jpg", "east":"C:/Python/resnet_v1_50.ckpt", "min_confidence":0.5, "width":320, "height":320}
args['image']="C:/Users/temp/Desktop/Cheque.jpg"
image = cv2.imread(args['image'])
orig = image.copy()
(origH, origW) = image.shape[:2]
(newW, newH) = (args["width"], args["height"])
rW = origW / float(newW)
rH = origH / float(newH)
image = cv2.resize(image, (newW, newH))
(H, W) = image.shape[:2]
blob = cv2.dnn.blobFromImage(image, 1.0, (W, H),(123.68, 116.78, 103.94), swapRB=True, crop=False)
net = cv2.dnn.readNet(args["east"])
layerNames = ["feature_fusion/Conv_7/Sigmoid","feature_fusion/concat_3"]
net.setInput(blob)
(scores, geometry) = net.forward(layerNames)
太棒了...onnnnn
无法加载和运行模型
最佳答案
您应该从此 link 加载您的 dnn 文件.
将“frozen_east_text_detection.pb”文件解压到桌面。
您需要像这样更改代码:
net = cv2.dnn.readNet('C:\\Users\\Desktop\\frozen_east_text_detection.pb')
它将成功加载。
编辑:这些错误是由于无法读取文件而发生的。
cv::dnn::dnn4_v20190122::readNet
关于python - 我无法在 jupyter 笔记本中读取 EAST : An Efficient and Accurate Scene Text Detector as . pb 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57690559/