lRomul / gramtion

Twitter bot for generating photo descriptions (alt text)
https://twitter.com/GramtionBot
MIT License
23 stars 2 forks source link

Feature Request: Separating OCR between bounded regions #1

Open jake-arkinstall opened 3 years ago

jake-arkinstall commented 3 years ago

I saw this tweet: https://twitter.com/GramtionBot/status/1394429729529270274?s=19

This is the first time I've seen this bot - and it's brilliant! Nice work.

I don't have experience with image recognition so this question may be naive.

I'm wondering if there's a way of using bounded box detection to distribute OCR results into contextual regions. If possible, this may have some interesting outcomes for various common image layouts (such as a comic or as a side-by-side comparison).

It may be possible to limit this process to images with specific properties to reduce false positives, such as predefined lists of image descriptions (e.g. This example, which outputs "Two signs that are sitting next to each other"), images with limited colour palettes (which may be comic strips).

The result of this would be seeing the current output:

Image 1 May show: Two signs that are sitting next to each other. Сontains text: working AT THE OFFICE AT HOME SITTING IN TRAFFIC WORKING WORKING GETTING LUNCH CHATTING WITH COWOR- / GETTING KERS/ COFFEE Irina Blok Tags: Rectangle, font, parallel, circle, diagram.

Transformed into:

Image 1 May show: Two signs that are sitting next to each other. 3 text regions detected Region 1 contains text: working Irina Blok Region 2 contains text: AT THE OFFICE SITTING IN TRAFFIC WORKING GETTING LUNCH CHATTING WITH COWOR- / GETTING KERS/ COFFEE Region 3 contains the text: AT HOME WORKING Tags: Rectangle, font, parallel, circle, diagram.

lRomul commented 3 years ago

An interesting idea! I think it will be really helpful especially for images with comics or side-by-side comparisons.

I am currently using Google Vision Ai for OCR. It returns text hierarchy with pages, blocks, and paragraphs. For example, for the tweet you mentioned result looks like this:

Screenshot from 2021-05-19 12-33-45

Imperfect page segmentation, but I can think of something with this. I will think of some other ways. For now, I'm trying to make a bot with ready-to-use parts :)

Thank you for the idea!