TheJaeLal / LineFormer

Line Chart Data Extraction: Official code for LineFormer - ICDAR23 Paper
24 stars 6 forks source link

error in loading config file #4

Closed sazidrj closed 6 months ago

sazidrj commented 8 months ago

I am running the demo inference code

import infer import cv2 import line_utils

img_path = "demo/PMC5959982___3_HTML.jpg" img = cv2.imread(img_path) # BGR format

CKPT = "iter_3000.pth" CONFIG = "lineformer_swin_t_config.py" DEVICE = "cpu"

infer.load_model(CONFIG, CKPT, DEVICE) line_dataseries = infer.get_dataseries(img, to_clean=False)

img = line_utils.draw_lines(img, line_utils.points_to_array(line_dataseries))

cv2.imwrite('demo/sample_result.png', img)

but I am getting below runtime error....

Traceback (most recent call last): File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/config/config.py", line 109, in getattr value = super().getattr(name) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/addict/addict.py", line 67, in getattr return self.getitem(item) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/config/config.py", line 138, in getitem return self.build_lazy(super().getitem(key)) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/config/config.py", line 105, in missing raise KeyError(name) KeyError: 'layer_cfg'

During handling of the above exception, another exception occurred:

Error

Traceback (most recent call last): File "/home/ipsavi/Sazid/LineFormer-main/demo.py", line 12, in infer.load_model(CONFIG, CKPT, DEVICE) File "/home/ipsavi/Sazid/LineFormer-main/infer.py", line 52, in load_model model = init_detector(config, ckpt, device=device) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmdet/apis/inference.py", line 66, in init_detector model = MODELS.build(config.model) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build return self.build_func(cfg, args, kwargs, registry=self) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg obj = obj_cls(args) # type: ignore File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmdet/models/detectors/mask2former.py", line 22, in init super().init( File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmdet/models/detectors/maskformer.py", line 36, in init self.panoptic_head = MODELS.build(panoptichead) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build return self.build_func(cfg, args, kwargs, registry=self) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg obj = obj_cls(args) # type: ignore File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmdet/models/dense_heads/mask2former_head.py", line 104, in init self.num_heads = transformer_decoder.layer_cfg.cross_attn_cfg.num_heads File "/home/ipsavi/anaconda3/envs/LineFormer/lib/python3.8/site-packages/mmengine/config/config.py", line 113, in getattr raise AttributeError(f"'{self.class.name}' object has no " AttributeError: 'ConfigDict' object has no attribute 'layer_cfg'

sazidrj commented 8 months ago

I think some configuration missing in lineformer_swin_t_config.py file

Cxmorifolium commented 7 months ago

getting the same error, is there a fix?

sazidrj commented 7 months ago

install mmdet==2.28.2