- python = 3.8.0
- to install requirments run
pip install -r requirments.txt
to inference using CM you need a .ts
detectron model and config file
in json format
let's start with the config file
Key Name | Description | Data type | Example | TIP |
---|---|---|---|---|
number_of_fields | contain the number of fields expected from the model | int | 20 | - |
side_labels | if we have ID DL and BR each one of them we consider as a side, thus we put the labels represent this sides, if we didn't find any side label while inference the inference will stop | list contain int | [ 0, 10] | for system without Side labels, put all the models label in this Key, so that if the model found any field, process continue |
non_label | a field that we consider as none, if we found this field and the confidance of this field larger than the side label field found, the process will stop and check the next image | int | 23 | if you don't have this field but it -1 |
fields_name | contain the name for each field, so we can save the result with this specified names | dictionary key[number]:value[string] | "0": "ID","1": "ID-Number", | - |
side_labels_fields | for each side we have some fields for this side only, if we found another field doesn't blong to this side we ignore this field | dictionary key[number]:value[list of ints] | "0": [1,2,3],"4":[5,6] | if you don't have a side, you can put all fields inside all fields, example : "0":[0,1,2,3,4,5],"1":[0,1,2,3,4,5],..."5":[0,1,2,3,4,5] |
rotation_line | fields we consider reprsentative for the card rotation, for example if we have in the ID first name, ID number; we expect the first name field to have y min smaller than the id number, so in this Key we put all fields we expect to find first for each side from top to bottom, with respect to the order in this list | dictionary key[number]:value[list of ints] | "0": [2,3,4] | if you don't have a side, you can put all fields inside all fields, example : "0":[0,1,2,3,4,5],"1":[0,1,2,3,4,5],..."5":[0,1,2,3,4,5] |
flip_lines | fields we consider reprsentative for the card flip, for example we expect the ID first name to be near the right corner of the id card, we expect the personal image to be near the left side of the card, so we put this fields in this key, with respect to the order in this list | dictionary key[number]:value[list of ints] | "0": [5,4,3,2 ], | if you don't have a side, you can put all fields inside all fields, example : "0":[0,1,2,3,4,5],"1":[0,1,2,3,4,5],..."5":[0,1,2,3,4,5] |
flip_lines_bool | for the flipping lines, we need to know which side we expect this field to be close to (right or left ), false mean we epxect it to be close to the right, true mean we expect it to be close to the left side | dictionary key[number]:value[boolean] | "0": false, "1": false,"2": true, | - |
target_list | for each side we may have somefields we don't want to save in the final output, thus in this Key any field found will be saved in the output otherwise we will ignore saving it in the output | dictionary key[number]:value[list of ints] | "0": [ 1,2 ],"5":[6,7,] | if you don't have a side, you can put all fields inside all fields, example : "0":[0,1,2,3,4,5],"1":[0,1,2,3,4,5],..."5":[0,1,2,3,4,5] |
template_list | for some sides we have a template for fields inside this side, so we put the expected location in the warped image in this Key, if we didn't find the target field, we search for it in this template | dictionary key[number]:value[list of ints] | "1" :[185.0, 115.0, 314.0, 131.0] ,"2" :[115.0, 180.0, 295.0, 205.0],... "x":[x1,y1,x2,y2] | - |
template_list_bool | boolean for template list, if we this field in the target list, put we don't have template for this field, we can put the value = false which mean ignore template for this field, true means we have a template for this field | dictionary key[number]:value[boolean] | "0": false, "1": false,"2": true, | - |
multi_label_instances | if we have a field that we found more than 1 time, we have 2 options, take only one with the heights confidance, take the two of them, to save the two of them expected value is true, to take high confidance expected value is false | boolean | true | note that effect on the rotation and fliping, if you expect to find this field more than one time, don't use it in flip or rotation except they will have the same idea of top bottom view |
side_system | if we have a side label system or no, side label system is like ID, DL, BR and so on, non side system is like first name, family name and the fields directly inside the image or in IDB, this key represent one thing, for rotation and flipping we consider the fields to the side field we found for example the boundary of the ID, with no label system we consider the fields to the whole image itself | boolean | true | this field is most likely be used with rotation and flipping |
input_size_min_max | the expected model input shape | list contain int | [300,1024] | - |
trans_height_trans_width | the warpped card dimensions height then width for each side label | dictionary key[number]:value[list of ints] | "0": [ 300,500],"10":[300,500] | - |
out_border_threshold | when we have a side label system, we expect the side label fields to be inside the label field, example: the first name is inside the id boundary box, but sometimes it can be outside the boundary of the label field, so we define a threshold if the sidelabel field is outside the label field by value more than this threshold in left or top or right or bottom we ignore this field | dictionary key[number]:value[list of ints] | "0": [ 10,10,10,10], | this field is useless if we have side label system as false |
field_height_width_threshold | we define some threshold for each field, the height and the width for this field, if the field is smaller than this threshold we ignore this field | dictionary key[number]:value[list of ints] | "0": [ 5,5], | if we don't care just put this value as -1 |
card_horz_vert_type | we consider the rotation on the cards 0 or 90 based on the label side width and height, to make sure that the CM is working with Horz or Vert side labels, we can set this Key to be 1 if we consider the default that the width > height and -1 if we consider that the default height > width | dictionary key[number]:int | "0": -1,"10": 1 | - |