diff --git a/.github/workflows/gen_whl_to_pypi_rapidocr_api.yml b/.github/workflows/gen_whl_to_pypi_rapidocr_api.yml index 5c742f837..e02554df4 100644 --- a/.github/workflows/gen_whl_to_pypi_rapidocr_api.yml +++ b/.github/workflows/gen_whl_to_pypi_rapidocr_api.yml @@ -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 }} diff --git a/api/rapidocr_api/api.py b/api/rapidocr_api/api.py index d00b407cb..234116e5f 100644 --- a/api/rapidocr_api/api.py +++ b/api/rapidocr_api/api.py @@ -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} diff --git a/api/requirements.txt b/api/requirements.txt index a1867f47a..5892806bd 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,6 +1,5 @@ requests rapidocr_onnxruntime -get_pypi_latest_version -wheel fastapi uvicorn[standard] +python-multipart \ No newline at end of file