Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add center loss cod and cfg #4165

Merged

Conversation

littletomatodonkey
Copy link
Collaborator

No description provided.

@paddle-bot-old
Copy link

Thanks for your contribution!

epoch_num: 800
log_smooth_window: 20
print_batch_step: 10
save_model_dir: ./output/rec_mobile_pp-OCRv2_center_loss
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议将center改成enhanced_ctc, center并不准确。 arxiv论文上也是这么对外宣传的

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的, 已修改

infer_mode: false
use_space_char: true
distributed: true
save_res_path: ./output/rec/predicts_mobile_pp-OCRv2_center_loss.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

algorithm: CRNN
Transform:
Backbone:
name: MobileNetV1Enhance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是已经确定叫LCNet了,如果确定了,可以直接写LCNet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块由于pretrain已经开源,目前修改风险可能比较高,暂时感觉修改不太合适

num_classes: 6625
feat_dim: 96
init_center: false
center_file_path:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提供一个默认路径吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,已提供


feats_reshape = paddle.reshape(
features, [-1, features.shape[-1]]).astype("float64")
label = paddle.argmax(predicts, axis=2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的标签,是不是应该使用batch也就是gt进行计算,predicts是预测的标签?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OCR识别里面,是没有显式的对齐标签的;所以训练的时候gt没法拿来使用

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,用gt是没有对齐的有明显的问题,但是会不会存在用predicts因为不是正确的标签,计算出来的centerloss引入比较大的偏差,从而导致学习出的“center”质量不是很高?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果center不做初始化的话,确实会影响效果;PPOCR-V2的方案,会先基于单纯的ctcloss,训练一个模型;然后基于训练数据提取center来做初始化。 另外,centerloss的权重一般也不会设置得很大

@littletomatodonkey littletomatodonkey merged commit 27b6346 into PaddlePaddle:dygraph Sep 29, 2021
@littletomatodonkey littletomatodonkey deleted the dyg/add_center_loss branch November 13, 2021 03:29
@Zhang-O
Copy link

Zhang-O commented Dec 4, 2021

https://github.com/PaddlePaddle/PaddleOCR/blame/dygraph/ppocr/losses/ace_loss.py#L25-L33
ace loss 的 crossentropyLoss 初始化有误导性,
ignore_index (int) – 指定一个忽略的标签值,此标签值不参与计算,负值表示无需忽略任何标签值。仅在soft_label=False时有效。 默认值为-100
代码里面设置ignore_index=0 其实是无效的,建议删除这个参数的设置

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants