PaddleHub修改模型缓存路径HUB_HOME

本文介绍了如何在Windows 11系统中为PaddleHub设置自定义的预训练模型存放路径,以避免C盘占用。通过创建HUB_HOME环境变量指向E盘的.paddlehub文件夹,解决了模型存储问题。

使用Paddlehub多了发现C盘被塞爆了,一看是用户文件下.paddlehub里面有大量模型文件。第一时间肯定是想如何修改这个路径。查了一下资料,官方有提供方法,记录一下。

PaddleHub支持修改预训练模型存放路径:

  • 如已设置${HUB_HOME}环境变量,则预训练模型、配置等文件都存放在${HUB_HOME}指示的路径下
  • 如未设置${HUB_HOME}环境变量,则存放在$HOME指示的路径下

我用的是Win11

我直接添加了一个名叫HUB_HOME环境变量。

变量值:E:\.paddlehub

这样所有内容就会缓存到E盘.paddlehub文件下面了。

报错:[2025-07-02 23:12:53,128] [ WARNING] - The home directory contains Chinese characters which may cause unknown exceptions in the execution of some modules. Please set another path through the set HUB_HOME command. E0702 23:12:53.176828 26960 analysis_config.cc:169] Please use PaddlePaddle with GPU version. E0702 23:12:53.361079 26960 analysis_config.cc:169] Please use PaddlePaddle with GPU version. 识别中文文本结果: Download https://bj.bcebos.com/paddlehub/paddlehub_dev/chinese_text_detection_db_mobile_1.1.0.zip [##################################################] 100.00% Decompress C:\Users\田龙飞\.paddlehub\tmp\tmpqgas7s5_\chinese_text_detection_db_mobile_1.1.0.zip [##################################################] 100.00% [2025-07-02 23:13:01,965] [ INFO] - Successfully installed dependent packages. [2025-07-02 23:13:02,031] [ INFO] - Successfully installed chinese_text_detection_db_mobile-1.1.0 Traceback (most recent call last): File "E:\Project\Python\SJZ-GC\paddle_ocr.py", line 63, in <module> chinese_texts = recognize_chinese(image_path) File "E:\Project\Python\SJZ-GC\paddle_ocr.py", line 23, in recognize_chinese results = ocr.recognize_text(images=[img], use_gpu=True) File "D:\Exp\Python38\lib\site-packages\paddlehub\compat\paddle_utils.py", line 221, in runner return func(*args, **kwargs) File "E:\PaddleOCR\paddle_hub_models\chinese_ocr_db_crnn_mobile\module.py", line 234, in recognize_text detection_results = self.text_detector_module.detect_text(images=predicted_data, File "D:\Exp\Python38\lib\site-packages\paddlehub\module\module.py", line 95, in __getattribute__ _attr = object.__getattribute__(self, attr) File "E:\PaddleOCR\paddle_hub_models\chinese_ocr_db_crnn_mobile\module.py", line 108, in text_detector_module self._text_detector_module = hub.Module(name='chinese_text_detection_db_mobile', File "D:\Exp\Python38\lib\site-packages\paddlehub\module\module.py", line 393, in __new__ module = cls.init_with_name( File "D:\Exp\Python38\lib\site-packages\paddlehub\module\module.py", line 516, in init_with_name return user_module_cls(**kwargs) File "C:\Users\田龙飞\.paddlehub\modules\chinese_text_detection_db_mobile\module.py", line 61, in __init__ self._set_config() File "D:\Exp\Python38\lib\site-packages\paddlehub\compat\paddle_utils.py", line 221, in runner return func(*args, **kwargs) File "C:\Users\田龙飞\.paddlehub\modules\chinese_text_detection_db_mobile\module.py", line 78, in _set_config config = Config(model_file_path, params_file_path) RuntimeError: (NotFound) Cannot open file C:\Users\田龙飞\.paddlehub\modules\chinese_text_detection_db_mobile\inference_model\model.pdmodel, please confirm whether the file is normal. [Hint: Expected paddle::inference::IsFileExists(prog_file_) == true, but received paddle::inference::IsFileExists(prog_file_):0 != true:1.] (at ..\paddle\fluid\inference\api\analysis_config.cc:117)
07-03
报错: ��Ϣ: ���ṩ��ģʽ�޷��ҵ��ļ��� D:\Exp\Python38\lib\site-packages\paddle\utils\cpp_extension\extension_utils.py:711: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. You can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md warnings.warn(warning_message) [2025-07-02 23:01:54,244] [ WARNING] - The home directory contains Chinese characters which may cause unknown exceptions in the execution of some modules. Please set another path through the set HUB_HOME command. Download https://bj.bcebos.com/paddlehub/paddlehub_dev/chinese_ocr_db_crnn_mobile_1.2.0.zip [##################################################] 100.00% Decompress C:\Users\田龙飞\.paddlehub\tmp\tmphyd3kin5\chinese_ocr_db_crnn_mobile_1.2.0.zip [##################################################] 100.00% [2025-07-02 23:02:05,465] [ INFO] - Successfully installed chinese_ocr_db_crnn_mobile-1.2.0 Traceback (most recent call last): File "E:\Project\Python\SJZ-GC\paddle_ocr.py", line 5, in <module> ocr = hub.Module(name="chinese_ocr_db_crnn_mobile") File "D:\Exp\Python38\lib\site-packages\paddlehub\module\module.py", line 393, in __new__ module = cls.init_with_name( File "D:\Exp\Python38\lib\site-packages\paddlehub\module\module.py", line 516, in init_with_name return user_module_cls(**kwargs) File "C:\Users\田龙飞\.paddlehub\modules\chinese_ocr_db_crnn_mobile\module.py", line 57, in __init__ self.rec_predictor, self.rec_input_tensor, self.rec_output_tensors = self._set_config( File "D:\Exp\Python38\lib\site-packages\paddlehub\compat\paddle_utils.py", line 221, in runner return func(*args, **kwargs) File "C:\Users\田龙飞\.paddlehub\modules\chinese_ocr_db_crnn_mobile\module.py", line 69, in _set_config config = Config(model_file_path, params_file_path) RuntimeError: (NotFound) Cannot open file C:\Users\田龙飞\.paddlehub\modules\chinese_ocr_db_crnn_mobile\inference_model\character_rec\model.pdmodel, please confirm whether the file is normal. [Hint: Expected paddle::inference::IsFileExists(prog_file_) == true, but received paddle::inference::IsFileExists(prog_file_):0 != true:1.] (at ..\paddle\fluid\inference\api\analysis_config.cc:117)
07-03
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值