Replies: 1 comment
-
从您的描述和日志信息来看,问题可能集中在以下几个方面: 问题分析
解决方案1. 确保预训练模型与当前架构匹配
2. 检查权重加载日志
3. 调整推理模型导出流程
4. 数据集与字典文件的检查
5. 验证模型大小与配置
6. 检查优化器与学习率
7. 验证推理模型的正确性
相关参考总结
Response generated by feifei-bot | chatgpt-4o-latest |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
下载了官方的预训练模型进行训练后转推理模型,对训练完的模型进行推理测试,发现只能识别刚刚训练过的字,没有训练过的字就连微信截图“你 我 他”很简单的都会识别错误,我可以判断这种情况是预训练模型权重丢失,官方预训练模型有200m大小训练完成后2个文件加起来不到70m,转成推理模型后文件不到15m,不知道怎么回事,是bug或软件兼容问题,还是我操作不当,比如配置文件设置错误。检测过我配置文件中的已经加载了预训练模型,并且路径也是正确的,不知道预训练权重是在训练的时候就丢失,还是在转成推理模型的时候丢失。反复训练然后转成推理模型很多次,都是这种情况。有没有大佬知道这种情况,感激不尽。
我使用的终端命令如下
python tools/train.py -c configs\det\ch_PP-OCRv3\ch_PP-OCRv3_det_student.yml 训练de模型
python tools/train.py -c configs\rec\PP-OCRv3\ch_PP-OCRv3_rec_distillation.yml 训练rec模型
python tools/export_model.py -c "./configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml" -o Global.pretrained_model="./output/ch_PP-OCR_V3_det_student/latest.pdparams" Global.save_inference_dir="./inference_model/det"det模型转inference
python tools/export_model.py -c "./configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml" -o Global.pretrained_model="./output/ch_pp-OCRv3_rec_distillation/best_model/model.pdparams" Global.save_inference_dir="./inference_model/rec"rec模型转inference
以下是我的配置文件
Global:
debug: false
use_gpu: true #是否使用显卡进行训练,true表示使用显卡训练,false表示不使用显卡。
epoch_num: 300 #迭代次数次数越多。训练的模型精度越高
log_smooth_window: 20
print_batch_step: 25
save_model_dir: ./output/ch_pp-OCRv3_rec_distillation #训练后模型所保存的位置。
save_epoch_step: 50 #训练多少次自动保存一次模型
eval_batch_step: 50 #训练多少次进行一次模型评估
cal_metric_during_train: true
pretrained_model: ./pretrain_models/ch_PP-OCRv3_rec_train/best_accuracy.pdparams #预训练模型所保存的路径
checkpoints:
save_inference_dir:
use_visualdl: false
infer_img: doc/imgs_words/ch/word_1.jpg
character_dict_path: ppocr/utils/ppocr_keys_v1.txt
max_text_length: &max_text_length 25
infer_mode: false
use_space_char: true
distributed: true
save_res_path: ./output/rec/predicts_ppocrv3_distillation.txt
d2s_train_image_shape: [3, 48, -1]
Optimizer:
name: Adam
beta1: 0.9
beta2: 0.999
lr:
name: Piecewise
decay_epochs : [700]
values : [0.0005, 0.00005]
warmup_epoch: 5
regularizer:
name: L2
factor: 3.0e-05
Architecture:
model_type: &model_type "rec"
name: DistillationModel
algorithm: Distillation
Models:
Teacher:
pretrained:
freeze_params: false
return_all_feats: true
model_type: *model_type
algorithm: SVTR_LCNet
Transform:
Backbone:
name: MobileNetV1Enhance
scale: 0.5
last_conv_stride: [1, 2]
last_pool_type: avg
last_pool_kernel_size: [2, 2]
Head:
name: MultiHead
head_list:
- CTCHead:
Neck:
name: svtr
dims: 64
depth: 2
hidden_dims: 120
use_guide: True
Head:
fc_decay: 0.00001
- SARHead:
enc_dim: 512
max_text_length: *max_text_length
Student:
pretrained:
freeze_params: false
return_all_feats: true
model_type: *model_type
algorithm: SVTR_LCNet
Transform:
Backbone:
name: MobileNetV1Enhance
scale: 0.5
last_conv_stride: [1, 2]
last_pool_type: avg
last_pool_kernel_size: [2, 2]
Head:
name: MultiHead
head_list:
- CTCHead:
Neck:
name: svtr
dims: 64
depth: 2
hidden_dims: 120
use_guide: True
Head:
fc_decay: 0.00001
- SARHead:
enc_dim: 512
max_text_length: *max_text_length
Loss:
name: CombinedLoss
loss_config_list:
weight: 1.0
act: "softmax"
use_log: true
model_name_pairs:
key: head_out
multi_head: True
dis_head: ctc
name: dml_ctc
weight: 0.5
act: "softmax"
use_log: true
model_name_pairs:
key: head_out
multi_head: True
dis_head: sar
name: dml_sar
weight: 1.0
mode: "l2"
model_name_pairs:
key: backbone_out
weight: 1.0
model_name_list: ["Student", "Teacher"]
key: head_out
multi_head: True
weight: 1.0
model_name_list: ["Student", "Teacher"]
key: head_out
multi_head: True
PostProcess:
name: DistillationCTCLabelDecode
model_name: ["Student", "Teacher"]
key: head_out
multi_head: True
Metric:
name: DistillationMetric
base_metric_name: RecMetric
main_indicator: acc
key: "Student"
ignore_space: False
Train:
dataset:
name: SimpleDataSet
data_dir: ./train_data/ #识别模型数据集所在的文件夹的上一层文件夹
ext_op_transform_idx: 1
label_file_list:
- ./train_data/rec/train.txt #训练数据集所标注文件所在的路径,路径精确到具体的文件的后缀名。
transforms:
- DecodeImage:
img_mode: BGR
channel_first: false
- RecConAug:
prob: 0.5
ext_data_num: 2
image_shape: [48, 320, 3]
max_text_length: *max_text_length
- RecAug:
- MultiLabelEncode:
- RecResizeImg:
image_shape: [3, 48, 320]
- KeepKeys:
keep_keys:
- image
- label_ctc
- label_sar
- length
- valid_ratio
loader:
shuffle: true
batch_size_per_card: 10
drop_last: true
num_workers: 4
Eval:
dataset:
name: SimpleDataSet
data_dir: ./train_data #识别模型数据集所在的文件夹的上一层文件夹
label_file_list:
- ./train_data/rec/val.txt #识别模型数据集标注文件所在的路径,精确的文件后缀名。
transforms:
- DecodeImage:
img_mode: BGR
channel_first: false
- MultiLabelEncode:
- RecResizeImg:
image_shape: [3, 48, 320]
- KeepKeys:
keep_keys:
- image
- label_ctc
- label_sar
- length
- valid_ratio
loader:
shuffle: false
drop_last: false
batch_size_per_card: 10
num_workers: 4
Beta Was this translation helpful? Give feedback.
All reactions