BADBADBADBOY / DBnet-lite.pytorch

A pytorch re-implementation of Real-time Scene Text Detection with Differentiable Binarization
107 stars 25 forks source link

加载预训练模型 #26

Open Lebesgue-zyker opened 1 year ago

Lebesgue-zyker commented 1 year ago

我想要加载官方给的pre-trained-model-synthtext-resnet18预训练模型,请问可以加载吗,是要从resume传入吗

Lebesgue-zyker commented 1 year ago

我尝试从resume加载pre-trained-model-synthtext-resnet50的预训练模型,报出如下错误 Resuming from checkpoint. Traceback (most recent call last): File "train.py", line 210, in <module> train_net(config) File "train.py", line 92, in train_net model.load_state_dict(checkpoint) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1605, in load_state_dict self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for DBNet: Missing key(s) in state_dict: "decode.head.in5.conv.weight", "decode.head.in5.bn.weight", "decode.head.in5.bn.bias", "decode.head.in5.bn.running_mean", "decode.head.in5.bn.running_var", "decode.head.in4.conv.weight", "decode.head.in4.bn.weight", "decode.head.in4.bn.bias", "decode.head.in4.bn.running_mean", "decode.head.in4.bn.running_var", "decode.head.in3.conv.weight", "decode.head.in3.bn.weight", "decode.head.in3.bn.bias", "decode.head.in3.bn.running_mean", "decode.head.in3.bn.running_var", "decode.head.in2.conv.weight", "decode.head.in2.bn.weight", "decode.head.in2.bn.bias", "decode.head.in2.bn.running_mean", "decode.head.in2.bn.running_var", "decode.head.out5.0.conv.weight", "decode.head.out5.0.bn.weight", "decode.head.out5.0.bn.bias", "decode.head.out5.0.bn.running_mean", "decode.head.out5.0.bn.running_var", "decode.head.out4.0.conv.weight", "decode.head.out4.0.bn.weight", "decode.head.out4.0.bn.bias", "decode.head.out4.0.bn.running_mean", "decode.head.out4.0.bn.running_var", "decode.head.out3.0.conv.weight", "decode.head.out3.0.bn.weight", "decode.head.out3.0.bn.bias", "decode.head.out3.0.bn.running_mean", "decode.head.out3.0.bn.running_var", "decode.head.out2.conv.weight", "decode.head.out2.bn.weight", "decode.head.out2.bn.bias", "decode.head.out2.bn.running_mean", "decode.head.out2.bn.running_var", "decode.binarize.0.weight", "decode.binarize.1.weight", "decode.binarize.1.bias", "decode.binarize.1.running_mean", "decode.binarize.1.running_var", "decode.binarize.3.weight", "decode.binarize.3.bias", "decode.binarize.4.weight", "decode.binarize.4.bias", "decode.binarize.4.running_mean", "decode.binarize.4.running_var", "decode.binarize.6.weight", "decode.binarize.6.bias", "decode.thresh.0.weight", "decode.thresh.1.weight", "decode.thresh.1.bias", "decode.thresh.1.running_mean", "decode.thresh.1.running_var", "decode.thresh.3.weight", "decode.thresh.3.bias", "decode.thresh.4.weight", "decode.thresh.4.bias", "decode.thresh.4.running_mean", "decode.thresh.4.running_var", "decode.thresh.6.weight", "decode.thresh.6.bias". Unexpected key(s) in state_dict: "decoder.in5.weight", "decoder.in4.weight", "decoder.in3.weight", "decoder.in2.weight", "decoder.out5.0.weight", "decoder.out4.0.weight", "decoder.out3.0.weight", "decoder.out2.weight", "decoder.binarize.0.weight", "decoder.binarize.1.weight", "decoder.binarize.1.bias", "decoder.binarize.1.running_mean", "decoder.binarize.1.running_var", "decoder.binarize.1.num_batches_tracked", "decoder.binarize.3.weight", "decoder.binarize.3.bias", "decoder.binarize.4.weight", "decoder.binarize.4.bias", "decoder.binarize.4.running_mean", "decoder.binarize.4.running_var", "decoder.binarize.4.num_batches_tracked", "decoder.binarize.6.weight", "decoder.binarize.6.bias", "decoder.thresh.0.weight", "decoder.thresh.1.weight", "decoder.thresh.1.bias", "decoder.thresh.1.running_mean", "decoder.thresh.1.running_var", "decoder.thresh.1.num_batches_tracked", "decoder.thresh.3.weight", "decoder.thresh.3.bias", "decoder.thresh.4.weight", "decoder.thresh.4.bias", "decoder.thresh.4.running_mean", "decoder.thresh.4.running_var", "decoder.thresh.4.num_batches_tracked", "decoder.thresh.6.weight", "decoder.thresh.6.bias", "backbone.fc.weight", "backbone.fc.bias", "backbone.smooth.weight", "backbone.smooth.bias", "backbone.layer2.0.conv2_offset.weight", "backbone.layer2.0.conv2_offset.bias", "backbone.layer2.1.conv2_offset.weight", "backbone.layer2.1.conv2_offset.bias", "backbone.layer2.2.conv2_offset.weight", "backbone.layer2.2.conv2_offset.bias", "backbone.layer2.3.conv2_offset.weight", "backbone.layer2.3.conv2_offset.bias", "backbone.layer3.0.conv2_offset.weight", "backbone.layer3.0.conv2_offset.bias", "backbone.layer3.1.conv2_offset.weight", "backbone.layer3.1.conv2_offset.bias", "backbone.layer3.2.conv2_offset.weight", "backbone.layer3.2.conv2_offset.bias", "backbone.layer3.3.conv2_offset.weight", "backbone.layer3.3.conv2_offset.bias", "backbone.layer3.4.conv2_offset.weight", "backbone.layer3.4.conv2_offset.bias", "backbone.layer3.5.conv2_offset.weight", "backbone.layer3.5.conv2_offset.bias", "backbone.layer4.0.conv2_offset.weight", "backbone.layer4.0.conv2_offset.bias", "backbone.layer4.1.conv2_offset.weight", "backbone.layer4.1.conv2_offset.bias", "backbone.layer4.2.conv2_offset.weight", "backbone.layer4.2.conv2_offset.bias".

Lebesgue-zyker commented 1 year ago

模型在训练中验证时报错: Traceback (most recent call last): File "/gemini/code/LUSTER/Detection/DBnet-lite/cal_rescall/rrc_evaluation_funcs.py", line 328, in main_evaluation evalData = evaluate_method_fn(p['g'], p['s'], evalParams) File "/gemini/code/LUSTER/Detection/DBnet-lite/cal_rescall/script.py", line 135, in evaluate_method subm = rrc_evaluation_funcs.load_folder_file(submFilePath, evaluationParams['DET_SAMPLE_NAME_2_ID'], True) File "/gemini/code/LUSTER/Detection/DBnet-lite/cal_rescall/rrc_evaluation_funcs.py", line 104, in load_folder_file raise Exception('ZIP entry not valid: %s' % name) Exception: ZIP entry not valid: res_12_2304_0.txt Traceback (most recent call last): File "train.py", line 207, in <module> train_net(config) File "train.py", line 177, in train_net rescall,precision,hmean = result_dict['recall'],result_dict['precision'],result_dict['hmean'] TypeError: string indices must be integers 使用的是ICDAR2015数据集,试了自己的数据集这是这个错误。