diff --git a/docs/ability/ocr.md b/docs/ability/ocr.md new file mode 100644 index 0000000000000000000000000000000000000000..75216b73108fa006699dcd3f13f33cf872f10dbd --- /dev/null +++ b/docs/ability/ocr.md @@ -0,0 +1,59 @@ +# OCR 文档识别 +## GOT-OCR2_0 +[GOT-OCR2_0](https://ai.gitee.com/serverless-api?model=GOT-OCR2_0) 提供功能强大的 OCR 解决方案,能够高精度、快速、全面的提取图像中的文本信息,支持多种语言,适用于各种场景,例如提取身份证、银行卡、PDF 文档、表格、车牌、手写文字、设备铭牌、数学公式等图像信息。 +### 使用方法 + +您可以点击 [GOT-OCR2_0](https://ai.gitee.com/serverless-api?model=GOT-OCR2_0) 在线免费体验。 + +- CURL 示例: +```bash +curl https://ai.gitee.com/v1/images/ocr \ + -X POST \ + -H "Authorization: Bearer 私人令牌" \ + -F "model=GOT-OCR2_0" + -F "image=@path/to/image.jpg" + -F "response_format=text" +``` +- Python 示例 +```python +import requests +API_URL = "https://ai.gitee.com/v1/images/ocr" +HEADERS = { + "Authorization": "Bearer 私人令牌", +} +def query(image_path, model="GOT-OCR2_0", response_format="text"): + with open(image_path, "rb") as image_file: + response = requests.post( + API_URL, + headers=HEADERS, + files={"image": (image_path, image_file)}, + data={"model": model, "response_format": response_format}, + ) + return response.json() + +output = query("test.jpg") +print(output) # {"text": "xxx"} + +``` +- 参数说明: + - 私人令牌: 点击 [私人令牌](https://ai.gitee.com/dashboard/settings/tokens) 获取 + - model:填写 GOT-OCR2_0 指定 AI 大模型。 + - image:图片文件。 + - 支持 "png", "jpg", "jpeg", "webp", "gif" 格式的图片。 + - 最大分辨率支持 4096X4096。 + - 文件不超过 3MB。 + - response_format:格式化类型, + - 值为 `text` 返回纯文本内容。 + - 值为 `format` 返回 [mathpix-markdown](https://github.com/Mathpix) 格式内容,建议带数学公式的文本使用该参数。 + +执行上述代码后将会响应: +```json +{ + "text": "美迪兰(南京)医疗设备有限公司\n名称:..." +} +``` + +在线体验效果: +[GOT-OCR2_0](https://ai.gitee.com/serverless-api?model=GOT-OCR2_0) + +![alt text](../../static/img/serverless-api/got-ocr2-0.jpg) \ No newline at end of file diff --git a/sidebars.ts b/sidebars.ts index 216c3afc598363b6cf04cf34a7ea2027eac22aa1..5e4101cd262f9211d8f442f0083e0161d490319c 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -102,6 +102,17 @@ const sidebars: SidebarsConfig = { }, ] }, + { + type: 'category', + collapsed: false, + label: '文档处理/OCR', + items: [ + { + type: 'doc', + id: 'ability/ocr', + }, + ] + }, ] }, diff --git a/static/img/serverless-api/got-ocr2-0.jpg b/static/img/serverless-api/got-ocr2-0.jpg new file mode 100644 index 0000000000000000000000000000000000000000..63de4100efb8c9c85e6505445310184bcb210bd8 Binary files /dev/null and b/static/img/serverless-api/got-ocr2-0.jpg differ