mindee / doctr

docTR (Document Text Recognition) - a seamless, high-performing & accessible library for OCR-related tasks powered by Deep Learning.
https://mindee.github.io/doctr/
Apache License 2.0
3.54k stars 414 forks source link

Support for Handwritten text #1049

Open harindercnvrg opened 1 year ago

harindercnvrg commented 1 year ago

🚀 The feature

Addition of new / Fine Tuning of existing models to support OCR for Handwritten Text. As a first step we can start with detection/prediction models that work specifically for Handwritten Text and down the line we can launch a model that works well for both Handwritten and Typed text.

Motivation, pitch

Thousands of forms, documents and notes are scanned stored in archives but are not accessible by search. This can enable digitising such documents that contain handwritten text and enable search on them.

Alternatives

No response

Additional context

No response

frgfm commented 1 year ago

Hi @harindercnvrg :wave:

That's indeed a long term goal for us! I would suggest dissecting the problem as follows:

harindercnvrg commented 1 year ago

@frgfm thank you for detailing the steps. Also, I was wondering if we cannot work with a model that is able to work with both digital and handwritten text, would it be possible to include an extra layer of classification and use separate models for handwritten and digital text based on the classification?

harindercnvrg commented 1 year ago

@frgfm also for reference CRAFT + TrOCR The model works fine for handwritten and digital text. It was fine tuned on the IAM dataset.

frgfm commented 1 year ago

Also, I was wondering if we cannot work with a model that is able to work with both digital and handwritten text

Yes of course, but I suggested handwritten only first because if that first step doesn't work, it's extremely unlikely than handling both will work :sweat_smile:

@frgfm also for reference CRAFT + TrOCR The model works fine for handwritten and digital text. It was fine tuned on the IAM dataset.

Thanks a lot for the heads up :pray: I added those to the wishlist of new model implementation on docTR (#1007)

felixdittrich92 commented 1 year ago

@frgfm i have to disagree with both model additions (CRAFT is really not a performance beast (with VGG backbone)) and let's don't talk about TrOCR ... this is a beast from Microsoft to show how big a model can be to perform OCR :laughing: No back to the facts .. TrOCR uses Roberta as Decoder we don't want to integrate some big LM (really) and i think we are also not able to train it from scratch (would only be possible if we take hf transformers as dependency). Another point is that TrOCR is also on an actual GPU really slow and performs not on char level .. it needs sentences

ParSeq will be a good fit also for handwritten (where it is solved in the decoding strategy without using any big LM)

frgfm commented 1 year ago

Yeah you're right! We'll have to filter the models once we have gathered all requests (& compare them)

tobiascornille commented 1 year ago

What is the status on this? If I understand correctly, some handwriting datasets are already added (#587), so is this issue still relevant?

felixdittrich92 commented 1 year ago

Hi @tobiascornille 👋 ,

Yes it is still not solved, because we have some architectures which should be able to perform well for handwritten (sar, master, vitstr) but a lack of training data. Imgur5k contains handwritten samples but is to small in overall so it could be only used for validation.

tobiascornille commented 1 year ago

@felixdittrich92 Good to know. I will be trying to collect some handwriting data in the coming months, so I might be able to contribute to this then.

One more question: are the current models already trained on Imgur5k? This might actually be problematic for some use cases, since the dataset is licensed under CC BY-NC 4.0 (see https://github.com/facebookresearch/IMGUR5K-Handwriting-Dataset/blob/main/LICENSE).

tobiascornille commented 1 year ago

@felixdittrich92 Have you considered adding the IIIT-HWS dataset? It's a synthetic dataset, but considering it 9M words and ~750 fonts, it seems promising. The first author is also the same guy behind IMGUR5k and TextStyleBrush, @kris314

felixdittrich92 commented 1 year ago

@tobiascornille the current pretrained models are trained on an custom dataset ( internal mindee data) :)

About the dataset request (looks like MJSynth but only with fonts which looks like handwritten !?): I didn't see any license in the repository .. if it's freely available and we could add it in a similar way to MJSynth in doctr then we're welcome to do that. Would you be interested to work on it ? :)

tobiascornille commented 1 year ago

@felixdittrich92 I've opened an issue (https://github.com/kris314/hwnet/issues/7). Let's see if the author responds.

And yes, this would be very relevant for a project I'm working on. It's a side project, so I cannot commit on any timeline, but I'd like to collect some data and fine-tune a handwriting model this summer.

ffalkenberg commented 11 months ago

@tobiascornille any progress on the fine-tuned handwriting model? :v:

tobiascornille commented 11 months ago

@tobiascornille any progress on the fine-tuned handwriting model? ✌️

Hey @felixdittrich92 , I'm afraid not. For the side project I ended up using a cloud provider because it was faster :/ Will post again if anything changes.

ArsalanYounus007 commented 7 months ago

Hi,

I was going to start Handwriting training now and thought to ask if someone made any progress on this. It would be really helpful.

Thank you.

felixdittrich92 commented 6 months ago

@odulcy-mindee Do you have internal datasets we could use to train one detection and one recognition model for each backend ? :) (pinned to 2.0.0 so no stress :sweat_smile:)

sh1man999 commented 4 months ago

no support for handwritten text? Can someone tell me what project is currently relevant in this direction?