Formula Recognition demo

image を LaTexに変換してくれるFormula RecognitionがOpenVINO 2021からはいったので、試してみます

実行環境

CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
MemTotal:       4002276 kB
OS: Ubuntu 20.04LTS
vmware上で実行

モデルのダウンロード

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/downloader.py –list models.lst -o ~/openvino_models/

最低限動作させるオプション

Options:
-h, –help Show this help message and exit.
-m_encoder M_ENCODER Required. Path to an .xml file with a trained encoder part of the model
-m_decoder M_DECODER Required. Path to an .xml file with a trained decoder part of the model
-i INPUT, –input INPUT
Required. Path to a folder with images or path to an image files
-o OUTPUT_FILE, –output_file OUTPUT_FILE
Optional. Path to file where to store output. If not mentioned, result will be storedin the console.
–vocab_path VOCAB_PATH
Required. Path to vocab file to construct meaningful phrase

この中で、vocab pathが必須になっています
今回は、
https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/intel/formula-recognition-medium-scan-0001
からvocab.jsonをダウンロードして使用します

imageファイルはサンプルでついてくる下記のものを使用します

実行

/opt/intel/openvino_2021/deployment_tools/open_model_zoo/demos/python_demos/formula_recognition_demo/formula_recognition_demo.py -m_encoder ~/openvino_models/intel/formula-recognition-medium-scan-0001/formula-recognition-medium-scan-0001-im2latex-encoder/FP16/formula-recognition-medium-scan-0001-im2latex-encoder.xml -m_decoder ~/openvino_models/intel/formula-recognition-medium-scan-0001/formula-recognition-medium-scan-0001-im2latex-decoder/FP16/formula-recognition-medium-scan-0001-im2latex-decoder.xml –vocab_path vocab.json -i sample.png

結果

Formula: 4 7 4 W ^ { 1 } + 7 . 1 9 o ^ { 4 } – 6 – 0 . 9 6 L ^ { 1 } y

ちゃんと認識されているようです

少しオプションがわかりにくいので、調査が進み次第、第2弾に続けたいと思います