Update code snippet
#1
by
Xenova
HF staff
- opened
README.md
CHANGED
@@ -18,15 +18,15 @@ npm i @huggingface/transformers
|
|
18 |
**Example:** Optical Character Recognition (OCR) w/ `onnx-community/mgp-str-base`
|
19 |
|
20 |
```js
|
21 |
-
import { MgpstrForSceneTextRecognition, MgpstrProcessor,
|
22 |
|
23 |
const model_id = 'onnx-community/mgp-str-base';
|
24 |
const model = await MgpstrForSceneTextRecognition.from_pretrained(model_id);
|
25 |
const processor = await MgpstrProcessor.from_pretrained(model_id);
|
26 |
|
27 |
-
// Load image from
|
28 |
-
const url = "https://
|
29 |
-
const image = await
|
30 |
|
31 |
// Preprocess the image
|
32 |
const result = await processor(image);
|
|
|
18 |
**Example:** Optical Character Recognition (OCR) w/ `onnx-community/mgp-str-base`
|
19 |
|
20 |
```js
|
21 |
+
import { MgpstrForSceneTextRecognition, MgpstrProcessor, load_image } from '@huggingface/transformers';
|
22 |
|
23 |
const model_id = 'onnx-community/mgp-str-base';
|
24 |
const model = await MgpstrForSceneTextRecognition.from_pretrained(model_id);
|
25 |
const processor = await MgpstrProcessor.from_pretrained(model_id);
|
26 |
|
27 |
+
// Load image from a URL
|
28 |
+
const url = "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/ocr-demo.png";
|
29 |
+
const image = await load_image(url);
|
30 |
|
31 |
// Preprocess the image
|
32 |
const result = await processor(image);
|