clovaai / deep-text-recognition-benchmark

Text recognition (optical character recognition) with deep learning methods, ICCV 2019
Apache License 2.0
3.77k stars 1.11k forks source link

Poor performance 😞 after training on custom data ℹ️ #392

Open amir2628 opened 1 year ago

amir2628 commented 1 year ago

Greetings! πŸ‘‹πŸΌ

I used EasyOCR repository ( their trainer.ipynb and not the deep-text-recognition-benchmark), to train my custom model. But since it is based on your repository, I think you might be able to help me. 😒

I hope the issue would not be lost in the void😒

So the dataset files where the collection of images and the label.csc files and did not use the create_lmdb_dataset.py to create the datasets. But as the title indicates, the performance that I saw during inference was not even close to the training and validation. 🀨

Have a good one!

amir2628 commented 1 year ago

turns out there is the following part in the recognition.py of EasyOCR:

    if device == 'cpu':
        state_dict = torch.load(model_path, map_location=device)
        new_state_dict = OrderedDict()
        for key, value in state_dict.items():
            new_key = key[7:]
            new_state_dict[new_key] = value
        model.load_state_dict(new_state_dict)

Which I am also on CPU. So I went and compared the dicts and it seems that they are the same:

        # Compare state_dict and new_state_dict
        differing_indices = []
        for idx, (key, state_value) in enumerate(state_dict.items()):
            new_value = new_state_dict.get(key, None)
            if new_value is not None and not torch.equal(state_value, new_value):
                differing_indices.append(idx)

        if len(differing_indices) == 0:
            print("The state_dict and new_state_dict are the same.")
        else:
            print("The state_dict and new_state_dict differ at the following indices:")
            print(differing_indices)

Output: The state_dict and new_state_dict are the same.

So I'm not sure what can cause this... :suspect:

Any ideas? πŸ’­

CharlyJazz commented 5 months ago

Did you make any fix foor this? I am facing same problem