FangShancheng / ABINet

Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition
Other
420 stars 72 forks source link

AssertionError: idx 0 != idx_new 2998 during testing. #96

Open wu-yz opened 1 year ago

wu-yz commented 1 year ago

When I run "CUDA_VISIBLE_DEVICES=0 python main.py --config=configs/train_abinet.yaml --phase test --image_only",I getting the error:"AssertionError: idx 0 != idx_new 2998 during testing." Could you tell me how to solve this problem?Thank you very much!

wu-yz commented 1 year ago

No,I haven't resolved it.

anthonyAndchen commented 12 months ago

你好,我经过一些尝试后,发现把出现断言错误的这一行代码注释掉后,在modules.model.py中的_get_length函数修改一下就可以运行。 原来的函数: def _get_length(self, logit, dim=-1): """ Greed decoder to obtain length from logit""" out = (logit.argmax(dim=-1) == self.charset.null_label) out = self.first_nonzero(out.int()) + 1 return out 修改为: def _get_length(self, logit, dim=-1): """ Greed decoder to obtain length from logit"""

    out = (logit.argmax(dim=-1) == self.charset.null_label)
    abn = out.any(dim)
    out = ((out.cumsum(dim) == 1) & out).max(dim)[1]
    out = out + 1  # additional end token
    out = torch.where(abn, out, out.new_tensor(logit.shape[1]))
    return out

发件人: wu-yz @.> 发送时间: 2023年9月7日 20:55 收件人: FangShancheng/ABINet @.> 抄送: anthonyAndchen @.>; Comment @.> 主题: Re: [FangShancheng/ABINet] AssertionError: idx 0 != idx_new 2998 during testing. (Issue #96)

No,I haven't resolved it.

― Reply to this email directly, view it on GitHubhttps://github.com/FangShancheng/ABINet/issues/96#issuecomment-1710103943, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOWBX26XAB4BMVCVY63VBF3XZG745ANCNFSM6AAAAAAZMZHR7A. You are receiving this because you commented.Message ID: @.***>

wu-yz commented 12 months ago

你好,我经过一些尝试后,发现把出现断言错误的这一行代码注释掉后,在modules.model.py中的_get_length函数修改一下就可以运行。 原来的函数: def _get_length(self, logit, dim=-1): """ Greed decoder to obtain length from logit""" out = (logit.argmax(dim=-1) == self.charset.null_label) out = self.first_nonzero(out.int()) + 1 return out 修改为: def _get_length(self, logit, dim=-1): """ Greed decoder to obtain length from logit""" out = (logit.argmax(dim=-1) == self.charset.null_label) abn = out.any(dim) out = ((out.cumsum(dim) == 1) & out).max(dim)[1] out = out + 1 # additional end token out = torch.where(abn, out, out.new_tensor(logit.shape[1])) return out ____ 发件人: wu-yz @.> 发送时间: 2023年9月7日 20:55 收件人: FangShancheng/ABINet @.> 抄送: anthonyAndchen @.>; Comment @.> 主题: Re: [FangShancheng/ABINet] AssertionError: idx 0 != idx_new 2998 during testing. (Issue #96) No,I haven't resolved it. ― Reply to this email directly, view it on GitHub<#96 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOWBX26XAB4BMVCVY63VBF3XZG745ANCNFSM6AAAAAAZMZHR7A. You are receiving this because you commented.Message ID: @.***>

太感谢了!