Comments (11)
I am using the trainer of easyOCR , its inside the repository. And I also could not use a pre trained model, I ahve to create one form scratch
from deep-text-recognition-benchmark.
@charlyjazz-sprockets did you run this code ? i think in configuration file you can make option FR to True in order to finetune easyocr, and in this case it will use the pretrained model
from deep-text-recognition-benchmark.
I did not try! Let me know to talk about this repo!
from deep-text-recognition-benchmark.
Are you having weird validations scores? My validations score are too good, but when I use the model in easyocr the perfomance is bad
from deep-text-recognition-benchmark.
@CharlyJazz how did you train you model ? what code did you use ?
from deep-text-recognition-benchmark.
https://github.com/JaidedAI/EasyOCR/blob/master/trainer/train.py
![image](https://private-user-images.githubusercontent.com/12489333/341975822-fc337f4a-8b09-403a-964a-8875a3f4bd45.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE2OTk5OTksIm5iZiI6MTcyMTY5OTY5OSwicGF0aCI6Ii8xMjQ4OTMzMy8zNDE5NzU4MjItZmMzMzdmNGEtOGIwOS00MDNhLTk2NGEtODg3NWEzZjRiZDQ1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIzVDAxNTQ1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk2NmE2ZjU3MDYyOGE5MmRlZWU1YTY5NWIzNzIzNDkzZTczNDk1ZDA4MjQ4YTk1ZDFiMDU4MjA5YWQ2ZjVhMTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.gjpucBs4KdRcOpbd7K_Aym8NVBQKhpkzfb5XArW5tD4)
The validation is super good
But when I use the pth file the prediciton are super stupid bad
![image](https://private-user-images.githubusercontent.com/12489333/341975890-793438df-a392-4673-8297-238de9fe971e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE2OTk5OTksIm5iZiI6MTcyMTY5OTY5OSwicGF0aCI6Ii8xMjQ4OTMzMy8zNDE5NzU4OTAtNzkzNDM4ZGYtYTM5Mi00NjczLTgyOTctMjM4ZGU5ZmU5NzFlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIzVDAxNTQ1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU4NTQzZjkzZDUxMzhhYWFhMzY0MzI2NDNmMzQxNjU2NTc3ZjQ4YThmZTcwMTJmYTA1MTc3ZjBmZWNmOWJkODYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.r-gS5H66RPI0ex7jVeHXXbR1sMUAwB0xmsOqO4gvoTU)
from deep-text-recognition-benchmark.
what's the size of your dataset ? also can you please show me the code of how you used the model.pth to get text as output ? for me it gives me a matrix of numbers and when i convert it to text , it doesn't give the right output
from deep-text-recognition-benchmark.
Same problem for me, my dataset is 5M of images of synthetic music chords notation, is not big deal.. is super normal the use case
import os
from train import train
from model import Model
from PIL import Image
from utils import CTCLabelConverter, AttnLabelConverter
import torchvision.transforms as transforms
import pandas as pd
import torch
from ddevice import device
from dataset import NormalizePAD, ResizeNormalize, adjust_contrast_grey
import math
import numpy as np
from get_config import get_config
opt = get_config("config_files/en_chords_synth_config.yaml")
class PredictAlignCollate(object):
def __init__(self, imgH=32, imgW=100, keep_ratio_with_pad=False, contrast_adjust = 0.):
self.imgH = imgH
self.imgW = imgW
self.keep_ratio_with_pad = keep_ratio_with_pad
self.contrast_adjust = contrast_adjust
def __call__(self, image):
image = np.array(image)
if self.keep_ratio_with_pad: # same concept with 'Rosetta' paper
resized_max_w = self.imgW
input_channel = 1
transform = NormalizePAD((input_channel, self.imgH, resized_max_w))
h, w = image.shape[:2]
#### augmentation here - change contrast
if self.contrast_adjust > 0:
image = np.array(image.convert("L"))
image = adjust_contrast_grey(image, target = self.contrast_adjust)
image = Image.fromarray(image, 'L')
ratio = w / float(h)
if math.ceil(self.imgH * ratio) > self.imgW:
resized_w = self.imgW
else:
resized_w = math.ceil(self.imgH * ratio)
image = Image.fromarray(image, 'L')
resized_image = image.resize((resized_w, self.imgH), Image.BICUBIC)
import uuid
# resized_image.save(f"temp/{uuid.uuid4()}.jpg")
return resized_image
else:
transform = ResizeNormalize((self.imgW, self.imgH))
resized_image = transform(resized_image)
return resized_image
def predict(opt, image_path, model_path, text_for_pred):
""" Predict text from a single image """
image = Image.open(image_path).convert('L')
transform = transforms.Compose([
PredictAlignCollate(imgH=opt.imgH, imgW=opt.imgW, keep_ratio_with_pad=opt.PAD, contrast_adjust = opt.contrast_adjust),
transforms.ToTensor(),
transforms.Normalize((0.5,), (0.5,)),
])
image = transform(image).unsqueeze(0).to(device)
converter = CTCLabelConverter(opt.character)
opt.num_class = len(converter.character)
with torch.no_grad():
model = Model(opt)
model = torch.nn.DataParallel(model).to(device)
model.load_state_dict(torch.load(model_path, map_location=device))
model.eval()
preds = model(image, text_for_pred, is_train=False)
preds_size = torch.IntTensor([preds.size(1)])
_, preds_index = preds.max(2)
preds_index = preds_index.view(-1)
preds_str = converter.decode_greedy(preds_index.data, preds_size.data)
return preds_str[0]
root = os.path.dirname(os.path.abspath(__file__))
pathi = os.path.join(root, "dataset_structure", "validation_book")
# pathi = os.path.join(root, "jazz_book_dataset", "transformed")
# pathi = "/Users/carlosazuaje/Charlyjazz/Github/OCR-Chord-Notation/synthetic_dataset_chords_v2/batch_1"
files = os.listdir(pathi)
if __name__ == "__main__":
for filename in files:
if not filename.endswith('.jpg'):
continue
file_path = os.path.join(pathi, filename)
label = (file_path.split('/')[-1])
prediction = predict(
opt,
file_path,
"/Users/carlosazuaje/Charlyjazz/Github/OCR-Chord-Notation/saved_models/chords_5millions/saved_models_chords_5millions_iter_949999.pth",
label)
print(f'Label: {label} Prediction: {prediction}')
from deep-text-recognition-benchmark.
Update: after 1M iteration the model seems to have better predictions
from deep-text-recognition-benchmark.
let me know if u wanna share knowledge about this thing I have discord
from deep-text-recognition-benchmark.
i'll try to inscrease number of iterations too , and i contacted you on linkedIn
from deep-text-recognition-benchmark.
Related Issues (20)
- how i convert .zip files to .pth?
- AssertionError: datasets should not be an empty iterable HOT 1
- CUDA error, while training Attn as prediction
- Cannot train model for upper case characters
- I encountered a bug when executing the following command in the deep-text-recognition-benchmark repository HOT 1
- [Question] Configuring the dataset for custom training HOT 2
- custom dataset Calculated padded input size per channel: (1 x 22). Kernel size: (2 x 2)
- Check the wrong prediction data
- Can it be used to extract texts from an entire page ?
- Adding new characters causes error HOT 2
- [Training] lmdb.Error: The paging file is too small
- ImportError: cannot import name '_accumulate' from 'torch._utils' HOT 1
- I am getting AssertionError: datasets should not be an empty iterable HOT 1
- Getting RuntimeError: Error(s) in loading state_dict for DataParallel: Missing key(s) in state_dict: HOT 2
- Training TPS-ResNet-BiLSTM-Attn.pth model on my own custom dataset to detect text and numbers from pictures of shipping container ids
- PermissionError: [Errno 13] Permission denied: 'D:/test6Training/labels'
- how can i train model from scratch with new language like Khmer language ?
- How to train using the original lmdb dataset from this repo but also using a custom dataset?
- Can't test a pretrained model HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep-text-recognition-benchmark.