import os
import time
from paddleocr import PaddleOCRVL
pipeline = PaddleOCRVL(
layout_detection_model_name="PP-DocLayoutV3",
layout_detection_model_dir="./PP-DocLayoutV3-weight",
vl_rec_backend="vllm-server",
vl_rec_server_url="http://localhost:8000/v1",
device="npu"
)
warmup_times = 1
test_loop_times = 3
test_items = [
"paddleocr_vl_demo.png",
]
all_results = {}
for idx, item_path in enumerate(test_items):
print(f"\n==========Test Item {idx+1}/{len(test_items)}: {os.path.basename(item_path)}==========")
print("warm up...")
for _ in range(warmup_times):
pipeline.predict(item_path)
print("warm up end!!!")
total_time = 0.0
times_per_iter = []
for i in range(test_loop_times):
print(f"Test#{i+1}")
start_test = time.perf_counter()
pipeline.predict(item_path)
iter_time = (time.perf_counter() - start_test) * 1000
total_time += iter_time
times_per_iter.append(iter_time)
avg_time = total_time / test_loop_times
all_results[item_path] = avg_time
print("\n" + "=" * 50)
print("All result:")
print("=" * 50)
print("File\t\t\tAverage Time(s)")
for item_path, avg_time in all_results.items():
filename = os.path.basename(item_path)
avg_time_sec = avg_time / 1000.0
print(f"{filename}\t{avg_time_sec:.2f}")