{ "cells": [ { "cell_type": "markdown", "id": "93c44a25", "metadata": {}, "source": [ "# Reuse a pipeline and measure a page" ] }, { "cell_type": "code", "execution_count": 1, "id": "e0284c00", "metadata": { "execution": { "iopub.execute_input": "2026-11-01T06:44:57.295596Z", "iopub.status.busy": "2026-11-01T06:44:57.295452Z", "iopub.status.idle": "2026-11-01T06:45:37.414957Z", "shell.execute_reply": "2026-11-01T06:45:37.414649Z" }, "scrolled": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Loaded DBNet detector (CPU, threads=8)\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Loaded SVTR recognizer (vocab=185 chars, CPU, threads=8)\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[occular] LM (pure Python): compact_lm.npz (268 MB), unigrams=2010937, alpha=0.5 beta=1.0 beam=100\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Seconds for this page: 12.23\n", "Recognized lines: 43\n" ] } ], "source": [ "from time import perf_counter\n", "from occular import OCRPipeline\n", "\n", "reader = OCRPipeline()\n", "reader.get_text(\"receipt.jpg\") # warm up the models\n", "\n", "started = perf_counter()\n", "text = reader.get_text(\"receipt.jpg\")\n", "seconds = perf_counter() - started\n", "print(\"Seconds for this page:\", round(seconds, 2))\n", "print(\"Recognized lines:\", len(text.splitlines()))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }