このページの内容
- 2.x → 3.x コード変換ツール
- 3.x で何が変わったのか、そしてその理由
- use_angle_cls と、今も使える 11 個の旧名
- use_gpu、show_log、use_onnx、drop_score は警告ではなくエラー
- ocr(img, cls=True) と新しい結果の形式
- cannot import name 'draw_ocr' from 'paddleocr'
- det_model_dir と rec_model_dir:独自モデル
- 黙って変わった既定値
- PPStructure → PPStructureV3
- コマンドライン:paddleocr --image_dir → paddleocr ocr -i
- 2.x → 3.x の完全な対応表
- 2.x を使い続ける:paddleocr を 3 未満に固定
- 移行チェックリスト
- よくある質問
結論:use_angle_cls を use_textline_orientation に変更し、use_gpu=True を device='gpu' に置き換え、show_log を削除し、cls= を付けずに ocr.predict(img) を呼び、line[1][0] の代わりに res['rec_texts']、res['rec_scores']、res['rec_polys'] を読みます。draw_ocr は res.save_to_img('output') に置き換えます。下の変換ツールがこれらをすべて自動で行い、安全に変換できない箇所は警告します。
2.x → 3.x コード変換ツール#
PaddleOCR 2.x のコードまたはコマンドを貼り付け#
ブラウザ内で実行手動で確認する箇所
すべての変更点(理由と出典付き)
変換ツールは推測ではなく、ルールに基づいて動作します。理解できるパターンだけを書き換え、変更ごとに根拠となる PaddleOCR のソース行を示し、人の判断が必要な箇所には # TODO(paddleocr 3.x) コメントを残します。最初の 2 つのサンプルの出力を PaddleOCR 3.7.0 で実行したところ、どちらもエラーなく動作してテスト用レシートの 27 行すべてを読み取り、1 つ目は result.jpg を書き出しました。なお、ツールが表示する変更点の説明は英語です。7
3.x で何が変わったのか、そしてその理由#
PaddleOCR 2.x は 2021 年から 2025 年初めにかけて、1 つの軽量なコードベースに機能を追加する形で成長しました。メンテナーのアップグレードノートによると、その方法は限界に達していました。コードの重複、一貫性のないインターフェース、新しい PaddlePaddle では動かなくなった古い依存関係です。その答えが「後方互換性のない大規模なアップグレード」でした。2 3.x の paddleocr パッケージは PaddleX のパイプラインを包む薄いラッパーで、PaddleOCR は PaddleX の OCR パイプラインをラップして結果オブジェクトを返します。1
- paddleocr 2.7.0.3 — 古い
requirements.txtで今もよく固定されているバージョン。 - paddleocr 2.10.0 — 最後の 2.x リリース。
- paddleocr 3.0.0 — PaddleX ベースの新しい API。
- paddleocr 3.7.0 — 現行リリース。既定で PP-OCRv6 モデルを使用。
日付は PyPI への最初のアップロード日です。6 現在バージョンを指定せずに paddleocr をインストールすると 3.7.0 が入るため、新しい環境を作った時点で 2.x のコードは動かなくなります。原因となる変更は次のとおりです。
未知の引数はエラーに#
変換される旧パラメータ名は 11 個だけです。use_gpu や show_log を含むそれ以外はすべて ValueError: Unknown argument になります。
ocr() のスイッチが廃止#
cls、det、rec、bin、inv、slice はなくなりました。ocr() は predict() の非推奨エイリアスです。
結果はオブジェクトに#
行ごとの [box, (text, score)] ではなく、ページごとに並列リストを持つ OCRResult が 1 つ返ります。旧来のインデックス参照は KeyError: 0 になります。
ヘルパーと PPStructure を削除#
draw_ocr、save_structure_res などは廃止され、結果オブジェクト自身が保存・描画します。PPStructure は PPStructureV3 になりました。
このほか、エラーにはならないものの出力が変わる変更が 2 つあります。新しい既定のモデルと前処理(黙って変わった既定値で解説)、そして推論エンジンのインストールです。3.x の pip install paddleocr では PaddlePaddle はインストールされず、PyPI の paddlepaddle-gpu パッケージは 2.6.2 で止まっています。インストールガイドを参照してください。
use_angle_cls と、今も使える 11 個の旧名#
3.x には、PaddleOCR の旧キーワード引数を変換する小さな対応表があります。ソースからそのまま引用した完全な一覧です。1
_DEPRECATED_PARAM_NAME_MAPPING = {
"det_model_dir": "text_detection_model_dir",
"det_limit_side_len": "text_det_limit_side_len",
"det_limit_type": "text_det_limit_type",
"det_db_thresh": "text_det_thresh",
"det_db_box_thresh": "text_det_box_thresh",
"det_db_unclip_ratio": "text_det_unclip_ratio",
"rec_model_dir": "text_recognition_model_dir",
"rec_batch_num": "text_recognition_batch_size",
"use_angle_cls": "use_textline_orientation",
"cls_model_dir": "textline_orientation_model_dir",
"cls_batch_num": "textline_orientation_batch_size",
}これらを渡すと、3.x が警告付きで名前を変換します。3.7.0 で PaddleOCR(lang='en', use_angle_cls=True) を実行すると、次のとおり出力されました。7
DeprecationWarning: The parameter `use_angle_cls` has been deprecated and will be removed in the future. Please use `use_textline_orientation` instead.Python は __main__ から発生したもの以外の DeprecationWarning を既定で表示しないため、この警告に気づかない人も多くいます。この対応表の周辺のコードから、次の 3 つのルールがわかります。1
- 旧名と新名の併用はエラー。
PaddleOCR(use_angle_cls=True, use_textline_orientation=True)はValueError: `use_angle_cls` and `use_textline_orientation` are mutually exclusive.になります(再現済み)。 - 対応表があるのは
PaddleOCRだけ。PPStructureV3(det_model_dir=...)とPPStructureV3(use_angle_cls=True)はValueError: Unknown argument: det_model_dir/use_angle_clsになります。どちらも再現済みです。 - 「使える」は「同じ挙動」ではない。2.x の
use_angle_clsの既定値はFalseでした。3.x でuse_textline_orientationを指定しないとパイプラインの既定値が使われ、それはTrueです。5
同じ 11 個は paddleocr ocr の CLI フラグとしても存在します。--use_angle_cls は引き続き動作し、CLIDeprecationWarning: The option `--use_angle_cls` has been deprecated and will be removed in the future. Please refer to the documentation for more details. と表示されます。
use_gpu、show_log、use_onnx、drop_score は警告ではなくエラー#
それ以外の残ったキーワード引数はすべて、3.x のエンジンオプションだけを受け付ける次のループに引っかかります。1
unknown_names = kwargs.keys() - default_vals.keys()
for name in unknown_names:
raise ValueError(f"Unknown argument: {name}")最初に見つけた名前でエラーを送出し、しかも unknown_names は集合なので、古い引数が 3 つあるコンストラクタでも 1 回の実行で報告されるのは 1 つだけです。下の表か変換ツールを使って、まとめて修正してください。3.7.0 での再現結果です。7
use_gpu=True -> ValueError: Unknown argument: use_gpu
show_log=False -> ValueError: Unknown argument: show_log
use_onnx=True -> ValueError: Unknown argument: use_onnx
drop_score=0.5 -> ValueError: Unknown argument: drop_score| 2.x | 3.x での置き換え | 備考 |
|---|---|---|
use_gpu=True | device='gpu' | または 'gpu:1'。device を指定しない場合、3.x は PaddlePaddle が CUDA GPU を認識していれば GPU 0、そうでなければ CPU を使います。 |
use_gpu=False | device='cpu' | 'cpu:0' は拒否されます。CPU には番号を付けません。 |
gpu_id=1 | device='gpu:1' | ID はデバイス文字列に含めます。 |
gpu_mem=500 | — | 相当するものはありません。メモリ不足のエラーは GPU の OOM を参照してください。 |
use_xpu / use_npu / use_mlu / use_gcu | device='xpu' など | 対応するデバイスの種類:cpu、gpu、xpu、npu、mlu、gcu、dcu、iluvatar_gpu、metax_gpu。 |
show_log=False | 削除する | 新しい paddleocr ロガーは最初から ERROR レベルです。より多く出力するには logger.setLevel(logging.INFO)。 |
use_onnx=True | engine='onnxruntime' | PaddleOCR 3.5 以降。pip install onnxruntime が必要です。私たちのテストでは、3.7.0 は onnxruntime だけ(PaddlePaddle なし)で動作しました。 |
drop_score=0.5 | text_rec_score_thresh=0.5 | エイリアスではありません。3.x の既定値は 0.0 なので、指定しない限り何も除外されません。 |
rec_image_shape='3, 48, 320' | text_rec_input_shape=(3, 48, 320) | 文字列ではなくタプルになりました。 |
逆方向のよくある間違いが device='cuda' です。PaddleX はこれを単純な AssertionError で拒否します。GPU のデバイス種別名は gpu です。
ocr(img, cls=True) と新しい結果の形式#
3.x にも ocr() メソッドはありますが、キーワード引数を predict() に転送するだけの非推奨エイリアスです。1
@deprecated("Please use `predict` instead.")
def ocr(self, img, **kwargs):
return self.predict(img, **kwargs)predict() には cls パラメータがないため、2.x のほぼすべてのチュートリアルにある行が失敗します。3.7.0 では次のようになりました。7
TypeError: PaddleOCR.predict() got an unexpected keyword argument 'cls'テキスト行の向き分類は、オブジェクトの作成時(use_textline_orientation=True)か、呼び出しごとに predict(img, use_textline_orientation=False) で指定するようになりました。PaddleX のソースから読み取れる注意点が 1 つあります。呼び出しごとにオフにすることはできますが、オフで作成したオブジェクトで呼び出し時にオンにしようとすると、処理は実行されずエラーがログに出力されます。
より大きな変化は戻り値です。2.x の ocr() は画像ごとにリストを返し、各行が [box, (text, score)]、文字が見つからなければ None でした。3 3.x の predict() は、画像または PDF のページごとに OCRResult を 1 つ返します。これは並列リストを持つ dict です。5
| キー | 内容 |
|---|---|
rec_texts | 各行の認識テキスト(text_rec_score_thresh 以上の行) |
rec_scores | 各行の信頼度スコア |
rec_polys | 各行のポリゴン:形状 (4, 2) の int16 NumPy 配列 |
rec_boxes | 軸平行な検出枠、形状 (n, 4):[x_min, y_min, x_max, y_max] |
dt_polys | 検出されたすべての枠(スコアのフィルタは適用されない) |
input_path、page_index | 結果の入力元 |
このオブジェクトに対して古いループがどう動くかを知っておく価値があります。エラーメッセージに PaddleOCR がまったく出てこないからです。for line in result[0] は dict のキーを走査するため、最初の line は文字列 'input_path' になり、box, (text, score) = line は ValueError: too many values to unpack (expected 2) になります。result[0][0][1][0] のようなインデックス参照は KeyError: 0 になります。どちらも再現済みです。7
result = ocr.ocr(img_path, cls=True)
for line in result[0]:
box, (text, score) = line
print(text, score, box)result = ocr.predict(img_path)
for res in result: # one OCRResult per image / PDF page
for box, text, score in zip(res['rec_polys'], res['rec_texts'], res['rec_scores']):
print(text, score, box.tolist())変換後につまずきやすい点が 3 つあります。ポリゴンは NumPy 配列なので、json.dumps の前に .tolist() を呼ぶ(または res.json を使う)必要があります。文字のないページでは None ではなく空のリストが返るため、if result[0] is None は決して成立しません。if not res['rec_texts'] で判定してください。そして既定の use_doc_unwarping=True では、座標は歪み補正後の画像を基準にします。私たちのレシートでは、最初の行が歪み補正ありで [[119,11],[507,8],[507,46],[120,49]]、なしで [[128,55],[489,55],[489,82],[128,82]] でした。7 詳しくは検出枠が合わないを参照してください。
ocr(img, det=False) と ocr(img, rec=False) に相当するパイプラインの機能はありません。単体モデルのクラスを使います。TextRecognition(model_name="PP-OCRv6_medium_rec").predict(crop) は rec_text と rec_score を、TextDetection(model_name="PP-OCRv6_medium_det").predict(img) は dt_polys と dt_scores を返します。切り出し画像をどう作っているかを推測せずに済むよう、変換ツールはこれらの呼び出しに TODO を付けます。
cannot import name 'draw_ocr' from 'paddleocr'#
draw_ocr は paddleocr 2.10.0 ではエクスポートされていましたが、3.x のパッケージにはないため、インポートが失敗します。7
ImportError: cannot import name 'draw_ocr' from 'paddleocr'現在は結果オブジェクト自身が描画します。アップグレードノートでは、可視化のブロック全体を 1 回の呼び出しに置き換えています。2
from PIL import Image
from paddleocr import draw_ocr
result = result[0]
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path='simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')for res in result:
res.save_to_img('output') # writes <name>_ocr_res_img.png (+ preprocessed image)
pil_image = res.img['ocr_res_img'] # or keep it in memory as a PIL image私たちのレシートでは、save_to_img('output') が receipt_ocr_res_img.png と receipt_preprocessed_img.png を書き出し、res.img にも同じ 2 つのキーがありました。7 独自のフォントを使うには、font_path を渡す代わりに環境変数 PADDLE_PDX_LOCAL_FONT_FILE_PATH を設定します。削除されたほかのヘルパーも同様に対応します。save_structure_res → res.save_to_json()、save_to_xlsx()、save_to_html()、save_all()、convert_info_docx → res.save_to_word()、to_excel → res.save_to_xlsx()。5
det_model_dir と rec_model_dir:独自モデル#
det_model_dir、rec_model_dir、cls_model_dir は 11 個のエイリアスに含まれるため、PaddleOCR では引き続き使えます。ただし内部では次の点が変わります。
- モデル名も指定する。
text_detection_model_dirだけを指定すると、パイプラインは既定の名前(PP-OCRv6_medium_det)のままとなり、PaddleX がそれをフォルダー内のinference.ymlの名前と比較します。結果はValueError: Model name mismatch: expected 'PP-OCRv6_medium_det' but config has 'PP-OCRv5_server_det'. Please input the correct model dir.です。5 - フォルダーは 3.x 形式のエクスポートが必要。3.x は
inference.jsonまたはinference.pdmodelに加え、inference.pdiparamsとinference.ymlを探します。有効なファイルがないフォルダーではNo valid model files were found for engine 'paddle_static'になります。 - 学習時のオプションは廃止。
rec_char_dict_path、rec_algorithm、det_algorithm、use_space_char、max_text_lengthはUnknown argumentになります。モデルは名前で選び、モジュールごとの設定はエクスポートした PaddleX の設定ファイルで行います(export_paddlex_config_to_yamlでエクスポートし、paddlex_config=...で指定)。
from paddleocr import PaddleOCR
ocr = PaddleOCR(
text_detection_model_name='PP-OCRv5_server_det',
text_detection_model_dir='./models/PP-OCRv5_server_det_infer',
text_recognition_model_name='PP-OCRv5_server_rec',
text_recognition_model_dir='./models/PP-OCRv5_server_rec_infer',
)モデル名やフォルダーを指定すると、lang と ocr_version は UserWarning とともに無視されます。また、2.x の文字体系グループの値 lang='latin'、'arabic'、'cyrillic'、'devanagari' は 3.x では言語コードではなく、No models are available for lang='latin' and ocr_version=None. になります。言語一覧 から実際のコードを選んでください。
黙って変わった既定値#
移行後に動くようになったコードでも、既定値が変わったため、テキスト・検出枠・速度が異なる場合があります。53
| 設定 | 2.x の既定値 | 3.x の既定値 |
|---|---|---|
| モデル | PP-OCRv4 | PP-OCRv6_medium の det + rec |
| 文書の向き補正 | — | オン(use_doc_orientation_classify) |
| ページの歪み補正(UVDoc) | — | オン(use_doc_unwarping) |
| テキスト行の向き分類 | オフ(use_angle_cls=False) | オン(use_textline_orientation) |
| テキスト検出のリサイズ | 960、max | 64、min(最大辺 4000) |
| スコアのフィルタ | 0.5(drop_score) | 0.0(text_rec_score_thresh) |
| CPU での oneDNN | オフ | オン(enable_mkldnn=True) |
変換ツールの「2.x の挙動を維持する」オプションは、エラーデータベースが 2.x に近い出力のために推奨する 4 つのスイッチを追加します:use_doc_orientation_classify=False、use_doc_unwarping=False、use_textline_orientation=False、text_rec_score_thresh=0.5。前処理モデルをオフにすると 3.x の処理も速くなります。モデルは新しいものを使い続けます。新モデルは 5 つのテスト文書で 124 項目中 123 項目を完全に読み取りました(ベンチマーク (EN))。
oneDNN の既定値は新規インストールで問題になります。enable_mkldnn=True と PaddlePaddle 3.3.1(現在 pip install paddlepaddle で入るバージョン)の組み合わせでは、CPU 推論が ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttribute<pir::DoubleAttribute>] でクラッシュします。paddlepaddle==3.2.0 に固定してください。詳細と計測結果:oneDNN の解決策。
PPStructure → PPStructureV3#
3.x では from paddleocr import PPStructure が ImportError: cannot import name 'PPStructure' from 'paddleocr' で失敗します。アップグレードノートが案内する移行先は PPStructureV3 で、追加のインストールが必要です。28
python -m pip install "paddleocr[doc-parser]"これがないと、PPStructureV3() は RuntimeError: A dependency error occurred during pipeline creation で失敗します(解決策)。コンストラクタには独自のパラメータがあり、エイリアスの対応表はありません。そのため PaddleOCR で使える名前でもここではエラーになります。3.7.0 の PPStructureV3 では、use_gpu、det_model_dir、use_angle_cls、show_log で Unknown argument になりました。7
| PPStructure(2.x) | PPStructureV3(3.x) |
|---|---|
use_gpu=True | device='gpu' |
table=False | use_table_recognition=False |
formula=True | use_formula_recognition=True(現在は既定でオン) |
image_orientation=True | use_doc_orientation_classify=True |
layout_model_dir | layout_detection_model_dir + layout_detection_model_name |
table_model_dir | 分割:wired_table_structure_recognition_model_dir / wireless_… |
recovery=True | res.save_to_word(dir) / res.save_to_markdown(dir) |
layout=False、ocr=False | スイッチなし:PaddleOCR または TableRecognitionPipelineV2 を使う |
mode='kie' | PP-ChatOCRv4(pip install "paddleocr[ie]") |
from paddleocr import PPStructure, save_structure_res
table_engine = PPStructure(show_log=True, image_orientation=True, use_gpu=True)
img = cv2.imread(img_path)
result = table_engine(img)
save_structure_res(result, './output', os.path.basename(img_path).split('.')[0])
for line in result:
line.pop('img')
print(line)from paddleocr import PPStructureV3
pipeline = PPStructureV3(use_doc_orientation_classify=True, device='gpu')
output = pipeline.predict(img_path) # one result per page; PDFs work directly
for res in output:
res.print()
res.save_to_json('output')
res.save_to_markdown('output') # also: save_to_word, save_to_html, save_to_xlsx, save_to_img2.x の構造解析の結果は 1 画像分の領域 dict のリストでしたが、3.x の結果はページごとに 1 つのオブジェクトです。出力の詳細や既定で使われる OCR モデルについては、PP-StructureV3 ガイド で解説しています。
コマンドライン:paddleocr --image_dir → paddleocr ocr -i#
3.x の CLI はサブコマンドが必須で、入力は -i で指定します。2.x の書き方は分かりにくい形で失敗します。argparse がファイル名をサブコマンドとして解釈するためです。3.7.0 での実行結果です。7
usage: paddleocr [-h] [-v] COMMAND ...
paddleocr: error: argument COMMAND: invalid choice: 'receipt.png' (choose from 'doc_preprocessor', 'doc_understanding', 'formula_recognition_pipeline', 'ocr', 'doc_parser', 'pp_chatocrv4_doc', 'pp_doctranslation', 'pp_structurev3', ...)| 2.x のコマンド | 3.x のコマンド |
|---|---|
paddleocr --image_dir x.png --use_angle_cls true --lang en | paddleocr ocr -i x.png --use_textline_orientation True --lang en |
--use_gpu false | --device cpu(--use_gpu は unrecognized arguments になる) |
--type structure --recovery true --output ./out | paddleocr pp_structurev3 -i x.pdf --save_path ./out |
--det false | paddleocr text_recognition -i crop.png |
--rec false | paddleocr text_detection -i x.png |
--use_onnx true | --engine onnxruntime |
--det_model_dir d --rec_model_dir r | --text_detection_model_dir d --text_recognition_model_dir r |
真偽値のフラグは true/True/1 を受け付け、それ以外は false として扱われます。私たちのレシートで --save_path を付けて paddleocr ocr を実行したところ、結果を表示し、JSON と 2 つの画像を書き出しました。シェルスクリプト全体を変換ツールに貼り付けることもできます。paddleocr と pip install の行だけを書き換え、それ以外はそのまま残します。
2.x → 3.x の完全な対応表#
変換ツールと同じデータから生成した、検証済みの対応表全 123 項目です。「エイリアス(警告)」は旧名が引き続き使えること、「名称変更」は変更が必要なこと、「置き換え」と「削除」は残しておくとエラーになることを意味します。すべての行に、私たちが確認したファイルと行へのリンクがあります。「変更内容」列の説明は英語のままです。135
インポート 13#
| 2.x | 3.x | 変更内容(英語) | 出典 |
|---|---|---|---|
from paddleocr import PaddleOCR | from paddleocr import PaddleOCR | 変更 Same import name; the class is now a wrapper around the PaddleX 'OCR' pipeline and returns result objects instead of nested lists. | PaddleOCR/paddleocr/__init__.py:32-43; PaddleOCR/paddleocr/_pipelines/ocr.py:66,175-177 |
from paddleocr import PPStructure | from paddleocr import PPStructureV3 | 置き換え PPStructure was removed in 3.x; the upgrade notes recommend PPStructureV3. Needs the doc-parser dependency group: pip install "paddleocr[doc-parser]". | PaddleOCR/docs/update/upgrade_notes.en.md:73; PaddleOCR/paddleocr/__init__.py:84-131 (no PPStructure in __all__); PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:963 |
from paddleocr import draw_ocr | — | 削除 draw_ocr was exported by paddleocr 2.10.0 but is not exported by 3.x; importing it raises ImportError. See the matching 'util' entry for the replacement. | paddleocr-2.10.0/paddleocr/__init__.py:14-24,32-42; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr import draw_structure_result | — | 削除 draw_structure_result was exported by paddleocr 2.10.0 but is not exported by 3.x; importing it raises ImportError. See the matching 'util' entry for the replacement. | paddleocr-2.10.0/paddleocr/__init__.py:14-24,32-42; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr import save_structure_res | — | 削除 save_structure_res was exported by paddleocr 2.10.0 but is not exported by 3.x; importing it raises ImportError. See the matching 'util' entry for the replacement. | paddleocr-2.10.0/paddleocr/__init__.py:14-24,32-42; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr import download_with_progressbar | — | 削除 download_with_progressbar was exported by paddleocr 2.10.0 but is not exported by 3.x; importing it raises ImportError. See the matching 'util' entry for the replacement. | paddleocr-2.10.0/paddleocr/__init__.py:14-24,32-42; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr import sorted_layout_boxes | — | 削除 sorted_layout_boxes was exported by paddleocr 2.10.0 but is not exported by 3.x; importing it raises ImportError. See the matching 'util' entry for the replacement. | paddleocr-2.10.0/paddleocr/__init__.py:14-24,32-42; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr import convert_info_docx | — | 削除 convert_info_docx was exported by paddleocr 2.10.0 but is not exported by 3.x; importing it raises ImportError. See the matching 'util' entry for the replacement. | paddleocr-2.10.0/paddleocr/__init__.py:14-24,32-42; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr import to_excel | — | 削除 to_excel was exported by paddleocr 2.10.0 but is not exported by 3.x; importing it raises ImportError. See the matching 'util' entry for the replacement. | paddleocr-2.10.0/paddleocr/__init__.py:14-24,32-42; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr import convert_info_markdown | — | 削除 Listed in 2.10.0 paddleocr.py __all__ (not re-exported by the package __init__). No 3.x export; use PPStructureV3 result .save_to_markdown(). | paddleocr-2.10.0/paddleocr/paddleocr.py:73-84; PaddleOCR/paddleocr/__init__.py:84-131 |
from paddleocr.tools.infer.utility import ... / from paddleocr.ppocr... / from paddleocr.ppstructure... | — | 削除 The 2.x wheel bundled tools/, ppocr/ and ppstructure/ inside the paddleocr package. The 3.x package only contains paddleocr/ (setuptools include = paddleocr, paddleocr.*), whose public API is the __all__ list. | paddleocr-2.10.0/paddleocr/(wheel contains paddleocr/tools, paddleocr/ppocr, paddleocr/ppstructure); PaddleOCR/pyproject.toml:61-64; PaddleOCR/paddleocr/__init__.py:84-131 |
(new in 3.x) module classes | from paddleocr import TextDetection, TextRecognition, TextLineOrientationClassification, LayoutDetection, ... | 変更 3.x exposes single-model classes used to replace ocr(det=False) / ocr(rec=False). | PaddleOCR/paddleocr/__init__.py:17-31 |
from paddleocr import logger (did not exist in 2.x; 2.x used show_log) | from paddleocr import logger | 変更 3.x uses a single logging.Logger named 'paddleocr', level ERROR by default. | PaddleOCR/paddleocr/__init__.py:66; PaddleOCR/paddleocr/_utils/logging.py:19-36; PaddleOCR/docs/version3.x/logging.en.md:9-11 |
PaddleOCR のコンストラクタ引数 47#
| 2.x | 3.x | 変更内容(英語) | 出典 |
|---|---|---|---|
use_angle_cls | use_textline_orientation | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. 2.x default False (utility.py:124). 3.x pipeline default is True (paddlex OCR.yaml:7) when not set. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:124; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
det_model_dir | text_detection_model_dir | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. Also set text_detection_model_name to the model's real name, otherwise the default PP-OCRv6_medium_det name is kept and PaddleX raises 'Model name mismatch' if the directory's inference.yml names another model. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:61; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
rec_model_dir | text_recognition_model_dir | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. Also set text_recognition_model_name (see det_model_dir note). | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:97; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
cls_model_dir | textline_orientation_model_dir | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. Also set textline_orientation_model_name if not the default. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:125; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
det_db_thresh | text_det_thresh | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. 2.x default 0.3; 3.x YAML default 0.3 (paddlex configs/pipelines/OCR.yaml:32). | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:67; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
det_db_box_thresh | text_det_box_thresh | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. 2.x default 0.6; 3.x YAML default 0.6. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:68; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
det_db_unclip_ratio | text_det_unclip_ratio | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. 2.x default 1.5; 3.x YAML default 1.5. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:69; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
det_limit_side_len | text_det_limit_side_len | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. Default CHANGED: 2.x 960 with limit_type 'max'; 3.x YAML 64 with limit_type 'min' and max_side_limit 4000 (paddlex configs/pipelines/OCR.yaml:29-31). CLI type is int in 3.x (2.x float). | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:62; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
det_limit_type | text_det_limit_type | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. Default CHANGED: 2.x 'max'; 3.x YAML 'min'. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:63; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
rec_batch_num | text_recognition_batch_size | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. 2.x default 6; 3.x YAML default 6. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:100; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
cls_batch_num | textline_orientation_batch_size | エイリアス(警告) Old name still works on PaddleOCR only, with a DeprecationWarning. Passing both names raises ValueError; PPStructureV3 raises Unknown argument. 2.x default 6; 3.x YAML default 6. | PaddleOCR/paddleocr/_pipelines/ocr.py:44-56,155-169; PaddleOCR/paddleocr/_utils/deprecation.py:36-42; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:128; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml |
lang | lang | 変更 Same name. Model selection logic changed: lang=None and ocr_version=None -> PP-OCRv6_medium_det/rec. 2.x script-group values 'latin', 'arabic', 'cyrillic', 'devanagari', 'ch_doc', 'structure' are not language codes in 3.x and give ValueError "No models are available for lang='latin' and ocr_version=None." Use a real code (e.g. 'fr', 'de', 'ru', 'ar', 'hi'); 'french' and 'german' are still accepted. Ignored with a warning when model names/dirs are given. | PaddleOCR/paddleocr/_pipelines/ocr.py:113-127,318-353; PaddleOCR/paddleocr/_utils/langs.py:17-60; paddleocr-2.10.0/paddleocr/paddleocr.py:506-527 |
ocr_version='PP-OCR' | 'PP-OCRv2' | 'PP-OCRv3' | 'PP-OCRv4' | ocr_version='PP-OCRv3' | 'PP-OCRv4' | 'PP-OCRv5' | 'PP-OCRv6' | 変更 2.x choices PP-OCR, PP-OCRv2, PP-OCRv3, PP-OCRv4 (default PP-OCRv4). 3.x PaddleOCR accepts PP-OCRv3..PP-OCRv6; anything else raises ValueError "Invalid OCR version: PP-OCRv2. Supported values are ['PP-OCRv3', 'PP-OCRv4', 'PP-OCRv5', 'PP-OCRv6']." PPStructureV3 accepts only PP-OCRv3..PP-OCRv5. PP-OCRv4 in 3.x only supports lang 'ch' and 'en'. | paddleocr-2.10.0/paddleocr/paddleocr.py:90-91; PaddleOCR/paddleocr/_pipelines/ocr.py:58,97-100,393-399; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:28,103-106 |
use_gpu=True|False | device='gpu' | 'gpu:0' | 'cpu' | 置き換え use_gpu is not accepted: ValueError "Unknown argument: use_gpu". Use device. If device is not set, GPU 0 is used when available, else CPU. If device='gpu' but Paddle has no CUDA, PaddleX logs 'The specified device (GPU) is not available! Switching to CPU instead.' | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); PaddleOCR/paddleocr/_common_args.py:38-50,102-106; paddlex-3.7.2/paddlex/utils/device.py:55-75; paddlex-3.7.2/paddlex/inference/models/runners/paddle_static/config/pp_option.py:97-115; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:40 |
gpu_id=N | device='gpu:N' | 置き換え Raises 'Unknown argument: gpu_id'. Device id is part of the device string. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddlex-3.7.2/paddlex/utils/device.py:78-100; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:55 |
gpu_mem=500 | — | 削除 Raises 'Unknown argument: gpu_mem'. No equivalent parameter in 3.x. (Note: the repo FAQ still suggests gpu_mem=200 for OOM; that advice is 2.x-only.) | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:54; PaddleOCR/docs/FAQ.en.md:91 |
use_xpu=True | device='xpu' (or 'xpu:0') | 置き換え Raises 'Unknown argument: use_xpu'. Supported device types: cpu, gpu, xpu, npu, mlu, gcu, dcu, iluvatar_gpu, metax_gpu. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddlex-3.7.2/paddlex/utils/device.py:31-41; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:41 |
use_npu=True | device='npu' (or 'npu:0') | 置き換え Raises 'Unknown argument: use_npu'. Supported device types: cpu, gpu, xpu, npu, mlu, gcu, dcu, iluvatar_gpu, metax_gpu. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddlex-3.7.2/paddlex/utils/device.py:31-41; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:42 |
use_mlu=True | device='mlu' (or 'mlu:0') | 置き換え Raises 'Unknown argument: use_mlu'. Supported device types: cpu, gpu, xpu, npu, mlu, gcu, dcu, iluvatar_gpu, metax_gpu. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddlex-3.7.2/paddlex/utils/device.py:31-41; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:43 |
use_gcu=True | device='gcu' (or 'gcu:0') | 置き換え Raises 'Unknown argument: use_gcu'. Supported device types: cpu, gpu, xpu, npu, mlu, gcu, dcu, iluvatar_gpu, metax_gpu. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddlex-3.7.2/paddlex/utils/device.py:31-41; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:45 |
use_tensorrt | use_tensorrt | 変更 Same name, still a constructor/CLI option. Ignored if engine_config is passed explicitly. | PaddleOCR/paddleocr/_common_args.py:44,71,77-89,152-157; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:51; PaddleOCR/docs/version3.x/inference_deployment/local_inference/inference_engine.en.md:152 |
precision='fp32'|'fp16'|'int8' | precision='fp32'|'fp16' | 変更 Same name; only fp32 and fp16 accepted. Others raise ValueError "Invalid precision: int8. Supported values are: ['fp32', 'fp16']." Applies to TensorRT (use_tensorrt=True). | PaddleOCR/paddleocr/_common_args.py:66-69; PaddleOCR/paddleocr/_constants.py:17,21; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:53 |
enable_mkldnn | enable_mkldnn | 変更 Same name; default CHANGED from False (2.x) to True (3.x). enable_mkldnn=False makes the CPU run_mode 'paddle' instead of the oneDNN path. | paddleocr-2.10.0/paddleocr/tools/infer/utility.py:131; PaddleOCR/paddleocr/_constants.py:18; PaddleOCR/paddleocr/_common_args.py:90-95 |
(new) mkldnn_cache_capacity | mkldnn_cache_capacity | 変更 New in 3.x, default 10. | PaddleOCR/paddleocr/_common_args.py:47; PaddleOCR/paddleocr/_constants.py:19 |
cpu_threads | cpu_threads | 変更 Same name, default 10 in both. | paddleocr-2.10.0/paddleocr/tools/infer/utility.py:132; PaddleOCR/paddleocr/_constants.py:20 |
ir_optim / min_subgraph_size | — | 削除 Raise 'Unknown argument: ...'. Low-level Paddle Inference options now go through engine_config (paddle_static fields: run_mode, delete_pass, enable_new_ir, trt_* ...). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:50,52; PaddleOCR/docs/version3.x/inference_deployment/local_inference/inference_engine.en.md:79-97 |
use_onnx=True | engine='onnxruntime' (3.5+) or enable_hpi=True | 置き換え Raises 'Unknown argument: use_onnx'. Upgrade notes: use_onnx replaced by high-performance inference (enable_hpi). The 3.5+ inference-engine doc adds engine='onnxruntime' (requires pip install onnxruntime / onnxruntime-gpu). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); PaddleOCR/docs/update/upgrade_notes.en.md:71; PaddleOCR/paddleocr/_common_args.py:29-35; PaddleOCR/docs/version3.x/inference_deployment/local_inference/inference_engine.en.md:20-30,50-58; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:155 |
onnx_providers=[...] | engine='onnxruntime', engine_config={'providers': [...]} | 置き換え Raises 'Unknown argument: onnx_providers'. engine_config field 'providers' documented for onnxruntime. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:156; PaddleOCR/docs/version3.x/inference_deployment/local_inference/inference_engine.en.md:118-132 |
onnx_sess_options | engine='onnxruntime', engine_config={'session_options': ...} | 置き換え Raises 'Unknown argument: onnx_sess_options'. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:157; PaddleOCR/docs/version3.x/inference_deployment/local_inference/inference_engine.en.md:132 |
(new) engine / engine_config | engine=None|'paddle'|'paddle_static'|'paddle_dynamic'|'transformers'|'onnxruntime', engine_config={...} | 変更 New in 3.5+. Default None ~ 'paddle' (PaddlePaddle). Invalid value -> ValueError "Invalid engine: X. Supported values are: [...]". | PaddleOCR/paddleocr/_common_args.py:29-35,58-64; PaddleOCR/docs/version3.x/inference_deployment/local_inference/inference_engine.en.md:60-73 |
show_log=False | import logging; from paddleocr import logger; logger.setLevel(logging.ERROR) | 置き換え Raises 'Unknown argument: show_log'. Upgrade notes: show_log replaced by a new logging system. Default level is already ERROR. PaddleX has its own separate logger. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); PaddleOCR/docs/update/upgrade_notes.en.md:69; PaddleOCR/docs/version3.x/logging.en.md:9-26; PaddleOCR/paddleocr/_utils/logging.py:24-36; paddleocr-2.10.0/paddleocr/tools/infer/utility.py:154 |
drop_score=0.5 | text_rec_score_thresh | 名称変更 drop_score is NOT in the deprecation map, so PaddleOCR(drop_score=...) raises 'Unknown argument: drop_score'. Equivalent filter is text_rec_score_thresh (constructor or predict()). Default CHANGED: 2.x 0.5, 3.x 0.0 (no filtering). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:107; paddleocr-2.10.0/paddleocr/tools/infer/predict_system.py:56,152; PaddleOCR/paddleocr/_pipelines/ocr.py:90,191; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml:45 |
rec_image_shape='3, 48, 320' | text_rec_input_shape=(3, 48, 320) | 名称変更 Not auto-mapped: rec_image_shape raises 'Unknown argument'. New param takes C,H,W (CLI: --text_rec_input_shape C H W). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:99; PaddleOCR/paddleocr/_pipelines/ocr.py:92,550-556 |
(new) text_det_input_shape | text_det_input_shape=(C, H, W) | 変更 New in 3.x. | PaddleOCR/paddleocr/_pipelines/ocr.py:89,533-539 |
return_word_box | return_word_box | 変更 Same name (constructor and predict()). | paddleocr-2.10.0/paddleocr/tools/infer/utility.py:161; PaddleOCR/paddleocr/_pipelines/ocr.py:91,192 |
cls_thresh / cls_image_shape / label_list | — | 削除 Raise 'Unknown argument'. No constructor equivalent; advanced per-module settings can be edited in an exported PaddleX pipeline config (export_paddlex_config_to_yaml + paddlex_config=...). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:126-129; PaddleOCR/paddleocr/_pipelines/base.py:74-77; PaddleOCR/docs/version3.x/paddleocr_and_paddlex.en.md:58-60 |
det_algorithm / rec_algorithm / det_box_type / use_dilation / det_db_score_mode / max_batch_size / det_east_* / det_sast_* / det_pse_* / scales / alpha / beta / fourier_degree | — | 削除 Raise 'Unknown argument'. Models are chosen by name: text_detection_model_name / text_recognition_model_name. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:60,64,70-93,96; PaddleOCR/paddleocr/_pipelines/ocr.py:73-80 |
rec_char_dict_path / use_space_char / max_text_length / rec_image_inverse / vis_font_path | — | 削除 Raise 'Unknown argument'. For visualization font, PaddleX reads env PADDLE_PDX_LOCAL_FONT_FILE_PATH. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:98,101-106; PaddleOCR/docs/FAQ.en.md:195-197; paddlex-3.7.2/paddlex/utils/flags.py:64 |
e2e_* / sr_* params | — | 削除 Raise 'Unknown argument'. End-to-end (PGNet) and super-resolution inference are not part of the 3.x PaddleOCR class. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:110-121,137-139 |
draw_img_save_dir / save_crop_res / crop_res_save_dir / save_log_path | res.save_to_img(path) / res.save_to_json(path) | 置き換え Raise 'Unknown argument'. Saving is done per result object. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:142-144,152; PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:1311-1315,1856-1857 |
use_mp / total_process_num / process_id | device='gpu:0,1,...' or multi-process example | 置き換え Raise 'Unknown argument'. Docs describe multi-device device strings and a multi-process parallel inference example. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:147-149; PaddleOCR/docs/version3.x/algorithm/PP-StructureV3/PP-StructureV3.en.md:1514; PaddleOCR/docs/version3.x/inference_deployment/local_inference/parallel_inference.en.md |
use_pdserving / warmup / benchmark | — | 削除 Raise 'Unknown argument'. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:133-134,151 |
page_num | — | 削除 Raises 'Unknown argument'. 3.x predict() accepts a PDF path directly and yields one result per page (page_index field). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/tools/infer/utility.py:59; PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:857-866,1817 |
image_dir (kwarg / CLI) | predict(input) / CLI -i, --input | 名称変更 Input is passed to predict(); accepts image path, PDF path, URL, directory of images, numpy array or list. | paddleocr-2.10.0/paddleocr/tools/infer/utility.py:58; PaddleOCR/paddleocr/_utils/cli.py:31-45; PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:857 |
(new) use_doc_orientation_classify / use_doc_unwarping | use_doc_orientation_classify=False, use_doc_unwarping=False | 変更 New in 3.x and ON by default in the OCR pipeline YAML (use_doc_preprocessor True). Official examples set both to False for plain OCR; set them False to get 2.x-like behaviour/speed. | PaddleOCR/paddleocr/_pipelines/ocr.py:81-82,285-292; paddlex-3.7.2/paddlex/configs/pipelines/OCR.yaml:6-13; PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:1293-1298 |
(new) text_detection_model_name / text_recognition_model_name / textline_orientation_model_name | e.g. text_detection_model_name='PP-OCRv5_mobile_det' | 変更 New in 3.x: models chosen by official name; auto-downloaded. | PaddleOCR/paddleocr/_pipelines/ocr.py:73-80; PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:1304-1310 |
(new) paddlex_config | paddlex_config='ocr_config.yaml' | 変更 Load an edited PaddleX pipeline YAML; export current config with export_paddlex_config_to_yaml(). | PaddleOCR/paddleocr/_pipelines/base.py:54-100; PaddleOCR/docs/version3.x/inference_deployment/local_inference/inference_engine.en.md:215-245 |
PPStructure → PPStructureV3 の引数 18#
| 2.x | 3.x | 変更内容(英語) | 出典 |
|---|---|---|---|
PPStructure(structure_version='PP-StructureV2') | — | 削除 Raises 'Unknown argument: structure_version' on PPStructureV3. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/paddleocr.py:92-93,820-824 |
PPStructure(layout=False) | PaddleOCR(...) for OCR-only, or TableRecognitionPipelineV2 for table-only | 置き換え PPStructureV3 has no switch to disable layout detection ('Unknown argument: layout'). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/ppstructure/utility.py:90-95; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:32-101; PaddleOCR/paddleocr/__init__.py:42 |
PPStructure(table=True|False) | PPStructureV3(use_table_recognition=True|False) | 名称変更 Not auto-mapped ('Unknown argument: table'). 3.x default True. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:96-101; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:93; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:2342 |
PPStructure(formula=True|False) | PPStructureV3(use_formula_recognition=True|False) | 名称変更 Not auto-mapped. Default CHANGED: 2.x False, 3.x True. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:102-107; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:94; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:2350 |
PPStructure(ocr=True|False) | — | 削除 No equivalent switch on PPStructureV3 ('Unknown argument: ocr'). | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); paddleocr-2.10.0/paddleocr/ppstructure/utility.py:108-113; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:32-101 |
PPStructure(image_orientation=True) | PPStructureV3(use_doc_orientation_classify=True) | 名称変更 Not auto-mapped. 3.x default False for PPStructureV3. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:84-89; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:89; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:2310 |
PPStructure(recovery=True) | res.save_to_word(save_path) / res.save_to_markdown(save_path) | 置き換え Layout recovery is done via result methods on PPStructureV3 results. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:115-120; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:69,797; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:1694-1700 |
PPStructure(recovery_to_markdown=True) | res.save_to_markdown(save_path); pipeline.concatenate_markdown_pages(markdown_list) | 置き換え | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:121-126; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:300-301; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:1766,2827-2851 |
PPStructure(use_pdf2docx_api=True) | — | 削除 No equivalent. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py; paddleocr-2.10.0/paddleocr/paddleocr.py:1002-1011 |
PPStructure(layout_model_dir=...) | PPStructureV3(layout_detection_model_dir=..., layout_detection_model_name=...) | 名称変更 Not auto-mapped. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:53; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:34-35 |
PPStructure(table_model_dir=...) | PPStructureV3(wired_table_structure_recognition_model_dir=..., wireless_table_structure_recognition_model_dir=...) | 名称変更 Not auto-mapped. 3.x splits table structure models into wired/wireless. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:36; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:65-68 |
PPStructure(formula_model_dir=...) | PPStructureV3(formula_recognition_model_dir=..., formula_recognition_model_name=...) | 名称変更 Not auto-mapped. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:45; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:86-87 |
PPStructure(layout_score_threshold=0.5) | PPStructureV3(layout_threshold=0.5) | 名称変更 Not auto-mapped. Accepts float or {class_id: thresh} dict. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:59-61; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:36; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:1820 |
PPStructure(layout_nms_threshold=0.5) | PPStructureV3(layout_nms=True|False) | 変更 Not auto-mapped. 3.x param is a bool switch, not a threshold. | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:62-64; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:37; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:1833 |
PPStructure(det_model_dir=..., rec_model_dir=..., use_angle_cls=...) | PPStructureV3(text_detection_model_dir=..., text_recognition_model_dir=..., use_textline_orientation=...) | 名称変更 PPStructureV3 has NO deprecated-name mapping: old names raise 'Unknown argument'. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")); PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:50-61,91,129-143 |
PPStructure(mode='kie', ser_model_dir=..., re_model_dir=..., kie_algorithm=...) | PPChatOCRv4Doc (pip install "paddleocr[ie]") | 置き換え KIE mode removed from the structure class; 3.x information-extraction pipeline is PP-ChatOCRv4 (dependency group 'ie'). | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:66-83; PaddleOCR/paddleocr/__init__.py:38; PaddleOCR/docs/version3.x/installation.en.md:39-45 |
PPStructure(show_log=..., use_gpu=...) | logger / device=... | 置き換え Same as PaddleOCR: 'Unknown argument'. | PaddleOCR/paddleocr/_common_args.py:52-54 (raises ValueError(f"Unknown argument: {name}")) |
PPStructure(...)(img, return_ocr_result_in_table=True) | — | 削除 __call__ no longer exists; use predict(). | paddleocr-2.10.0/paddleocr/paddleocr.py:902-933; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:223 |
メソッドと結果の形式 12#
| 2.x | 3.x | 変更内容(英語) | 出典 |
|---|---|---|---|
PPStructure(...) | PPStructureV3(...) | 置き換え Class removed; PPStructureV3 is the documented replacement. | PaddleOCR/docs/update/upgrade_notes.en.md:73; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:31 |
ocr.ocr(img) | ocr.predict(img) | 変更 ocr() still exists but is decorated @deprecated('Please use predict instead.') and forwards **kwargs to predict(). Returns a list of OCRResult objects, one per image/page. | PaddleOCR/paddleocr/_pipelines/ocr.py:208-241; PaddleOCR/docs/update/upgrade_notes.en.md:51-67 |
ocr.ocr(img, cls=True) | ocr.predict(img, use_textline_orientation=True) or PaddleOCR(use_textline_orientation=True) | 変更 predict() has no 'cls' kwarg -> TypeError (Python: "PaddleOCR.predict() got an unexpected keyword argument 'cls'"). | PaddleOCR/paddleocr/_pipelines/ocr.py:208-241; paddleocr-2.10.0/paddleocr/paddleocr.py:696-706 |
ocr.ocr(img, det=False) # recognition only | TextRecognition(model_name=...).predict(img_or_crops) | 置き換え Upgrade notes: ocr() no longer accepts det/rec; use TextDetection / TextRecognition modules. Default rec model PP-OCRv6_medium_rec. | PaddleOCR/docs/update/upgrade_notes.en.md:69; PaddleOCR/paddleocr/_models/text_recognition.py; paddleocr-2.10.0/paddleocr/paddleocr.py:784-799 |
ocr.ocr(img, rec=False) # detection only | TextDetection(model_name=...).predict(img) | 置き換え Default det model PP-OCRv6_medium_det. | PaddleOCR/docs/update/upgrade_notes.en.md:69; PaddleOCR/paddleocr/_models/text_detection.py:23-26; paddleocr-2.10.0/paddleocr/paddleocr.py:773-783 |
ocr.ocr(img, det=False, rec=False) # angle cls only | TextLineOrientationClassification().predict(img) | 置き換え Default model PP-LCNet_x0_25_textline_ori. | PaddleOCR/paddleocr/_models/textline_orientation_classification.py:21-24; paddleocr-2.10.0/paddleocr/paddleocr.py:784-798 |
ocr.ocr(img, bin=True, inv=True, alpha_color=..., slice={...}) | — | 削除 predict() only takes the keyword args listed in its signature; others raise TypeError. | PaddleOCR/paddleocr/_pipelines/ocr.py:208-222; paddleocr-2.10.0/paddleocr/paddleocr.py:696-706 |
PPStructure()(img) | PPStructureV3().predict(img) | 変更 Returns LayoutParsingResultV2 objects (print, save_to_json, save_to_markdown, save_to_word, save_to_html, save_to_xlsx, save_to_img). | PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:223; paddlex-3.7.2/paddlex/inference/pipelines/layout_parsing/result_v2.py:48-49; PaddleOCR/docs/version3.x/pipeline_usage/PP-StructureV3.en.md:2815-2851 |
(new) predict_iter(input) | ocr.predict_iter(img) | 変更 Generator version of predict(). | PaddleOCR/paddleocr/_pipelines/ocr.py:179-206 |
(new) close() | ocr.close() | 変更 Releases the PaddleX pipeline. | PaddleOCR/paddleocr/_pipelines/base.py:79-80 |
result = ocr.ocr(img); result[0] -> [[box, (text, score)], ...] (None if no text) | result = ocr.predict(img); res = result[0]; res['rec_texts'], res['rec_scores'], res['rec_polys'], res['rec_boxes'], res['dt_polys'] | 変更 Each item is an OCRResult (a dict subclass). Old indexing like result[0][0][1][0] fails (KeyError: 0). rec_polys: list of (4,2) int16 arrays; rec_boxes: (n,4) [x_min,y_min,x_max,y_max]. res.json returns {'res': {...}} (JSON-safe lists). | paddleocr-2.10.0/paddleocr/paddleocr.py:762-772; paddlex-3.7.2/paddlex/inference/pipelines/ocr/result.py:31; paddlex-3.7.2/paddlex/inference/common/result/base_result.py:75; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:197-207; PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:1836-1880 |
for line in result[0]: box, (text, score) = line | for res in result: | 変更 Code-converter rewrite of the classic 2.x loop. rec_texts/rec_scores/rec_polys are parallel lists filtered by text_rec_score_thresh. | PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:1850-1853 |
ヘルパー関数 9#
| 2.x | 3.x | 変更内容(英語) | 出典 |
|---|---|---|---|
draw_ocr(image, boxes, txts, scores, font_path=...) | res.save_to_img(save_path) or res.img['ocr_res_img'] (PIL.Image) | 置き換え Upgrade notes show res.save_to_img('result') replacing draw_ocr. Custom font: env PADDLE_PDX_LOCAL_FONT_FILE_PATH. | paddleocr-2.10.0/paddleocr/tools/infer/utility.py:451-458; PaddleOCR/docs/update/upgrade_notes.en.md:38-48,65-66; PaddleOCR/docs/version3.x/pipeline_usage/OCR.en.md:1872-1881; PaddleOCR/docs/FAQ.en.md:197 |
draw_structure_result(image, result, font_path) | res.save_to_img(save_path) | 置き換え | paddleocr-2.10.0/paddleocr/ppstructure/utility.py:159; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:400 |
save_structure_res(res, save_folder, img_name) | res.save_to_json(p) / res.save_to_xlsx(p) / res.save_to_html(p) / res.save_to_img(p) / res.save_all(p) | 置き換え | paddleocr-2.10.0/paddleocr/ppstructure/predict_system.py:274; paddlex-3.7.2/paddlex/inference/common/result/base_result.py:94-105; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:216,400,526,590 |
sorted_layout_boxes(res, w) | res.save_to_markdown(p) / res.markdown | 置き換え No public 3.x equivalent function; ordered document output is obtained via the markdown result. | paddleocr-2.10.0/paddleocr/ppstructure/recovery/recovery_to_doc.py:87; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:789,797 |
convert_info_docx(img, res, save_folder, img_name) | res.save_to_word(save_path) | 置き換え | paddleocr-2.10.0/paddleocr/ppstructure/recovery/recovery_to_doc.py:32; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:69 |
convert_info_markdown(res, save_folder, img_name) | res.save_to_markdown(save_path) + PPStructureV3.concatenate_markdown_pages() | 置き換え | paddleocr-2.10.0/paddleocr/paddleocr.py:69; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:797; PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:300-301 |
to_excel(html_table, excel_path) | res.save_to_xlsx(save_path) | 置き換え | paddleocr-2.10.0/paddleocr/ppstructure/table/predict_table.py:150; paddlex-3.7.2/paddlex/inference/common/result/mixin.py:590 |
download_with_progressbar(url, path) | — | 削除 Models are downloaded automatically to ~/.paddlex/official_models (PADDLE_PDX_CACHE_HOME); source chosen by PADDLE_PDX_MODEL_SOURCE (huggingface default; modelscope, aistudio, bos). | paddleocr-2.10.0/paddleocr/__init__.py:20; paddlex-3.7.2/paddlex/utils/cache.py:28-29; paddlex-3.7.2/paddlex/inference/utils/official_models.py:878-886; paddlex-3.7.2/paddlex/utils/flags.py:72 |
result printing: print(line) | res.print() / res.save_to_json(p) | 変更 | PaddleOCR/docs/update/upgrade_notes.en.md:61-66 |
コマンドライン 24#
| 2.x | 3.x | 変更内容(英語) | 出典 |
|---|---|---|---|
paddleocr --image_dir img.png | paddleocr ocr -i img.png | 変更 3.x requires a subcommand. Without it argparse treats the path as the COMMAND: "paddleocr: error: argument COMMAND: invalid choice: 'img.png' (choose from ...)". | PaddleOCR/paddleocr/_cli.py:281-309; PaddleOCR/paddleocr/_utils/cli.py:31-45; paddleocr-2.10.0/paddleocr/paddleocr.py:936-960 |
paddleocr --image_dir img.png --use_angle_cls true | paddleocr ocr -i img.png --use_textline_orientation True | エイリアス(警告) --use_angle_cls is still accepted by 'paddleocr ocr' with a CLIDeprecationWarning "The option --use_angle_cls has been deprecated and will be removed in the future. ..." | PaddleOCR/paddleocr/_pipelines/ocr.py:503-506,567-588; PaddleOCR/paddleocr/_utils/deprecation.py:26-33 |
--det_model_dir | --text_detection_model_dir | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--det_model_dir and --text_detection_model_dir are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--rec_model_dir | --text_recognition_model_dir | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--rec_model_dir and --text_recognition_model_dir are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--cls_model_dir | --textline_orientation_model_dir | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--cls_model_dir and --textline_orientation_model_dir are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--det_db_thresh | --text_det_thresh | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--det_db_thresh and --text_det_thresh are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--det_db_box_thresh | --text_det_box_thresh | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--det_db_box_thresh and --text_det_box_thresh are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--det_db_unclip_ratio | --text_det_unclip_ratio | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--det_db_unclip_ratio and --text_det_unclip_ratio are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--det_limit_side_len | --text_det_limit_side_len | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--det_limit_side_len and --text_det_limit_side_len are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--det_limit_type | --text_det_limit_type | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--det_limit_type and --text_det_limit_type are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--rec_batch_num | --text_recognition_batch_size | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--rec_batch_num and --text_recognition_batch_size are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--cls_batch_num | --textline_orientation_batch_size | エイリアス(警告) Deprecated alias on 'paddleocr ocr' only; giving both prints "--cls_batch_num and --textline_orientation_batch_size are mutually exclusive." and exits 2. | PaddleOCR/paddleocr/_pipelines/ocr.py:567-600 |
--use_gpu true|false | --device gpu|gpu:0|cpu | 置き換え --use_gpu is not defined in 3.x -> argparse 'unrecognized arguments'. | PaddleOCR/paddleocr/_common_args.py:129-139 |
--type structure | paddleocr pp_structurev3 -i <file> | 変更 | PaddleOCR/paddleocr/_pipelines/pp_structurev3.py:695-696; paddleocr-2.10.0/paddleocr/paddleocr.py:388,963-964 |
--type structure --recovery true | paddleocr pp_structurev3 -i <file> --save_path out/ | 変更 --save_path calls res.save_all() for each result (all registered save methods). | PaddleOCR/paddleocr/_utils/cli.py:41-45,68-73 |
--det false | paddleocr text_recognition -i <img> | 変更 | PaddleOCR/paddleocr/_models/text_recognition.py; paddleocr-2.10.0/paddleocr/paddleocr.py:386 |
--rec false | paddleocr text_detection -i <img> | 変更 | PaddleOCR/paddleocr/_models/text_detection.py:36-38; paddleocr-2.10.0/paddleocr/paddleocr.py:387 |
--savefile true --output ./out | --save_path ./out | 名称変更 | paddleocr-2.10.0/paddleocr/paddleocr.py:389,990-995; PaddleOCR/paddleocr/_utils/cli.py:41-45 |
--lang en | --lang en | 変更 Same flag on 'paddleocr ocr'; see 'lang' param note on removed script-group codes. | PaddleOCR/paddleocr/_pipelines/ocr.py:557-559 |
--ocr_version PP-OCRv4 | --ocr_version PP-OCRv3|PP-OCRv4|PP-OCRv5|PP-OCRv6 | 変更 argparse choices enforced. | PaddleOCR/paddleocr/_pipelines/ocr.py:560-565 |
--use_onnx true | --engine onnxruntime (or --enable_hpi True) | 置き換え | PaddleOCR/paddleocr/_common_args.py:140-151 |
--show_log false | — | 削除 The 3.x CLI sets the paddleocr logger to INFO itself. | PaddleOCR/paddleocr/_cli.py:301-303 |
--enable_mkldnn / --cpu_threads / --use_tensorrt / --precision | same flags | 変更 Still available on every pipeline/model subcommand; enable_mkldnn default now True. | PaddleOCR/paddleocr/_common_args.py:152-188 |
(3.x) subcommands | ocr, doc_preprocessor, doc_understanding, formula_recognition_pipeline, doc_parser (PaddleOCR-VL), pp_chatocrv4_doc, pp_doctranslation, pp_structurev3, seal_recognition, table_recognition_v2, chart_parsing, doc_img_orientation_classification, doc_vlm, formula_recognition, layout_detection, seal_text_detection, table_cells_detection, table_classification, table_structure_recognition, text_detection, text_image_unwarping, text_recognition, textline_orientation_classification, install_hpi_deps, install_genai_server_deps, genai_server (only if the PaddleX genai server plugin imports), doc2md, api | 変更 Complete list registered by _get_parser(). Pipeline/model subcommands share -i/--input, --save_path, --device, --engine, --enable_hpi, --use_tensorrt, --precision, --enable_mkldnn, --mkldnn_cache_capacity, --cpu_threads, --enable_cinn (pipelines also --paddlex_config). | PaddleOCR/paddleocr/_cli.py:57-123,126-165,168-278,281-294; PaddleOCR/paddleocr/_pipelines/*.py subparser_name; PaddleOCR/paddleocr/_models/*.py subparser_name; PaddleOCR/paddleocr/_api_client/cli.py:30-35; PaddleOCR/paddleocr/_pipelines/base.py:118-131 |
2.x を使い続ける:paddleocr を 3 未満に固定#
まだ移行できない場合は、専用の仮想環境で最後の 2.x リリースに固定してください。
python -m pip install "paddleocr<3"これで 2.10.0 が入ります。3.x と同様に、この wheel も PaddlePaddle を依存関係に含まないため、フレームワークは自分でインストールします。3 どの PaddlePaddle 3.x のバージョンで paddleocr 2.x が動くかは検証していないため、動作している 2.x の環境がすでにあるなら、作り直すのではなく固定(pip freeze > requirements.txt)してください。2.x の内部モジュール(paddleocr.tools、paddleocr.ppocr、paddleocr.ppstructure)をインポートするコードは 2.x でしか動きません。これらのモジュールは 3.x のパッケージにはありません。
移行を先延ばしにするほどコストは増えます。2.x には新しいモデルが追加されない一方で、3.x は PP-OCRv5 から PP-OCRv6 に移行し、PaddleOCR-VL も追加されました。
移行チェックリスト#
新しい環境と新しいエンジン#
新しい venv を作成します。
pip install paddleocrを実行し、次に PaddlePaddle のインデックスからpaddlepaddle==3.2.0、またはonnxruntimeをインストールします。インストールコマンド生成ツールで、お使いのマシン用の正確なコマンドがわかります。コードを変換する#
各ファイルを変換ツールにかけ、すべての
# TODO(paddleocr 3.x)を解決します。一度だけ警告をエラーにする#
python -W error::DeprecationWarningでテストを実行し、残っているエイリアスやocr()の呼び出しを洗い出します。出力を比較する#
実際の文書をいくつか使ってテキストの差分を取ります。違いがあれば、モデルを疑う前に「2.x の挙動を維持する」スイッチを試してください。
遭遇したエラーを確認する#
予期しないエラーはエラー解決ツールに貼り付けてください。
よくある質問#
PaddleOCR 3.x で use_angle_cls はまだ使えますか?
はい、PaddleOCR でのみ使えます。3.x が DeprecationWarning 付きで新しい名前(use_textline_orientation)に変換する 11 個の旧名の 1 つです。PPStructureV3 では ValueError: Unknown argument: use_angle_cls になり、旧名と新名を両方渡すと「mutually exclusive」のエラーになります。
use_gpu なしで PaddleOCR 3.x の GPU を使うには?
device='gpu'(または 'gpu:0'、'gpu:1')を指定します。device を省略すると、インストールされた PaddlePaddle が CUDA 対応でビルドされていれば、3.x は自動で GPU 0 を選びます。それでも CPU で動く場合は、おそらく CPU 版の PaddlePaddle が入っています。GPU が使われないを参照してください。
ocr(img, cls=True) が TypeError になるのはなぜですか?
3.x の ocr() は predict() に転送するだけで、predict() には cls パラメータがないためです。cls=True を削除し、代わりにコンストラクタで use_textline_orientation=True を指定してください。ocr() は非推奨なので、predict() に切り替えましょう。
draw_ocr の代わりは何ですか?
各結果が自分自身を描画します。res.save_to_img('output') は可視化画像をフォルダーに書き出し、res.img['ocr_res_img'] は PIL 画像として返します。独自のフォントは PADDLE_PDX_LOCAL_FONT_FILE_PATH で指定します。
paddleocr==2.7.0.3 を使い続けてもよいですか?
バージョンを固定し、動作している環境を維持するなら可能です。2.7.0.3 は 2023年9月15日のリリースで、最後の 2.x は 2.10.0(2025年3月)です。どちらにも新しいモデルは追加されず、2.x の API と 3.x を 1 つの環境で混在させることはできません。
変換ツールに自分のコードを入れても安全ですか?
処理はすべてブラウザ内で行われ、コードがどこかに送信されることはありません。認識したパターンだけを変更し、すべての変更点を根拠となるソースの行とともに示し、人の判断が必要な箇所には TODO コメントを残します。ほかのコード変更と同じように、差分を確認してください。
同じ画像でも 3.x の結果が 2.x と違うのはなぜですか?
既定のモデル(PP-OCRv4 ではなく PP-OCRv6)、新しい前処理(向き補正、歪み補正)、0.5 のスコアフィルタがないことが理由です。2.x に近い挙動にするには、use_doc_orientation_classify=False、use_doc_unwarping=False、use_textline_orientation=False、text_rec_score_thresh=0.5 を指定してください。
出典
- このページのために読んだコミット dab3fe3(2026-09-16)時点の PaddleOCR のソースコード:
paddleocr/_pipelines/ocr.py(エイリアス表 44〜56 行目、エイリアス処理 155〜169 行目、predict()/ocr()179〜241 行目)、_common_args.py(38〜54 行目)、_utils/deprecation.py(26〜42)、__init__.py(84〜131)、_cli.py(57〜309)、_pipelines/pp_structurev3.py(32〜143)。 - 公式のアップグレードノート:docs/update/upgrade_notes.en.md(3.x が互換性を破った理由。ocr/det/rec、show_log、use_onnx、PPStructure の変更)。
- PyPI の paddleocr 2.10.0 の wheel(最後の 2.x リリース):
paddleocr/paddleocr.py(ocr()のシグネチャ 696〜706 行目、戻り値の形式 762〜772 行目)、tools/infer/utility.py(2.x の既定値)、ppstructure/utility.py。 - 2.x のサンプルコード:docs/version2.x/ppocr/blog/whl.en.md と docs/version2.x/ppstructure/quick_start.en.md。
- PyPI の PaddleX 3.7.2 の wheel:
paddlex/configs/pipelines/OCR.yaml(3.x の OCR の既定値、6〜45 行目)、paddlex/inference/pipelines/ocr/result.pyとcommon/result/(結果オブジェクト、保存メソッド)、inference/models/utils/model_resolver.py(Model name mismatch)。 - 2026-10-27 に確認した paddleocr の PyPI リリース履歴:2.7.0.3(2023-09-15)、2.10.0(2025-03-07、最後の 2.x)、3.0.0(2025-05-20)、3.7.0(2026-06-11)。
- 私たちのテスト(2026-10-27、Linux x86-64、Python 3.13、paddleocr 3.7.0 + paddlex 3.7.2 + paddlepaddle 3.2.0):このページで引用しているエラー・警告メッセージ、旧 CLI 構文、典型的なサンプルと結果ループに対する変換ツールの出力の実行。
- PP-StructureV3 の使い方と doc-parser extra:PP-StructureV3.en.md、installation.en.md。
- OCR パイプラインのパラメータと結果のフィールド:OCR.en.md(1293〜1315 行目、1836〜1881 行目)。