PaddlePaddle / PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)【安全加固,暂停交互,请耐心等待】
https://www.paddlepaddle.org.cn/hub
Apache License 2.0
12.72k stars 2.08k forks source link

警告,代码不执行:W0320 23:05:13.228931 16218 analysis_predictor.cc:1059] Deprecated. Please use CreatePredictor instead. #1331

Open Irvingao opened 3 years ago

Irvingao commented 3 years ago

代码:

import paddlehub as hub import cv2 import time if __name__ == "__main__": face_detector = hub.Module(name="pyramidbox_face_detection") result = face_detector.face_detection(images=[cv2.imread('./test.jpg')]) print("result", result) cv2.waitKey()

输出图

image

程序不往下执行,卡住。

Irvingao commented 3 years ago

使用旧版本模型可以正常使用CPU预测。

haoyuying commented 3 years ago

尝试下

result = face_detector.face_detection(images=[cv2.imread('./test.jpg')],
                   output_dir='detection_result',  
                   visualization=True)

看看能不能保存图片结果。 我这边用了这个脚本,是可以得到结果的

import paddlehub as hub 
import cv2 
import time 
if __name__ == "__main__": 
    face_detector = hub.Module(name="pyramidbox_face_detection") 
    result = face_detector.face_detection(images=[cv2.imread('2007_000170.jpg')])
    print("result", result) 

paddlepaddle-gpu和paddlehub都是用的2.0.0,可以把paddlehub升级成2.0试一下

Irvingao commented 3 years ago

下载paddlehub2.0后,导致paddlepaddle直接崩溃。

dajiew commented 3 years ago

尝试下

result = face_detector.face_detection(images=[cv2.imread('./test.jpg')],
                   output_dir='detection_result',  
                   visualization=True)

看看能不能保存图片结果。 我这边用了这个脚本,是可以得到结果的

import paddlehub as hub 
import cv2 
import time 
if __name__ == "__main__": 
    face_detector = hub.Module(name="pyramidbox_face_detection") 
    result = face_detector.face_detection(images=[cv2.imread('2007_000170.jpg')])
    print("result", result) 

paddlepaddle-gpu和paddlehub都是用的2.0.0,可以把paddlehub升级成2.0试一下


import cv2
import os

ocr = hub.Module(name="chinese_ocr_db_crnn_mobile")
result = ocr.recognize_text(images=[cv2.imread(r'C:\Data\OCR\Images\01.png')],output_dir='./ocr_result', visualization=True)
print('-----------------------------------')
ocr = hub.Module(name='chinese_ocr_db_crnn_mobile')
np_images = [cv2.imread(os.path.join(r'C:\Data\OCR\Images',image_path)) for image_path in os.listdir(r'C:\Data\OCR\Images')]
results = ocr.recognize_text(
        images=np_images,
        use_gpu=False,
        output_dir='./ocr_result',
        visualization=True,
        box_thresh=0.5,
        text_thresh=0.5
)```
我这边也是,代码不执行只是报警告。环境是cuda 10.2 cudnn 7.6.5  paddle 2.0 paddlehub 2.0.4 py3.8的
报错信息为:
`[2021-03-23 14:28:21,030] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __ init_ _() to handle the initialization of the object
W0323 14:28:20.153537 85932 analysis_predictor.cc:1145] Deprecated. Please use CreatePredictor instead.`