Skip to content

Commit

Permalink
Add example code snippet for OCR
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Oct 30, 2023
1 parent 4e7b64e commit 96c1c06
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,14 @@ export class AutomaticSpeechRecognitionPipeline extends Pipeline {
* let output = await captioner(url);
* // [{ generated_text: 'a cat laying on a couch with another cat' }]
* ```
*
* **Example:** Optical Character Recognition (OCR) w/ `Xenova/trocr-small-handwritten`.
* ```javascript
* let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/handwriting.jpg';
* let captioner = await pipeline('image-to-text', 'Xenova/trocr-small-handwritten');
* let output = await captioner(url);
* // [{ generated_text: 'Mr. Brown commented icily.' }]
* ```
*/
export class ImageToTextPipeline extends Pipeline {
/**
Expand Down

0 comments on commit 96c1c06

Please sign in to comment.