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

在 Loss 配置中增加 out_channel, 方便自定义数据训练 #9439

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/rec/rec_d28_can.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Architecture:

Loss:
name: CANLoss
out_channel: 111

PostProcess:
name: CANLabelDecode
Expand Down
4 changes: 2 additions & 2 deletions ppocr/losses/rec_can_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class CANLoss(nn.Layer):
counting_loss: counting loss of every symbol
'''

def __init__(self):
def __init__(self, out_channel=111):
super(CANLoss, self).__init__()

self.use_label_mask = False
self.out_channel = 111
self.out_channel = out_channel
self.cross = nn.CrossEntropyLoss(
reduction='none') if self.use_label_mask else nn.CrossEntropyLoss()
self.counting_loss = nn.SmoothL1Loss(reduction='mean')
Expand Down