python - Python 梵文图像提取
问题描述
我试图从使用 python 的手写梵文脚本图像中提取字符,但它只输出一个字母而不是整个段落。
`from keras.preprocessing.image import img_to_array
from keras.models import load_model
import numpy as np
import argparse
import imutils
import cv2
labels = [u'\u091E',u'\u091F',u'\u0920',u'\u0921',u'\u0922',u'\u0923',u'\u0924',u'\u0925',u'\u0926',u'\u0927',u'\u0915',u'\u0928',u'\u092A',u'\u092B',u'\u092c',u'\u092d',u'\u092e',u'\u092f',u'\u0930',u'\u0932',u'\u0935',u'\u0916',u'\u0936',u'\u0937',u'\u0938',u'\u0939','ksha','tra','gya',u'\u0917',u'\u0918',u'\u0919',u'\u091a',u'\u091b',u'\u091c',u'\u091d',u'\u0966',u'\u0967',u'\u0968',u'\u0969',u'\u096a',u'\u096b',u'\u096c',u'\u096d',u'\u096e',u'\u096f']
#
import numpy as np
from keras.preprocessing import image
test_image = cv2.imread("out.jpg")
image = cv2.resize(test_image, (32,32))
image = image.astype("float") / 255.0
image = img_to_array(image)
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = np.expand_dims(image, axis=0)
image = np.expand_dims(image, axis=3)
print("[INFO] loading network...")
import tensorflow as tf
model = tf.keras.models.load_model("HindiModel2.h5")
lists = model.predict(image)[0]
print("The letter is ",labels[np.argmax(lists)])`
这是我使用的代码,还添加了 HindiModel2.h5 和 out.jpg 文件。
链接 - https://drive.google.com/drive/folders/12jbrYg9Dj4QAPjj_887Q-jsQmgUM7AYz?usp=sharing
主 github 的链接 - https://github.com/darklord0303/Hindi-OCR
解决方案
推荐阅读
- pandas - 如何在 Pandas 中为频率计数绘制条形图?
- c++ - 纠正 Xcode 中的工作流程以避免错误:Architecture x86_64 的重复符号
- python - 有选择地替换字符串中的特定嵌套分隔符(括号),同时尊重嵌套
- android - ExoPlayer 强制用户使用软件解码器进行视频和音频
- c - 如何将 char 用户输入单独格式化为二维数组?
- c# - 使用 Task.Factory.FromAsync 创建基于 I/O 的任务
- kotlin - 在 Kotlin/Tomcat/Eclipse/Maven 项目中使用“启用工作区解析”的先决条件是什么?
- faunadb - 为什么我有一个错误“预期参考,提供对象”?
- javascript - 设计 React Hooks 可以防止 react-hooks/exhaustive-deps 警告
- python - 无法使用 beautifulsoup 抓取日本网站