LBH1024 / CAN

When Counting Meets HMER: Counting-Aware Network for Handwritten Mathematical Expression Recognition (ECCV’2022 Poster).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

在HME100K数据集上ExpRate与论文中相差5%

Howrunz opened this issue · comments

您好,首先感谢您做出了一项很有启发性的工作并开源了代码。

在运行代码过程中我遇到了两个问题,如下:

问题1:在HME100K数据集上,训练90个epoch,测试集的ExpRate最高为53.58,最高点出现于epoch90。之后重新开始,训练240个epoch,测试集的ExpRate最高为62.03,最高点出现于epoch198,与论文中汇报的67.31相差5.28。想问一下是否我在复现哪个环节时没有与您保持一致?如何达到您在论文中汇报的结果?(240个epoch的实验忘了调整init_epoch,实际训练了215个epoch)

细节:

  1. 我注意到您在#19中提供了在HME100K数据集上训练的主要参数,我使用的主要参数如下,其它参数与config.yaml一致:
seed: 20211024

epochs: 90
batch_size: 8
workers: 8
train_parts: 3
valid_parts: 1
valid_start: 0
save_start: 0

optimizer: Adadelta
lr: 1
lr_decay: cosine
step_ratio: 10
step_decay: 5
eps: 1e-6
weight_decay: 2e-5
beta: 0.9

counting_decoder:
  in_channel: 684
  out_channel: 247
  1. 训练时未对图片做Resize操作;
  2. 训练所使用的GPU为Nvidia Tesla V100 (32GB),单张。
  3. Train loss:
    train_loss
  4. Train ExpRate:
    epoch_train_ExpRate
  5. Eval loss:
    eval_loss
  6. Eval ExpRate:
    epoch_eval_ExpRate

问题2:论文中描述HME100K共包含249种符号(包括‘eos’和‘sos’),但我在去重后只得到247种符号(包括‘eos’和‘sos’),不清楚丢失了哪两种。

以上,感谢!

你好,官方放出来的HME100K数据集是没处理过的,推荐在保持图像宽高比的情况下将图像的高resize为120。符号种类数可以设置为247,不影响结果。

好的,感谢,我去试一下

@LBH1024 请与我分享 HME100K 数据集,因为我无法下载它。我的邮箱:pinkal21300@iiitnr.edu.in
太感谢了。

@LBH1024 太感谢了。

你好,我想请问一下,你的字典大小为247,也就需要把符号种类改成247。我这个数据集字典大小为558,我将符号种类改成558之后,得到了KeyError: '('这样的报错,你知道是什么原因吗?

你好,我想请问一下,你的字典大小为247,也就需要把符号种类改成247。我这个数据集字典大小为558,我将符号种类改成558之后,得到了KeyError: '('这样的报错,你知道是什么原因吗?

