typefile
{
"action": "Run OCR",
"image": "https://replicate.delivery/pbxt/KU3ZDwmFqwo7tsfY5m8OsN0XDJLqk2lvgSKOT5s7HFZOqkNq/D5300-1.jpg",
"languages_choices": "English",
"languages_input": "English",
"page_number": 1
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_5Be**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run cudanexus/ocr-surya using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"cudanexus/ocr-surya:6bbfc505be178d4c78abd48f0facb5f17dc8adbdc3f8401b708c78365d122318",
{
input: {
action: "Run OCR",
image: "https://replicate.delivery/pbxt/KU3ZDwmFqwo7tsfY5m8OsN0XDJLqk2lvgSKOT5s7HFZOqkNq/D5300-1.jpg",
languages_choices: "English",
languages_input: "English",
page_number: 1
}
}
);
console.log(output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_5Be**********************************
This is your API token. Keep it to yourself.
import replicate
Run cudanexus/ocr-surya using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"cudanexus/ocr-surya:6bbfc505be178d4c78abd48f0facb5f17dc8adbdc3f8401b708c78365d122318",
input={
"action": "Run OCR",
"image": "https://replicate.delivery/pbxt/KU3ZDwmFqwo7tsfY5m8OsN0XDJLqk2lvgSKOT5s7HFZOqkNq/D5300-1.jpg",
"languages_choices": "English",
"languages_input": "English",
"page_number": 1
}
)
print(output)
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_5Be**********************************
This is your API token. Keep it to yourself.
Run cudanexus/ocr-surya using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "cudanexus/ocr-surya:6bbfc505be178d4c78abd48f0facb5f17dc8adbdc3f8401b708c78365d122318",
"input": {
"action": "Run OCR",
"image": "https://replicate.delivery/pbxt/KU3ZDwmFqwo7tsfY5m8OsN0XDJLqk2lvgSKOT5s7HFZOqkNq/D5300-1.jpg",
"languages_choices": "English",
"languages_input": "English",
"page_number": 1
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
Object output with 3 properties
OCR completed.
{
"id": "boxpbijbbkpujtmdcgxz5q5ofm",
"model": "cudanexus/ocr-surya",
"version": "6bbfc505be178d4c78abd48f0facb5f17dc8adbdc3f8401b708c78365d122318",
"input": {
"action": "Run OCR",
"image": "https://replicate.delivery/pbxt/KU3ZDwmFqwo7tsfY5m8OsN0XDJLqk2lvgSKOT5s7HFZOqkNq/D5300-1.jpg",
"languages_choices": "English",
"languages_input": "English",
"page_number": 1
},
"logs": "Detecting bboxes: 0%| | 0/1 [00:00<?, ?it/s]\nDetecting bboxes: 100%|██████████| 1/1 [00:01<00:00, 1.17s/it]\nDetecting bboxes: 100%|██████████| 1/1 [00:01<00:00, 1.17s/it]\nRecognizing Text: 0%| | 0/1 [00:00<?, ?it/s]/root/.pyenv/versions/3.11.8/lib/python3.11/site-packages/transformers/generation/utils.py:1518: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use and modify the model generation configuration (see https://huggingface.co/docs/transformers/generation_strategies#default-text-generation-configuration )\nwarnings.warn(\nRecognizing Text: 100%|██████████| 1/1 [00:04<00:00, 4.77s/it]\nRecognizing Text: 100%|██████████| 1/1 [00:04<00:00, 4.77s/it]\n<tempfile._TemporaryFileWrapper object at 0x7dbfd272e190> /tmp/tmpup9030rb.jpg",
"output": {
"image": "https://replicate.delivery/pbxt/pz8BUQIXW6KPJZGw98JlWzpGP59JFKQr6e2SYvshNTfaGUbSA/tmpup9030rb.jpg",
"jsona": "https://replicate.delivery/pbxt/fJj6xOVoedjMXkVVWepkFWST2zPdeMK7q6Eqif4bMOqbzgaTC/ocr_text.txt",
"text": "OCR completed."
},
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-02-28T19:50:52.872348Z",
"started_at": "2024-02-28T19:54:59.358136Z",
"completed_at": "2024-02-28T19:55:07.347179Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/boxpbijbbkpujtmdcgxz5q5ofm/cancel",
"get": "https://api.replicate.com/v1/predictions/boxpbijbbkpujtmdcgxz5q5ofm"
},
"metrics": {
"predict_time": 7.989043,
"total_time": 254.474831
}
}
