Google colab:如何为 pytesseract 安装训练数据文件?

Google colab : How do i install traineddata file for pytesseract?

在 google colab 上使用 "pip install" 安装 pytesseract 包后,我需要为其他国家语言安装 OCR 训练数据,但是,我不知道在哪里复制它..

如果我使用 "pip install" 自行安装软件包,我 window PC 上的软件包位置在哪里?

在 google 上安装软件包 colab 不会安装在您正在使用的本地驱动器上,启动 colab 环境将创建一个远程驱动器,您可以在其中检出所有项目文件。

如果您想知道特定的 pip 包安装路径,您可以随时使用

!pip show pytesseract-ocr

它将向您显示 Location: 软件包的安装位置,然后您可以随时将必要的文件添加到软件包安装目录

例如,如果我想在 google 云中安装阿拉伯语

我会下载文件 ! wget https://raw.githubusercontent.com/tesseract-ocr/tessdata_best/master/ara.traineddata

然后我会把它移到数据集 ! mv "ara.traineddata" "/usr/share/tesseract-ocr/4.00/tessdata"

然后我将参数传递给 pytesseract,它是 lang='ara' image_path_in_colab="/content/غلاو-الكتاب.jpg" 提取物 = pytesseract.image_to_string(Image.open(image_path_in_colab) , lang='ara')