From 2d21d2d215dbb7ed6c5f0a0c135b2492cc646c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E6=B4=8B=E4=B8=89=E6=B4=8B?= <1258009915@qq.com> Date: Tue, 27 Feb 2024 07:44:35 +0000 Subject: [PATCH] update --- README.md | 4 ++-- requirements.txt | 1 + src/client_demo.py | 4 ---- src/models/ocr_model/utils/inference.py | 1 + src/server.py | 1 + 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b1bfc27..e7c6e4e 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,10 @@ Then go to `http://localhost:8501` in your browser to run TexTeller in the web. We use [ray serve](https://github.com/ray-project/ray) to provide a simple API for using TexTeller in your own projects. To start the server, navigate to the `TexTeller/src` directory and run the following command: ```bash -python serve.py # default settings +python server.py # default settings ``` -You can pass the following arguments to the `serve.py` script to get custom inference settings(e.g. `python serve.py --use_gpu` to enable GPU inference): +You can pass the following arguments to the `server.py` script to get custom inference settings(e.g. `python server.py --use_gpu` to enable GPU inference): | Argument | Description | | --- | --- | diff --git a/requirements.txt b/requirements.txt index d7ca88e..34bb9e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ ray[serve] accelerate tensorboardX nltk +python-multipart \ No newline at end of file diff --git a/src/client_demo.py b/src/client_demo.py index 8ea236c..2b9f033 100644 --- a/src/client_demo.py +++ b/src/client_demo.py @@ -7,8 +7,4 @@ with open(img_path, 'rb') as img: files = {'img': img} response = requests.post(url, files=files) -# data = {"img_path": img_path} - -# response = requests.post(url, json=data) - print(response.text) diff --git a/src/models/ocr_model/utils/inference.py b/src/models/ocr_model/utils/inference.py index 5dcaf9f..cc34101 100644 --- a/src/models/ocr_model/utils/inference.py +++ b/src/models/ocr_model/utils/inference.py @@ -21,6 +21,7 @@ def inference( if isinstance(imgs_path[0], str): imgs = convert2rgb(imgs_path) else: # already numpy array(rgb format) + assert isinstance(imgs_path[0], np.ndarray) imgs = imgs_path imgs = inference_transform(imgs) pixel_values = torch.stack(imgs) diff --git a/src/server.py b/src/server.py index 7124134..11adfa3 100644 --- a/src/server.py +++ b/src/server.py @@ -67,6 +67,7 @@ class Ingress: img_rb = await form['img'].read() img_nparray = np.frombuffer(img_rb, np.uint8) + img_nparray = cv2.imdecode(img_nparray, cv2.IMREAD_COLOR) img_nparray = cv2.cvtColor(img_nparray, cv2.COLOR_BGR2RGB) pred = await self.texteller_server.predict.remote(img_nparray) return pred