Open Shidhani opened 2 years ago
Go to config.py
in easyocr folder, you have to change filename and md5sum of the detector model there.
@rkcosmos I got RuntimeError: Error(s) in loading state_dict for CRAFT: Missing key(s) in state_dict: "basenet.slice1.0.weight", "basenet.slice1.0.bias", "basenet.slice1.1.weight", ..
@gmuffiness
may be when train use the vgg backbone not the craft
@Shidhani Can you tell me how to train your own CRAFT model ? I need lightweight CRAFT model.
Go to
config.py
in easyocr folder, you have to change filename and md5sum of the detector model there.
How about url?
'craft' : {
'filename': 'craft_mlt_25k.pth',
'url': 'C:/Users/res/source/sheet_recognition/test_code/text/EasyOCR-1.6.2/trainer/craft/exp/custom_data_train/CRAFT_clr_amp_200.pth',
'md5sum': '50D96F50EDD083B92CC5CCFE9E9C0A5B0D476D8BCF4F4194DC75CC71DC6EEF44'
},
@rkcosmos I got
RuntimeError: Error(s) in loading state_dict for CRAFT: Missing key(s) in state_dict: "basenet.slice1.0.weight", "basenet.slice1.0.bias", "basenet.slice1.1.weight", ..
When you use train.py to train the CRAFT model, the .pth file will be dict_state of 3 item { "iter": train_step, "craft": craft.state_dict(), "optimizer": optimizer.state_dict(), } You only need craft.state_dict(), so
save_pth= torch.load(''path_to_pth_file)
model = save_pth["craft"]
torch.save(model , "craft_model_save_location")
@Shidhani Can you tell me how to train your own CRAFT model ? I need lightweight CRAFT model.
I also need guide on how to annotate images on specific format for craft
Go to
config.py
in easyocr folder, you have to change filename and md5sum of the detector model there.
Just in case someone does not feel like editing the source code of the environment, you can use this:
# for craft:
import easyocr
from easyocr.detection import get_detector, get_textbox
# or for dbnet
# from .detection_db import get_detector, get_textbox
reader = easyocr.Reader(
lang_list=["fr"],
detector=False,
)
reader.get_detector, reader.get_textbox = get_detector, get_textbox
reader.detector = reader.initDetector('path_to_the_filtered_model')
path_to_the_filtered_model
is for the model obtained using @kidserge-yong method (thank you btw!).
@FrankwaP hi! now that this issue is solved, I have an unrelated question I'm pretty new to programming and saw your answer, it amazed me. Did you read all the code before writing this or it was somehow a pattern that was present in other codes? btw, how should I read a long code like this one? thanks!
Hi @zahrasadat9 :-)
I don't remember exactly what I did, but here's the general process I use most of the time:
That way you skip all the "useless" code, which makes you save a lot of time depending on how deep in the code your problem is.
Here, I might have skipped the debugging part and just used "ctrl + left click" on the Reader
part of easyocr.Reader
, as it looks pretty straight forward.
Hope it helps! :-D
I trained the CRAFT detection model using a custom dataset and got the new weights as a .pth file. Now, how can I use this model with EasyOCR? I tried to pass the model directory to the
model_storage_directory
parameter but it doesn't seem to work.when I run the above script I get:
FileNotFoundError: Missing custom_example/1/model/craft_mlt_25k.pth and downloads disabled