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

Recognizing custom model result is bad compared to text predicted during training for Greek Language #1256

Open
vamshi-1611 opened this issue May 16, 2024 · 0 comments

Comments

@vamshi-1611
Copy link

vamshi-1611 commented May 16, 2024

Hello All

I am trying to train custom model training for Greek Language

please find my config.yaml file

number: '0123456789'
symbol: "!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ €"
lang_char: 'ΨτκφΦηΔΟΖΚθΘβδΧαωΞουλΠψςνΡγρΥΜεμΤΛΙσξΗΩΒΓΣΑιχΕπζΝ'
experiment_name: 'greek'
train_data: './all_data'
valid_data: './all_data/Greek_val'
manualSeed: 1111
workers: 6
batch_size: 32 #32
num_iter: 300000
valInterval: 100
saved_model: '' #'saved_models/en_filtered/iter_300000.pth'
FT: False
optim: False # default is Adadelta
lr: 1.0
beta1: 0.9
rho: 0.95
eps: 0.00000001
grad_clip: 5
#Data processing
select_data: 'Greek_train' # this is dataset folder in train_data
batch_ratio: '1'
total_data_usage_ratio: 1.0
batch_max_length: 128
imgH: 64
imgW: 600
rgb: False
contrast_adjust: False
sensitive: True
PAD: True
contrast_adjust: 0.0
data_filtering_off: False

Model Architecture

Transformation: 'None'
FeatureExtraction: 'VGG'
SequenceModeling: 'BiLSTM'
Prediction: 'CTC'
num_fiducial: 20
input_channel: 1
output_channel: 256
hidden_size: 256
decode: 'greedy'
new_prediction: True
freeze_FeatureFxtraction: False
freeze_SequenceModeling: False

Generated opt.txt file is below

image

Model Architecture is below

Filtering the images containing characters which are not in opt.character
Filtering the images whose label is longer than opt.batch_max_length

dataset_root: ./all_data
opt.select_data: ['Greek_train']
opt.batch_ratio: ['1']

dataset_root: ./all_data dataset: Greek_train
./all_data/Greek_train
sub-directory: /Greek_train num samples: 295
num total samples of Greek_train: 295 x 1.0 (total_data_usage_ratio) = 295
num samples of Greek_train per batch: 32 x 1.0 (batch_ratio) = 32

Total_batch_size: 32 = 32

dataset_root: ./all_data/Greek_val dataset: /
./all_data/Greek_val/
sub-directory: /. num samples: 264

