PaddlePaddle / PaddlePaddle/FastDeploy

fastdeploy服务化部署,部分图片传到服务后会报错module 'numpy' has no attribute 'astype'

Open
#2,190 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
756
Avg merge
19h 28m
Merged PRs (30d)
4

Description

  • 【FastDeploy版本】:fastdeploy:1.0.4-cpu-only-21.10
  • 【系统平台】: 官方docker

报错如下

0904 12:09:52.059001 1627 pb_stub.cc:402] Failed to process the request(s) for model 'det_postprocess_0', message: AttributeError: module 'numpy' has no attribute 'astype'

At:
  /usr/local/lib/python3.8/dist-packages/numpy/__init__.py(284): __getattr__
  /opt/tritonserver/FastDeploy/examples/vision/ocr/PP-OCR/serving/fastdeploy_serving/models/det_postprocess/1/model.py(197): execute

我根据报错尝试查看了一下这个det_postprocess/1/model.py的代码,execute方法里就两处用到了astype。其中有一行代码我看着很奇怪,尝试改了下(倒数第二行改为了倒数第一行)。改了之后就能正常识别之前会报错的那批图片了。这应该算是一个BUG吧,但是我不懂python不知道我改得对不对,希望大佬确认一下

                for index in range(len(image_list)):
                    if cls_labels[index] == 1 and cls_scores[
                            index] > self.cls_threshold:
                        image_list[index] = cv2.rotate(
                            image_list[index].astype(np.float32), 1)
                        #image_list[index] = np.astype(np.uint8)
			image_list[index] = image_list[index].astype(np.uint8)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open det_postprocess/1/model.py and inspect execute around line 197, where the failing module-level astype call is shown. Compare the two astype usages, then reproduce with the affected images and verify that the OCR service processes them without the NumPy AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, opencv, python
Domain
backend, devops
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.