base on Rust library and CLI tool for OCR (extracting text from images) # Ocrs **ocrs** is a Rust library and CLI tool for extracting text from images, also known as OCR (Optical Character Recognition). The goal is to create a modern OCR engine that: - Works well on a wide variety of images (scanned documents, photos containing text, screenshots etc.) with zero or much less preprocessing effort compared to earlier engines like [Tesseract][tesseract]. This is achieved by using machine learning more extensively in the pipeline. - Is easy to compile and run across a variety of platforms, including WebAssembly - Is trained on open and liberally licensed datasets - Has a codebase that is easy to understand and modify Under the hood, the library uses neural network models trained in [PyTorch][pytorch], which are then exported to [ONNX][onnx] and executed using the [RTen][rten] engine. See the [models](#models-and-datasets) section for more details. [onnx]: https://onnx.ai [pytorch]: https://pytorch.org [rten]: https://github.com/robertknight/rten [tesseract]: https://github.com/tesseract-ocr/tesseract ## Status ocrs is currently in an early preview. Expect more errors than commercial OCR engines. ## Language Support ocrs currently recognizes the Latin alphabet only (eg. English). Support for more languages is [planned](https://github.com/robertknight/ocrs/issues/8). ## CLI installation To install the CLI tool, you will first need Rust and Cargo installed. Then run: ```sh $ cargo install ocrs-cli --locked ``` ## CLI usage To extract text from an image, run: ```sh $ ocrs image.png ``` When the tool is run for the first time, it will download the required models automatically and store them in `~/.cache/ocrs`. ### Additional examples Extract text from an image and write to `content.txt`: ```sh $ ocrs image.png -o content.txt ``` Extract text and layout information from the image in JSON format: ```sh $ ocrs image.png --json -o content.json ``` Annotate an image to show the location of detected words and lines: ```sh $ ocrs image.png --png -o annotated.png ```` ## Library usage See the [ocrs crate README](ocrs/) for details on how to use ocrs as a Rust library. ## Models and datasets ocrs uses neural network models written in PyTorch. See the [ocrs-models](https://github.com/robertknight/ocrs-models) repository for more details about the models and datasets, as well as tools for training custom models. These models are also available in ONNX format for use with other machine learning runtimes. ## Development To build and run the ocrs library and CLI tool locally you will need a recent stable Rust version installed. Then run: ```sh git clone https://github.com/robertknight/ocrs.git cd ocrs cargo run -p ocrs-cli -r -- image.png ``` ### Testing Ocrs has unit tests for the code that runs before and after ML model processing, plus E2E tests which exercise the whole pipeline, including models. After making changes to the code, run unit tests and lint checks with: ```sh make check ``` You can also run standard commands like `cargo test` directly. Run the E2E tests with: ```sh make test-e2e ``` For details of how the ML models are evaluated, see the [ocrs-models](https://github.com/robertknight/ocrs-models) repository. ", Assign "at most 3 tags" to the expected json: {"id":"6701","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"