herobd / formlabeling

form pairing project
5 stars 1 forks source link

how to make my tag data with the help of shortcut keys #1

Open xuyuhui666 opened 4 years ago

xuyuhui666 commented 4 years ago

Hi thanks for you code,I have train the model of detector and pairing on NAF_data, but i want to train the model on my data I follow the steps on readme, but I can't generate complete tag data. Can you tell me how to make your own tag data in detail? Could you give me a detailed introduction to create it Thanks very much!

herobd commented 4 years ago

Sure.

We first separated the images into groups based on their form type; one group for each type, the group being defined as the images in the same directory. We did this by first running a clustering algorithm on the images (this wasn't me so I can't tell you the details, other than it wasn't too complicated) and then manually sorting out the results. Having these groups was just to speed up labeling and is unnecessary, especially if you don't have a lot of repetition.

We then created a template for each group using labelKeys.py. The script walks through the groups directory and opens the first image in each group for labeling.

labelAll.py then walks through each image in each group. It places the template labeling on the image so you can align the template and edit the boxes. labelAll.py will also first create the template if one does not exits for a group. It opens the next unfinished image (allowing you to pick up where you left off).

labelAll.py has a number of parameters set at the top of the file you'll want to adjust:

If you want to skip doing groups and templates, I think the easy work around would be to put all your images in one group and make a blank/empty template. Then you should be able to run labelAll.py without any modifications.

Controls for labeling: I apologize that this is not very well done. It was made for my use and the few people I had helping me label the data.

All labeling is done with right clicks. Left clicks can then be used for the matplitlib navigation (zoom, pan, etc).

When you first begin editing an image's label, you will be asked to mark corner points. First it asks you to mark (right click) where the corners should be (in case of torn, bent corners). These corners are used to do an initial alignment with the template. It then asks for actual corner locations, you can skip this by simply pressing ENTER again.

The colored panel on the right shows both controls and the current mode (magenta box around one of the boxes).

If you are using a template, you'll see that the template will almost never perfectly align to the new image. You have some tools to adjust all the boxes at once to better align the template:

You can also use M mode to select a subset of boxes (clicking a box selects/deselects, clicking on no box deselects all). The above global manipulations will now apply only to the selected subset.

In you are in any of the first modes (text/label - Partitioned region) clicking and dragging (right button) will create a box. You can also select a box (click on it) and move it (click center, drag), or adjust it's sides (click side, drag). Holding SHIFT will allow the corners to be moved (boxes are stored as quadrilaterals). You can use 'D' to change a boxes type (press D and then the new type). however it can only switch from field type to field type or text type to text type. (text/label - enumeration are text types, field-row are field types)

You'll see a faint arrow on each box showing the read direction, you can rotate this with J for easier labeling of rotated text.

When a box is selected, creating a box of the opposite type, or clicking a box of the opposite type, will pair them together (green line). If you wish to pair boxes of the same type, the pair mode (F) will allow this (purple line).

The delete mode (G) will delete any pairing line or box you click on.

Ignore the horz link mode.

Some ease of use things: A: undo S: redo K: create copy of selected box (below). This is useful for repeated lines of text roughly the same size.

Finishing. When done, pressing ENTER saves the labels and opens the next image. If you work is interrupted, you can use ESC to save an incomplete labeling (will be opened again when running labelAll.py). You can also use F12 to close without saving, in case you made some big mistake.

Running labelAll.py with the C flag will prompt for a name and the present labeled images that need reviewed/checked (that haven't been checked under that name).

Other caveats: You'll notice it creates a templateX.json.lock file when your working. This was to allow multiple labelers (working on the same shared drive) preventing them from working on the same group at the same time. If the program crashes, it may not delete the lock file, in which case you'll need to manually remove it.

This can run a bit slow on images with lots of bounding boxes.

I'm actively working on this repo and make no guarantees about stuff breaking.

On Tue, Nov 12, 2019 at 5:50 AM xuyuhui666 notifications@github.com wrote:

Hi thanks for you code,I have train the model of detector and pairing on NAF_data, but i want to train the model on my data I follow the steps on readme, but I can't generate complete tag data. Can you tell me how to make your own tag data in detail? Could you give me a detailed introduction to create it Thanks very much!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/herobd/formlabeling/issues/1?email_source=notifications&email_token=AASBIAMBGT6GH2XGA2GHITTQTKRBJA5CNFSM4JMDBCEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HYV6H2A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASBIAIKHK44LTAJ45HVUBDQTKRBJANCNFSM4JMDBCEA .

surya89s commented 3 years ago

Hi,

I am not able to tag my data as it gives the following error on terminal once I open and mark the tags, can you please help with it.

self.selectedRect.set_xy(np.array([[0,0],[0.1,0],[0,0.1]]))

AttributeError: 'Control' object has no attribute 'selectedRect' Polygon4((0, 0) ...) Traceback (most recent call last): File "./formlabeling/labelKeys.py", line 110, in texts,fields,pairs,samePairs,horzLinks,groups,corners,actualCorners,complete,r,c = labelImage(os.path.join(directory,groupName,imageTemplate),texts,fields,pairs,samePairs,horzLinks,groups,None,page_corners,page_cornersActual) ValueError: too many values to unpack (expected 11)

herobd commented 3 years ago

I forgot to update labelKeys.py when I added transcriptions to the tool. Pull the latest and it should work.