DevashishPrasad / CascadeTabNet

This repository contains the code and implementation details of the CascadeTabNet paper "CascadeTabNet: An approach for end to end table detection and structure recognition from image-based documents"
MIT License
1.46k stars 422 forks source link

The show_result_pyplot() function using the newer version of MMdet has missing parameters. #173

Open wlhpange opened 1 year ago

wlhpange commented 1 year ago

Hello, dear developers. I have a pressing problem now.I am a beginner in this field, and I have the following problems when running demo: The following are tips:

E:\Coding\workbench\test14\mmdetection\mmdet\models\builder.py:50: UserWarning: train_cfg and test_cfg is deprecated, please specify them in model
  warnings.warn(
E:\Coding\PyEnv\test14\lib\site-packages\mmcv\utils\misc.py:333: UserWarning: "out_size" is deprecated in `RoIAlign.__init__`, please use "output_size" instead
  warnings.warn(
E:\Coding\PyEnv\test14\lib\site-packages\mmcv\utils\misc.py:333: UserWarning: "sample_num" is deprecated in `RoIAlign.__init__`, please use "sampling_ratio" instead
  warnings.warn(

load checkpoint from local path: epoch_36.pth
The model and loaded state dict do not match exactly

unexpected key in source state_dict: bbox_head.0.fc_cls.weight, bbox_head.0.fc_cls.bias, bbox_head.0.fc_reg.weight, bbox_head.0.fc_reg.bias, bbox_head.0.shared_fcs.0.weight, bbox_head.0.shared_fcs.0.bias, bbox_head.0.shared_fcs.1.weight, bbox_head.0.shared_fcs.1.bias, bbox_head.1.fc_cls.weight, bbox_head.1.fc_cls.bias, bbox_head.1.fc_reg.weight, bbox_head.1.fc_reg.bias, bbox_head.1.shared_fcs.0.weight, bbox_head.1.shared_fcs.0.bias, bbox_head.1.shared_fcs.1.weight, bbox_head.1.shared_fcs.1.bias, bbox_head.2.fc_cls.weight, bbox_head.2.fc_cls.bias, bbox_head.2.fc_reg.weight, bbox_head.2.fc_reg.bias, bbox_head.2.shared_fcs.0.weight, bbox_head.2.shared_fcs.0.bias, bbox_head.2.shared_fcs.1.weight, bbox_head.2.shared_fcs.1.bias, mask_head.0.convs.0.conv.weight, mask_head.0.convs.0.conv.bias, mask_head.0.convs.1.conv.weight, mask_head.0.convs.1.conv.bias, mask_head.0.convs.2.conv.weight, mask_head.0.convs.2.conv.bias, mask_head.0.convs.3.conv.weight, mask_head.0.convs.3.conv.bias, mask_head.0.upsample.weight, mask_head.0.upsample.bias, mask_head.0.conv_logits.weight, mask_head.0.conv_logits.bias, mask_head.1.convs.0.conv.weight, mask_head.1.convs.0.conv.bias, mask_head.1.convs.1.conv.weight, mask_head.1.convs.1.conv.bias, mask_head.1.convs.2.conv.weight, mask_head.1.convs.2.conv.bias, mask_head.1.convs.3.conv.weight, mask_head.1.convs.3.conv.bias, mask_head.1.upsample.weight, mask_head.1.upsample.bias, mask_head.1.conv_logits.weight, mask_head.1.conv_logits.bias, mask_head.2.convs.0.conv.weight, mask_head.2.convs.0.conv.bias, mask_head.2.convs.1.conv.weight, mask_head.2.convs.1.conv.bias, mask_head.2.convs.2.conv.weight, mask_head.2.convs.2.conv.bias, mask_head.2.convs.3.conv.weight, mask_head.2.convs.3.conv.bias, mask_head.2.upsample.weight, mask_head.2.upsample.bias, mask_head.2.conv_logits.weight, mask_head.2.conv_logits.bias

missing keys in source state_dict: roi_head.bbox_head.0.fc_cls.weight, roi_head.bbox_head.0.fc_cls.bias, roi_head.bbox_head.0.fc_reg.weight, roi_head.bbox_head.0.fc_reg.bias, roi_head.bbox_head.0.shared_fcs.0.weight, roi_head.bbox_head.0.shared_fcs.0.bias, roi_head.bbox_head.0.shared_fcs.1.weight, roi_head.bbox_head.0.shared_fcs.1.bias, roi_head.bbox_head.1.fc_cls.weight, roi_head.bbox_head.1.fc_cls.bias, roi_head.bbox_head.1.fc_reg.weight, roi_head.bbox_head.1.fc_reg.bias, roi_head.bbox_head.1.shared_fcs.0.weight, roi_head.bbox_head.1.shared_fcs.0.bias, roi_head.bbox_head.1.shared_fcs.1.weight, roi_head.bbox_head.1.shared_fcs.1.bias, roi_head.bbox_head.2.fc_cls.weight, roi_head.bbox_head.2.fc_cls.bias, roi_head.bbox_head.2.fc_reg.weight, roi_head.bbox_head.2.fc_reg.bias, roi_head.bbox_head.2.shared_fcs.0.weight, roi_head.bbox_head.2.shared_fcs.0.bias, roi_head.bbox_head.2.shared_fcs.1.weight, roi_head.bbox_head.2.shared_fcs.1.bias, roi_head.mask_head.0.convs.0.conv.weight, roi_head.mask_head.0.convs.0.conv.bias, roi_head.mask_head.0.convs.1.conv.weight, roi_head.mask_head.0.convs.1.conv.bias, roi_head.mask_head.0.convs.2.conv.weight, roi_head.mask_head.0.convs.2.conv.bias, roi_head.mask_head.0.convs.3.conv.weight, roi_head.mask_head.0.convs.3.conv.bias, roi_head.mask_head.0.upsample.weight, roi_head.mask_head.0.upsample.bias, roi_head.mask_head.0.conv_logits.weight, roi_head.mask_head.0.conv_logits.bias, roi_head.mask_head.1.convs.0.conv.weight, roi_head.mask_head.1.convs.0.conv.bias, roi_head.mask_head.1.convs.1.conv.weight, roi_head.mask_head.1.convs.1.conv.bias, roi_head.mask_head.1.convs.2.conv.weight, roi_head.mask_head.1.convs.2.conv.bias, roi_head.mask_head.1.convs.3.conv.weight, roi_head.mask_head.1.convs.3.conv.bias, roi_head.mask_head.1.upsample.weight, roi_head.mask_head.1.upsample.bias, roi_head.mask_head.1.conv_logits.weight, roi_head.mask_head.1.conv_logits.bias, roi_head.mask_head.2.convs.0.conv.weight, roi_head.mask_head.2.convs.0.conv.bias, roi_head.mask_head.2.convs.1.conv.weight, roi_head.mask_head.2.convs.1.conv.bias, roi_head.mask_head.2.convs.2.conv.weight, roi_head.mask_head.2.convs.2.conv.bias, roi_head.mask_head.2.convs.3.conv.weight, roi_head.mask_head.2.convs.3.conv.bias, roi_head.mask_head.2.upsample.weight, roi_head.mask_head.2.upsample.bias, roi_head.mask_head.2.conv_logits.weight, roi_head.mask_head.2.conv_logits.bias

E:\Coding\workbench\test14\mmdetection\mmdet\datasets\utils.py:64: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.
  warnings.warn(
E:\Coding\PyEnv\test14\lib\site-packages\torch\nn\functional.py:2970: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  warnings.warn("Default upsampling behavior when mode={} is changed "
E:\Coding\workbench\test14\mmdetection\mmdet\models\dense_heads\rpn_head.py:191: UserWarning: In rpn_proposal or test_cfg, nms_thr has been moved to a dict named nms as iou_threshold, max_num has been renamed as max_per_img, name of original arguments and the way to specify iou_threshold of NMS will be deprecated.
  warnings.warn(

The displayed result is the original image.

After querying the data and browsing the code of the display result function, I found that the show_result_pyplot() function in MMDetection 1.2.0/MMDET/APIs/Influence.py used in master has a class_names parameter, but the mmdetection2.12.0 I used does not have this parameter. I don't know what to do next to make the demo display the correct result. It may not be just the problem of this function, but the pre-training model uses the specified epoch_36.pth. .. I hope you can take the time to guide me.

The following is my configuration environment: PC:windows11 mmdetection:v2.12.0 mmvc:1.4.0 torch:1.5.0 torchvision==0.6.0 cuda:10.1 pillow:9.4.0

wlhpange commented 1 year ago

In addition, this is the code I used.

from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmcv
# Load model
config_file = 'CascadeTabNet/Config/cascade_mask_rcnn_hrnetv2p_w32_20e_v2.py'
checkpoint_file = 'epoch_36.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')

# Test a single image 
img = "CascadeTabNet/Demo/demo.png"

# Run Inference
result = inference_detector(model, img)
# Visualization results
show_result_pyplot(model,img, result,score_thr=0.85)
wlhpange commented 1 year ago

Do I need to retrain the data set in this environment? But the previous pre-training model can't be used!

ZCappuccino commented 1 month ago

Hello, I have encountered the same problem as you. Have you solved it now?