# Copyright 2026 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
from paddleocr import LayoutDetection
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--image_dir", type=str, default="layout.jpg")
parser.add_argument("--model_name", type=str, default="PP-DocLayoutV2")
parser.add_argument("--model_dir", type=str, default="PP-DocLayoutV2")
return parser.parse_args()
if __name__ == "__main__":
args = parse_args()
model = LayoutDetection(
model_name=args.model_name,
model_dir=args.model_dir,
)
for res in model.predict_iter(args.image_dir):
res.print()
res.save_to_img("output")
res.save_to_json("output")