PaddlePaddle / FastDeploy

⚡️An Easy-to-use and Fast Deep Learning Model Deployment Toolkit for ☁️Cloud 📱Mobile and 📹Edge. Including Image, Video, Text and Audio 20+ main stream scenarios and 150+ SOTA models with end-to-end optimization, multi-platform and multi-framework support.
https://www.paddlepaddle.org.cn/fastdeploy
Apache License 2.0
3k stars 465 forks source link

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

Open zhouyiminga opened 1 year ago

zhouyiminga commented 1 year ago

报错如下

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)
dengmingD commented 1 year ago

图片有可能为空

zhouyiminga commented 1 year ago

图片有可能为空

不会啊,是一批图片中的一部分识别的时候会报这个错,但是这部分图片是百分百报这个错的,重试多少下都是。然后我修改了下model.py的代码,这部分原来百分百会报错的图片再传过去就也能返回识别结果了