你好,我认为是你的word_dict.txt文件中没有(符号。

我检查了我的word_dict.txt文件里是有(这个符号的,我想请问一下你的word_dict.txt文件的格式是这样吗?
token 1
token 2
token 3
......

我检查了我的word_dict.txt文件里是有(这个符号的,我想请问一下你的word_dict.txt文件的格式是这样吗? token 1 token 2 token 3 ......

是的,那可能的原因就有:中英文混淆以及文件路径指向错误。

keyError出现的原因是字典中没有对应的键,因此建议从此处查找原因。

作者的代码实现为:

class Words:
    def __init__(self, words_path):
        with open(words_path) as f:
            words = f.readlines()
            print(f'共 {len(words)} 类符号。')
        self.words_dict = {words[i].strip(): i for i in range(len(words))}  # 加断点
        self.words_index_dict = {i: words[i].strip() for i in range(len(words))}

    def __len__(self):
        return len(self.words_dict)

    def encode(self, labels):
        label_index = [self.words_dict[item] for item in labels]  # 加断点
        return label_index

可以在# 加断点注释处debug。

Hi @Howrunz, were you able to reproduce the results in the paper on the HME100K dataset after resizing the images to a height of 120? Did you perform any other pre-processing steps like the ones I've mentioned here?
Thanks.

我检查了我的word_dict.txt文件里是有(这个符号的,我想请问一下你的word_dict.txt文件的格式是这样吗? token 1 token 2 token 3 ......

是的,那可能的原因就有:中英文混淆以及文件路径指向错误。

keyError出现的原因是字典中没有对应的键,因此建议从此处查找原因。

作者的代码实现为:

class Words:
    def __init__(self, words_path):
        with open(words_path) as f:
            words = f.readlines()
            print(f'共 {len(words)} 类符号。')
        self.words_dict = {words[i].strip(): i for i in range(len(words))}  # 加断点
        self.words_index_dict = {i: words[i].strip() for i in range(len(words))}

    def __len__(self):
        return len(self.words_dict)

    def encode(self, labels):
        label_index = [self.words_dict[item] for item in labels]  # 加断点
        return label_index

可以在# 加断点注释处debug。

谢谢你的建议,我修改了word_dict.txt文件中符号排列的格式,这个问题就迎刃而解了。但是又遇到了新的问题,我怀疑是我的.pkl文件出现了问题,我想请问一下你使用HME100K这个数据集,生成.pkl文件的时候是如何生成的呢?图片需要进行怎样的预处理呢?

Hi @Howrunz, were you able to reproduce the results in the paper on the HME100K dataset after resizing the images to a height of 120? Did you perform any other pre-processing steps like the ones I've mentioned here? Thanks.

Hi @mrkruk5 . By adjusting the height to 120 and keeping the aspect ratio, the reproduced ExpRate reached 67.66%. The input image is converted to grayscale, otherwise consistent with the author's code.

谢谢你的建议,我修改了word_dict.txt文件中符号排列的格式,这个问题就迎刃而解了。但是又遇到了新的问题,我怀疑是我的.pkl文件出现了问题,我想请问一下你使用HME100K这个数据集,生成.pkl文件的时候是如何生成的呢?图片需要进行怎样的预处理呢?

  1. .pkl文件实际为一个字典,键为图像名,值为图像像素矩阵。
  2. 预处理就是将图像转为灰度图,在保持宽高比的基础上缩放高度到120。

谢谢你的建议,我修改了word_dict.txt文件中符号排列的格式,这个问题就迎刃而解了。但是又遇到了新的问题,我怀疑是我的.pkl文件出现了问题,我想请问一下你使用HME100K这个数据集,生成.pkl文件的时候是如何生成的呢?图片需要进行怎样的预处理呢?

  1. .pkl文件实际为一个字典,键为图像名,值为图像像素矩阵。
  2. 预处理就是将图像转为灰度图,在保持宽高比的基础上缩放高度到120。

[[[很抱歉又来打扰您,我将图像转为灰度图,在保持宽高比的基础上缩放高度到120的方式对图像进行了预处理,在使用WAP这里的方法生成了pkl文件。然后我将train_image_path和train_label_path修改了之后,代码出现下面这个错误。

image

不知道您方便吗?如果方便的话可以留下您的邮箱,以便我们更好的交流。

Hi @Howrunz, were you able to reproduce the results in the paper on the HME100K dataset after resizing the images to a height of 120? Did you perform any other pre-processing steps like the ones I've mentioned here? Thanks.

Hi @mrkruk5 . By adjusting the height to 120 and keeping the aspect ratio, the reproduced ExpRate reached 67.66%. The input image is converted to grayscale, otherwise consistent with the author's code.

Hi @Howrunz, thank you for confirming the results and preprocessing steps. Did you pad the lower right corner of the images to the max batch width for batch processing during training on the HME100K dataset? Do you also have results of the model trained on HME100K tested on the CROHME datasets?

Hi @Howrunz, thank you for confirming the results and preprocessing steps. Did you pad the lower right corner of the images to the max batch width for batch processing during training on the HME100K dataset? Do you also have results of the model trained on HME100K tested on the CROHME datasets?

  1. That's right, the maximum width of each batch is not necessarily the same, see the author's code here for details.
  2. Sorry, I haven't had time to do it yet.

[[[很抱歉又来打扰您,我将图像转为灰度图,在保持宽高比的基础上缩放高度到120的方式对图像进行了预处理,在使用WAP这里的方法生成了pkl文件。然后我将train_image_path和train_label_path修改了之后,代码出现下面这个错误。

image

不知道您方便吗?如果方便的话可以留下您的邮箱,以便我们更好的交流。

抱歉不行,我只能说作者的代码没有问题。

[[[很抱歉又来打扰您,我将图像转为灰度图,在保持宽高比的基础上缩放高度到120的方式对图像进行了预处理,在使用WAP这里的方法生成了pkl文件。然后我将train_image_path和train_label_path修改了之后,代码出现下面这个错误。
image
不知道您方便吗?如果方便的话可以留下您的邮箱,以便我们更好的交流。

抱歉不行,我只能说作者的代码没有问题。

好的,感谢你的回复。