テキスト検出とOCR(光学的文字認識)ができる「keras-ocr」のインストール

【Python】テキスト検出とOCR(光学的文字認識)ができる「keras-ocr」のインストールについて解説しています。

「keras-ocr(https://github.com/faustomorales/keras-ocr)」は、KerasのCRNN実装と公開されているCRAFTテキスト検出モデルを少し洗練させてパッケージ化したものです。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■keras-ocrをインストールする

keras-ocrをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install keras-ocr

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install keras-ocr

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting keras-ocr
Downloading keras_ocr-0.9.1-py3-none-any.whl (42 kB)
---------------------------------------- 42.3/42.3 kB 1.0 MB/s eta 0:00:00
Collecting essential_generators
Downloading essential_generators-1.0-py3-none-any.whl (9.5 MB)
---------------------------------------- 9.5/9.5 MB 3.1 MB/s eta 0:00:00
Requirement already satisfied: fonttools in c:\users\user_\appdata\roaming\python\python38\site-packages (from keras-ocr) (4.30.0)
Collecting shapely
Downloading Shapely-1.8.2-cp38-cp38-win_amd64.whl (1.3 MB)
---------------------------------------- 1.3/1.3 MB 5.1 MB/s eta 0:00:00
Collecting editdistance
Downloading editdistance-0.6.0-cp38-cp38-win_amd64.whl (24 kB)
Collecting pyclipper
Downloading pyclipper-1.3.0.post3-cp38-cp38-win_amd64.whl (95 kB)
---------------------------------------- 95.2/95.2 kB 5.7 MB/s eta 0:00:00
Collecting efficientnet==1.0.0
Downloading efficientnet-1.0.0-py3-none-any.whl (17 kB)
Requirement already satisfied: tqdm in c:\users\user_\appdata\roaming\python\python38\site-packages (from keras-ocr) (4.60.0)
Requirement already satisfied: validators in c:\users\user_\appdata\roaming\python\python38\site-packages (from keras-ocr) (0.18.2)
Collecting imgaug
Downloading imgaug-0.4.0-py2.py3-none-any.whl (948 kB)
---------------------------------------- 948.0/948.0 kB 5.5 MB/s eta 0:00:00
Requirement already satisfied: scikit-image in c:\users\user_\appdata\roaming\python\python38\site-packages (from efficientnet==1.0.0->keras-ocr) (0.18.3)
Collecting keras-applications<=1.0.8,>=1.0.7
Downloading Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
---------------------------------------- 50.7/50.7 kB ? eta 0:00:00
Requirement already satisfied: matplotlib in c:\users\user_\appdata\roaming\python\python38\site-packages (from imgaug->keras-ocr) (3.4.2)
Requirement already satisfied: numpy>=1.15 in c:\users\user_\appdata\roaming\python\python38\site-packages (from imgaug->keras-ocr) (1.21.5)
Requirement already satisfied: scipy in c:\users\user_\appdata\roaming\python\python38\site-packages (from imgaug->keras-ocr) (1.7.0)
Requirement already satisfied: imageio in c:\users\user_\appdata\roaming\python\python38\site-packages (from imgaug->keras-ocr) (2.9.0)
Requirement already satisfied: six in c:\users\user_\appdata\roaming\python\python38\site-packages (from imgaug->keras-ocr) (1.12.0)
Requirement already satisfied: opencv-python in c:\users\user_\appdata\roaming\python\python38\site-packages (from imgaug->keras-ocr) (4.5.2.54)
Requirement already satisfied: Pillow in c:\users\user_\appdata\roaming\python\python38\site-packages (from imgaug->keras-ocr) (9.1.1)
Requirement already satisfied: decorator>=3.4.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from validators->keras-ocr) (5.1.1)
Requirement already satisfied: h5py in c:\users\user_\appdata\roaming\python\python38\site-packages (from keras-applications<=1.0.8,>=1.0.7->efficientnet==1.0.0->keras-ocr) (3.1.0)
Requirement already satisfied: networkx>=2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from scikit-image->efficientnet==1.0.0->keras-ocr) (2.6.3)
Requirement already satisfied: tifffile>=2019.7.26 in c:\users\user_\appdata\roaming\python\python38\site-packages (from scikit-image->efficientnet==1.0.0->keras-ocr) (2021.11.2)
Requirement already satisfied: PyWavelets>=1.1.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from scikit-image->efficientnet==1.0.0->keras-ocr) (1.1.1)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from matplotlib->imgaug->keras-ocr) (2.3.1)
Requirement already satisfied: cycler>=0.10 in c:\users\user_\appdata\roaming\python\python38\site-packages (from matplotlib->imgaug->keras-ocr) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from matplotlib->imgaug->keras-ocr) (1.3.1)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\user_\appdata\roaming\python\python38\site-packages (from matplotlib->imgaug->keras-ocr) (2.8.0)
Installing collected packages: pyclipper, essential_generators, shapely, editdistance, keras-applications, imgaug, efficientnet, keras-ocr
Successfully installed editdistance-0.6.0 efficientnet-1.0.0 essential_generators-1.0 imgaug-0.4.0 keras-applications-1.0.8 keras-ocr-0.9.1 pyclipper-1.3.0.post3 shapely-1.8.2

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、keras-ocrが正常にインストールされたことになります。

なお、今回はkeras-ocrのバージョン0.9.1をインストールしました。

コメント

タイトルとURLをコピーしました