argman / EAST

A tensorflow implementation of EAST text detector
GNU General Public License v3.0
3.01k stars 1.05k forks source link

how to annotate custom data & train it on EAST? #311

Open eliyaz-kl opened 4 years ago

eliyaz-kl commented 4 years ago

Im looking for any annotation tool which gives the output as east dataset format, so that i can train my custom data. and make a model which should detect only the trained lables.

My scope is to extract particular text (Key-Value) from scanned image documents which will be having same structure.. for example, from any invoice i need to extract the name of the person or name with total amount for all the document..

as tesseract or tensorflow didn't help me a lot, im trying with EAST.. pls guide me to archive this scope.. your help will be much appreciated

sulfasTor commented 4 years ago

You can try LabelMe (https://github.com/CSAILVision/LabelMeAnnotationTool) Labelme is a annotation used to label images. It can be used to label text. Each labeled image will give a XML but you can transform it easily to the icdar training data format. Although I can share you the script I used if you are stuck.

N.B. Label Me from MIT is slow when labeling a lot of bounding boxes. I did some improvements and the lag is much less (https://github.com/sulfasTor/LabelMeAnnotationTool)

eliyaz-kl commented 4 years ago

You can try LabelMe (https://github.com/CSAILVision/LabelMeAnnotationTool) Labelme is a annotation used to label images. It can be used to label text. Each labeled image will give a XML but you can transform it easily to the icdar training data format. Although I can share you the script I used if you are stuck.

N.B. Label Me from MIT is slow when labeling a lot of bounding boxes. I did some improvements and the lag is much less (https://github.com/sulfasTor/LabelMeAnnotationTool)

i have annotated the new images to yolo format using lableme but when i tried google, i could not find yolo to EAST conversion code. can you pls share the link.. @sulfasTor

sulfasTor commented 4 years ago

From @alexpm94:

Will give a txt file as this: https://github.com/argman/EAST/blob/master/training_samples/img_1.txt

import xml.etree.ElementTree as ET
import glob

gt_path = r"path/to/dir"
paths = glob.glob(gt_path +'/*.xml')

for filename in paths:
    tree = ET.parse(filename)
    root = tree.getroot()
    boxes = []

    for object_tree in root.findall('object'):
        box = []
        obj_text = object_tree.find('name').text
        if object_tree.find('deleted').text == '1':
            deleted = True 
        else: 
            deleted=False
        if obj_text == None or deleted:
            continue

        polygon = object_tree.find('polygon')

        for pt in polygon.findall('pt'):
            x = pt.find('x').text
            y = pt.find('y').text
            box.append(x)
            box.append(y)
        box.append(obj_text)
        box_str = ','.join(box)+'\n'
        boxes.append(box_str)
    txt_fn = filename[:-3]+'txt'
    with open(txt_fn, 'w') as f:
        f.writelines(boxes)        
taanis98 commented 4 years ago

@sulfasTor I am still having difficulty converting from XML to ICDAR format, what is the script that you have used.

payal211 commented 2 years ago

@eliyaz-kl , @sulfasTor, @taanis98

I am trying to annotate custom dataset in ICDAR2015 format, I tried the above script with no luck. Can you please share one sampled .xml file and corresponding converted .txt file along with the conversion script? or is there any other way to convert Yolo format .xml or .txt into ICDAR Format? If yes, then please share that.

Thanks in advance.