No Transformation module specified
model input parameters 64 600 20 1 256 256 94 128 None VGG BiLSTM CTC
Model:
DataParallel(
(module): Model(
(FeatureExtraction): VGG_FeatureExtractor(
(ConvNet): Sequential(
(0): Conv2d(1, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(1): ReLU(inplace=True)
(2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(3): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(4): ReLU(inplace=True)
(5): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(6): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(7): ReLU(inplace=True)
(8): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(9): ReLU(inplace=True)
(10): MaxPool2d(kernel_size=(2, 1), stride=(2, 1), padding=0, dilation=1, ceil_mode=False)
(11): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(12): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(13): ReLU(inplace=True)
(14): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(15): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(16): ReLU(inplace=True)
(17): MaxPool2d(kernel_size=(2, 1), stride=(2, 1), padding=0, dilation=1, ceil_mode=False)
(18): Conv2d(256, 256, kernel_size=(2, 2), stride=(1, 1))
(19): ReLU(inplace=True)
)
)
(AdaptiveAvgPool): AdaptiveAvgPool2d(output_size=(None, 1))
(SequenceModeling): Sequential(
(0): BidirectionalLSTM(
(rnn): LSTM(256, 256, batch_first=True, bidirectional=True)
(linear): Linear(in_features=512, out_features=256, bias=True)
)
(1): BidirectionalLSTM(
(rnn): LSTM(256, 256, batch_first=True, bidirectional=True)
(linear): Linear(in_features=512, out_features=256, bias=True)
)
)
(Prediction): Linear(in_features=256, out_features=94, bias=True)
)
)
Modules, Parameters
module.FeatureExtraction.ConvNet.0.weight 288
module.FeatureExtraction.ConvNet.0.bias 32
module.FeatureExtraction.ConvNet.3.weight 18432
module.FeatureExtraction.ConvNet.3.bias 64
module.FeatureExtraction.ConvNet.6.weight 73728
module.FeatureExtraction.ConvNet.6.bias 128
module.FeatureExtraction.ConvNet.8.weight 147456
module.FeatureExtraction.ConvNet.8.bias 128
module.FeatureExtraction.ConvNet.11.weight 294912
module.FeatureExtraction.ConvNet.12.weight 256
module.FeatureExtraction.ConvNet.12.bias 256
module.FeatureExtraction.ConvNet.14.weight 589824
module.FeatureExtraction.ConvNet.15.weight 256
module.FeatureExtraction.ConvNet.15.bias 256
module.FeatureExtraction.ConvNet.18.weight 262144
module.FeatureExtraction.ConvNet.18.bias 256
module.SequenceModeling.0.rnn.weight_ih_l0 262144
module.SequenceModeling.0.rnn.weight_hh_l0 262144
module.SequenceModeling.0.rnn.bias_ih_l0 1024
module.SequenceModeling.0.rnn.bias_hh_l0 1024
module.SequenceModeling.0.rnn.weight_ih_l0_reverse 262144
module.SequenceModeling.0.rnn.weight_hh_l0_reverse 262144
module.SequenceModeling.0.rnn.bias_ih_l0_reverse 1024
module.SequenceModeling.0.rnn.bias_hh_l0_reverse 1024
module.SequenceModeling.0.linear.weight 131072
module.SequenceModeling.0.linear.bias 256
module.SequenceModeling.1.rnn.weight_ih_l0 262144
module.SequenceModeling.1.rnn.weight_hh_l0 262144
module.SequenceModeling.1.rnn.bias_ih_l0 1024
module.SequenceModeling.1.rnn.bias_hh_l0 1024
module.SequenceModeling.1.rnn.weight_ih_l0_reverse 262144
module.SequenceModeling.1.rnn.weight_hh_l0_reverse 262144
module.SequenceModeling.1.rnn.bias_ih_l0_reverse 1024
module.SequenceModeling.1.rnn.bias_hh_l0_reverse 1024
module.SequenceModeling.1.linear.weight 131072
module.SequenceModeling.1.linear.bias 256
module.Prediction.weight 24064
module.Prediction.bias 94
Total Trainable Params: 3780574
Trainable params num : 3780574
Optimizer:
Adadelta (
Parameter Group 0
eps: 1e-08
foreach: None
lr: 1.0
maximize: False
rho: 0.95
weight_decay: 0
)

image

As per https://github.com/JaidedAI/EasyOCR/blob/master/custom_model.md copied best _accuracy.pth file and renamed as greek.pth as per custom_example.zip renamed custom_example.py to greek.py and modified greek.yaml as below
image

moved all greek.py and greek.yaml file to /root/.EasyOCR/user_network/ and greek.pth file to /root/.EasyOCR/model
this character list i have added from opt.txt file character parameter

created greek_char.txt file in easyocr/character (python dist-packages) as below

Ψ
τ
κ
φ
Φ
η
Δ
Ο
Ζ
Κ
θ
Θ
β
δ
Χ
α
ω
Ξ
ο
υ
λ
Π
ψ
ς
ν
Ρ
γ
ρ
Υ
Μ
ε
μ
Τ
Λ
Ι
σ
ξ
Η
Ω
Β
Γ
Σ
Α
ι
χ
Ε
π
ζ
Ν

Please find my code for using custom model

import easyocr
reader=easyocr.Reader(lang_list=['greek'],recog_network='greek')
result=reader.readtext('0.png',detail=0)
for x in result :
print(x)

0.png is Εμφ and my output is NH

Please let me know how to fix this issue

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

No branches or pull requests

1 participant