Skip to content

Commit

Permalink
Add surya
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Apr 21, 2024
1 parent dba2fc3 commit 1292e5f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
49 changes: 49 additions & 0 deletions book/cooltools/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,55 @@
" .status == \"PASS\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## OCR, Line Detection and Layout Analysis with `surya`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Do you need an open-source OCR package?\n",
"\n",
"Try `surya`.\n",
"\n",
"`surya` is an OCR + layout analysis + line detection library for Python, supporting over 90 languages.\n",
"\n",
"A great alternative to popular libraries like easyocr.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install surya-ocr"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from PIL import Image\n",
"from surya.ocr import run_ocr\n",
"from surya.model.detection import segformer\n",
"from surya.model.recognition.model import load_model\n",
"from surya.model.recognition.processor import load_processor\n",
"\n",
"image = Image.open(IMAGE_PATH)\n",
"langs = [\"en\"]\n",
"det_processor, det_model = segformer.load_processor(), segformer.load_model()\n",
"rec_model, rec_processor = load_model(), load_processor()\n",
"\n",
"predictions = run_ocr([image], [langs], det_model, det_processor, rec_model, rec_processor)"
]
}
],
"metadata": {
Expand Down
1 change: 0 additions & 1 deletion book/testing/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@
"source": [
"import boto3\n",
"from moto import mock_aws\n",
"from mymodule import MyModel\n",
"\n",
"class MyModel:\n",
" def __init__(self, name, value):\n",
Expand Down

0 comments on commit 1292e5f

Please sign in to comment.