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

Failed to upgrade config #99

Closed playgithub closed 3 years ago

playgithub commented 3 years ago

pip install torch==1.4.0+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html Failed, so I mannual download the corresponding .whl that is with 1cu101, but failed when import, error is aboutImportError DLL ...`. Windows 10 & VS2019. It seems like dll incompatible problem.

So tried try the most recent version my hardware supports for everty package. torch 1.7.p+cu110 mmvc-full 1.2.0 mmdet 2.6.0 etc

demo code


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

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

# Run Inference
result = inference_detector(model, img)

# Visualization results
show_result_pyplot(img, result,('Bordered', 'cell', 'Borderless'), score_thr=0.85)

error

TypeError: __init__() got an unexpected keyword argument 'num_stages'

After some search, it's like the config is outdate, try to upgrade it, but failed

> python D:\mmdetection\tools\upgrade_model_version.py cascade_mask_rcnn_hrnetv2p_w32_20e.py new.py

Traceback (most recent call last):
  File "D:\mmdetection\tools\upgrade_model_version.py", line 209, in <module>
    main()
  File "D:\mmdetection\tools\upgrade_model_version.py", line 205, in main
    convert(args.in_file, args.out_file, args.num_classes)
  File "D:\mmdetection\tools\upgrade_model_version.py", line 121, in convert
    checkpoint = torch.load(in_file)
  File "D:\TestCascadeTabNet\env\lib\site-packages\torch\serialization.py", line 595, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "D:\TestCascadeTabNet\env\lib\site-packages\torch\serialization.py", line 764, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '#'.

Any way?

marcdemers commented 3 years ago

I just faced the same problem. Since the v1.2.0 branch is not available anymore from mmdetection repo, you can download the source here. This implementation has the required kwargs. Hope this helps,