mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-10 21:10:55 +08:00
Optimize rapidocr_api return parameter
This commit is contained in:
1 parent
2caa0b083f
commit
39c3a35c8d
3 files changed
+6
-9
No files matched your search
@@ -35,6 +35,7 @@ jobs:
|
||||
run: |
|
||||
cd api
|
||||
pip install -r requirements.txt
|
||||
pip install get_pypi_latest_version wheel
|
||||
|
||||
python -m pip install --upgrade pip
|
||||
python setup.py bdist_wheel ${{ github.event.head_commit.message }}
|
||||
|
||||
@@ -4,18 +4,16 @@
|
||||
import argparse
|
||||
import base64
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, Form, UploadFile
|
||||
from PIL import Image
|
||||
from rapidocr_onnxruntime import RapidOCR
|
||||
|
||||
|
||||
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
|
||||
@@ -23,13 +21,12 @@ class OCRAPIUtils:
|
||||
def __init__(self) -> None:
|
||||
self.ocr = RapidOCR()
|
||||
|
||||
def __call__(self, img):
|
||||
def __call__(self, img: Image.Image) -> Dict:
|
||||
img = np.array(img)
|
||||
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
||||
|
||||
ocr_res, _ = self.ocr(img)
|
||||
if not ocr_res:
|
||||
return json.dumps({})
|
||||
return {}
|
||||
|
||||
out_dict = {
|
||||
str(i): {"rec_txt": rec, "dt_boxes": dt_box, "score": score}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
requests
|
||||
rapidocr_onnxruntime
|
||||
get_pypi_latest_version
|
||||
wheel
|
||||
fastapi
|
||||
uvicorn[standard]
|
||||
python-multipart
|
||||
Reference in new issue
Block a user