PaddlePaddle / PaddleX

All-in-One Development Tool based on PaddlePaddle(飞桨低代码开发工具)
Apache License 2.0
4.92k stars 961 forks source link

AttributeError: 'paddle.base.libpaddle.AnalysisConfig' object has no attribute 'set_optimization_level' #2536

Closed birdAgent closed 12 hours ago

birdAgent commented 14 hours ago

你好!非常感谢你们的工作。我在使用人脸识别产线使用教程时遇到了缺少方法的问题

按照https://github.com/PaddlePaddle/PaddleX/blob/develop/docs/pipeline_usage/tutorials/cv_pipelines/face_recognition.md

运行

from` paddlex import create_pipeline

pipeline = create_pipeline(pipeline="face_recognition")

pipeline.build_index(data_root="face_demo_gallery", index_dir="face_gallery_index")

output = pipeline.predict("friends1.jpg", index_dir="face_gallery_index")
for res in output:
    res.print()
    res.save_to_img("./output/")

报错 Using official model (BlazeFace), the model files will be be automatically downloaded and saved in /home/server/.paddlex/official_models. Traceback (most recent call last): File "example.py", line 50, in pipeline = create_pipeline(pipeline="face_recognition") File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/pipelines/init.py", line 119, in create_pipeline return create_pipeline_from_config( File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/pipelines/init.py", line 94, in create_pipeline_from_config pipeline = BasePipeline.get(pipeline_name)( File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/pipelines/base.py", line 39, in _patched_init__ ret = ctx.run(init_func, self, *args, **kwargs) File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/pipelines/base.py", line 39, in patchedinit ret = ctx.run(init_func, self, *args, **kwargs) File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/pipelines/pp_shitu_v2.py", line 45, in init self._build_predictor(det_model, rec_model) File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/pipelines/pp_shitu_v2.py", line 63, in _build_predictor self.det_model = self._create(model=det_model) File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/pipelines/base.py", line 71, in _create return create_predictor( File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/models/init__.py", line 88, in create_predictor return BasicPredictor.get(model_name)( File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/models/base/basic_predictor.py", line 47, in init self._build_components() File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/models/object_detection.py", line 41, in _build_components predictor = ImageDetPredictor( File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/components/paddle_predictor/predictor.py", line 73, in init self._update_option(option) File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/components/paddle_predictor/predictor.py", line 80, in _update_option self._reset() File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/components/paddle_predictor/predictor.py", line 98, in _reset ) = self._create() File "/home/8TDisk/lzm/code/PaddleX/paddlex/inference/components/paddle_predictor/predictor.py", line 187, in _create config.set_optimization_level(3) AttributeError: 'paddle.base.libpaddle.AnalysisConfig' object has no attribute 'set_optimization_level'

复现

  1. 已经按照提供的教程安装依赖库

  2. 未修改代码

  3. 文档2.2.2步骤下载数据集

  4. 报错信息如上

环境

  1. PaddlePaddle:paddlepaddle-gpu 2.6.1 ;PaddleX: 3.0.0b2

  2. 操作系统:ubuntu 18.04

  3. python版本:3.8.20

  4. CUDA 11.8

zhang-prog commented 13 hours ago

目前的示例有点问题,请使用3.0b2的PaddleX运行这个示例

from paddlex import create_pipeline

pipeline = create_pipeline(pipeline="face_recognition")

index = pipeline.build_index(gallery_imgs="face_demo_gallery", gallery_label="face_demo_gallery/gallery.txt")

output = pipeline.predict("friends1.jpg", index=index)
for res in output:
    res.print()
    res.save_to_img("./output/")
birdAgent commented 12 hours ago

@zhang-prog 按照修改能正常运行了,非常感谢!