PaddleOCR2Pytorch icon indicating copy to clipboard operation
PaddleOCR2Pytorch copied to clipboard

AttributeError: module 'paddle.fluid' has no attribute 'load_dygraph'

Open ziFan99 opened this issue 1 year ago • 4 comments

我在进行paddle转成pytorch模型的时候,遇到这个报错信息: Traceback (most recent call last): File "./converter/ch_ppocr_v4_rec_server_converter.py", line 112, in converter = PPOCRv4RecConverter(cfg, paddle_pretrained_model_path) File "./converter/ch_ppocr_v4_rec_server_converter.py", line 12, in init para_state_dict, opti_state_dict = self.read_paddle_weights(paddle_pretrained_model_path) File "/root/autodl-tmp/PaddleOCR2Pytorch-main/pytorchocr/base_ocr_v20.py", line 97, in read_paddle_weights para_state_dict, opti_state_dict = fluid.load_dygraph(weights_path) AttributeError: module 'paddle.fluid' has no attribute 'load_dygraph' 我使用的命令是: python ./converter/ch_ppocr_v4_rec_server_converter.py --yaml_path /root/autodl-tmp/PaddleOCR-2.9.1/models/rec/recv4_hgnet_server_Augcustom/config.yml --src_model_path /root/autodl-tmp/PaddleOCR-2.9.1/models/rec/recv4_hgnet_server_Augcustom 请问这个是什么问题?

ziFan99 avatar Jan 14 '25 03:01 ziFan99

可能是新版paddle去掉这个接口了

frotms avatar Jan 14 '25 06:01 frotms

That's true! Then, how can we convert with the newest version of paddle (without degrading ther version)?

KienTranDSAI avatar Feb 10 '25 01:02 KienTranDSAI

您好!我遇到了相似的问题。使用的是paddlepaddle==2.5.2, paddleocr>2.6。 当用 python ./converter/ch_ppocr_v4_det_converter.py --yaml_path ./configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml --src_model_path ppocr_models/ch_PP-OCRv4_det_train 跑之后, 出现如下报错:AttributeError: module 'paddle.fluid' has no attribute 'load_dygraph'。 请问load_dygraph 可以用其他function代替吗?

mumuMia avatar Mar 17 '25 19:03 mumuMia

By the way, I got it working by using the following package version combination, you can try it out: python 3.9, pip <22.0.4, paddlepaddle 2.4.1, paddleocr 2.10.0, packaging 24.2. fluid was deprecated after paddlepaddle 2.5, so you have to use the 2.4.x version or lower. I hope this will fix your problem.

mumuMia avatar Mar 18 '25 15:03 mumuMia