lowercaseonly commited on
Commit
6d0530f
1 Parent(s): da0365c

Added README Content

Browse files
Files changed (1) hide show
  1. README.md +296 -1
README.md CHANGED
@@ -9,4 +9,299 @@ task_categories:
9
  language:
10
  - en
11
  - de
12
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  language:
10
  - en
11
  - de
12
+ ---
13
+
14
+ # Public Ground-Truth Dataset for Handwritten Circuit Diagrams (GTDB-HD)
15
+ This repository contains images of hand-drawn electrical circuit diagrams as well as accompanying bounding box annotation for object detection as well as segmentation ground truth files. This dataset is intended to train (e.g. neural network) models for the purpose of the extraction of electrical graphs from raster graphics.
16
+
17
+ ## Structure
18
+ The folder structure is made up as follows:
19
+
20
+ ```
21
+ gtdh-hd
22
+ │ README.md # This File
23
+ │ classes.json # Classes List
24
+ │ classes_color.json # Classes to Color Map
25
+ │ classes_discontinuous.json # Classes Morphology Info
26
+ │ classes_ports.json # Electrical Port Descriptions for Classes
27
+ │ consistency.py # Dataset Statistics and Consistency Check
28
+ | loader.py # Simple Dataset Loader and Storage Functions
29
+ │ segmentation.py # Multiclass Segmentation Generation
30
+ │ utils.py # Helper Functions
31
+ └───drafter_D
32
+ │ └───annotations # Bounding Box Annotations
33
+ │ │ │ CX_DY_PZ.xml
34
+ │ │ │ ...
35
+ │ │
36
+ │ └───images # Raw Images
37
+ │ │ │ CX_DY_PZ.jpg
38
+ │ │ │ ...
39
+ │ │
40
+ │ └───instances # Instance Segmentation Polygons
41
+ │ │ │ CX_DY_PZ.json
42
+ │ │ │ ...
43
+ │ │
44
+ │ └───segmentation # Binary Segmentation Maps (Strokes vs. Background)
45
+ │ │ │ CX_DY_PZ.jpg
46
+ │ │ │ ...
47
+ ...
48
+ ```
49
+
50
+ Where:
51
+
52
+ - `D` is the (globally) running number of a drafter
53
+ - `X` is the (globally) running number of the circuit (12 Circuits per Drafter)
54
+ - `Y` is the Local Number of the Circuit's Drawings (2 Drawings per Circuit)
55
+ - `Z` is the Local Number of the Drawing's Image (4 Pictures per Drawing)
56
+
57
+ ### Image Files
58
+ Every image is RGB-colored and either stored as `jpg`, `jpeg` or `png` (both uppercase and lowercase suffixes exist).
59
+
60
+ ### Bounding Box Annotations
61
+ A complete list of class labels including a suggested mapping table to integer numbers for training and prediction purposes can be found in `classes.json`. The annotations contains **BB**s (Bounding Boxes) of **RoI**s (Regions of Interest) like electrical symbols or texts within the raw images and are stored in the [PASCAL VOC](http://host.robots.ox.ac.uk/pascal/VOC/) format.
62
+
63
+ Please note: *For every Raw image in the dataset, there is an accompanying bounding box annotation file.*
64
+
65
+ #### Known Labeled Issues
66
+ - C25_D1_P4 cuts off a text
67
+ - C27 cuts of some texts
68
+ - C29_D1_P1 has one additional text
69
+ - C31_D2_P4 has a text less
70
+ - C33_D1_P4 has a text less
71
+ - C46_D2_P2 cuts of a text
72
+
73
+ ### Instance Segmentation
74
+ For every binary segmentation map, there is an accompanying polygonal annotation file for instance segmentation purposes, which is stored in the [labelme](https://github.com/wkentaro/labelme) format. Note that the contained polygons are quite coarse, intended to be used in conjunction with the binary segmentation maps for connection extraction and to tell individual instances with overlapping BBs apart.
75
+
76
+ ### Segmentation Maps
77
+ Binary Segmentation images are available for some samples and bear the same resolution as the respective image files. They are considered to contain only black and white pixels indicating areas of drawings strokes and background respectively.
78
+
79
+ ### Netlists
80
+ For some images, there are also netlist files available, which are stored in the [ASC](http://ltwiki.org/LTspiceHelp/LTspiceHelp/Spice_Netlist.htm) format.
81
+
82
+ ### Consistency and Statistics
83
+ This repository comes with a stand-alone script to:
84
+
85
+ - Obtain Statistics on
86
+ - Class Distribution
87
+ - BB Sizes
88
+ - Check the BB Consistency
89
+ - Classes with Regards to the `classes.json`
90
+ - Counts between Pictures of the same Drawing
91
+ - Ensure a uniform writing style of the Annotation Files (indent)
92
+
93
+ The respective script is called without arguments to operate on the **entire** dataset:
94
+
95
+ ```
96
+ $ python3 consistency.py
97
+ ```
98
+
99
+ Note that due to a complete re-write of the annotation data, the script takes several seconds to finish. A drafter can be specified as CLI argument to restrict the evaluation (for example drafter 15):
100
+
101
+ ```
102
+ $ python3 consistency.py 15
103
+ ```
104
+
105
+ ### Multi-Class (Instance) Segmentation Processing
106
+ This dataset comes with a script to process both new and existing (instance) segmentation files. It is invoked as follows:
107
+
108
+ ```
109
+ $ python3 segmentation.py <command> <drafter_id> <target> <source>
110
+ ```
111
+
112
+ Where:
113
+
114
+ - `<command>` has to be one of:
115
+ - `transform`
116
+ - Converts existing BB Annotations to Polygon Annotations
117
+ - Default target folder: `instances`
118
+ - Existing polygon files will not be overridden in the default settings, hence this command will take no effect in an completely populated dataset.
119
+ - Intended to be invoked after adding new binary segmentation maps
120
+ - **This step has to be performed before all other commands**
121
+ - `wire`
122
+ - Generates Wire Describing Polygons
123
+ - Default target folder: `wires`
124
+ - `keypoint`
125
+ - Generates Keypoints for Component Terminals
126
+ - Default target folder: `keypoints`
127
+ - `create`
128
+ - Generates Multi-Class segmentation Maps
129
+ - Default target folder: `segmentation_multi_class`
130
+ - `refine`
131
+ - Refines Coarse Polygon Annotations to precisely match the annotated objects
132
+ - Default target folder: `instances_refined`
133
+ - For instance segmentation purposes
134
+ - `pipeline`
135
+ - executes `wire`,`keypoint` and `refine` stacked, with one common `source` and `target` folder
136
+ - Default target folder: `instances_refined`
137
+ - `assign`
138
+ - Connector Point to Port Type Assignment by Geometric Transformation Matching
139
+ - `<drafter_id>` **optionally** restricts the process to one of the drafters
140
+ - `<target>` **optionally** specifies a divergent target folder for results to be placed in
141
+ - `<source>` **optionally** specifies a divergent source folder to read from
142
+
143
+ Please note that source and target forlders are **always** subfolder inside the individual drafter folders. Specifying source and target folders allow to stack the results of individual processing steps. For example, to perform the entire pipeline for drafter 20 manually, use:
144
+
145
+ ```
146
+ python3 segmentation.py wire 20 instances_processed instances
147
+ python3 segmentation.py keypoint 20 instances_processed instances_processed
148
+ python3 segmentation.py refine 20 instances_processed instances_processed
149
+ ```
150
+
151
+ ### Dataset Loader
152
+ This dataset is also shipped with a set of loader and writer functions, which are internally used by the segmentation and consistency scripts and can be used for training. The dataset loader is simple, framework-agnostic and has been prepared to be callable from any location in the file system. Basic usage:
153
+
154
+ ```
155
+ from loader import read_dataset
156
+
157
+ db_bb = read_dataset() # Read all BB Annotations
158
+ db_seg = read_dataset(segmentation=True) # Read all Polygon Annotations
159
+ db_bb_val = read_dataset(drafter=12) # Read Drafter 12 BB Annotations
160
+
161
+ len(db_bb) # Get The Amount of Samples
162
+ db_bb[5] # Get an Arbitrary Sample
163
+
164
+ db = read_images(drafter=12) # Returns a list of (Image, Annotation) pairs
165
+ db = read_snippets(drafter=12) # Returns a list of (Image, Annotation) pairs
166
+ ```
167
+
168
+ ## Citation
169
+ If you use this dataset for scientific publications, please consider citing us as follows:
170
+
171
+ ```
172
+ @inproceedings{thoma2021public,
173
+ title={A Public Ground-Truth Dataset for Handwritten Circuit Diagram Images},
174
+ author={Thoma, Felix and Bayer, Johannes and Li, Yakun and Dengel, Andreas},
175
+ booktitle={International Conference on Document Analysis and Recognition},
176
+ pages={20--27},
177
+ year={2021},
178
+ organization={Springer}
179
+ }
180
+ ```
181
+
182
+ ## How to Contribute
183
+ If you want to contribute to the dataset as a drafter or in case of any further questions, please send an email to: <johannes.bayer@dfki.de> (corresponding author), <yakun.li@dfki.de>, <andreas.dengel@dfki.de>
184
+
185
+ ## Guidelines
186
+ These guidelines are used throughout the generation of the dataset. They can be used as an instruction for participants and data providers.
187
+
188
+ ### Drafter Guidelines
189
+ - 12 Circuits should be drawn, each of them twice (24 drawings in total)
190
+ - Most important: The drawing should be as natural to the drafter as possible
191
+ - Free-Hand sketches are preferred, using rulers and drawing Template stencils should be avoided unless it appears unnatural to the drafter
192
+ - Different types of pens/pencils should be used for different drawings
193
+ - Different kinds of (colored, structured, ruled, lined) paper should be used
194
+ - One symbol set (European/American) should be used throughout one drawing (consistency)
195
+ - It is recommended to use the symbol set that the drafter is most familiar with
196
+ - It is **strongly** recommended to share the first one or two circuits for review by the dataset organizers before drawing the rest to avoid problems (complete redrawing in worst case)
197
+
198
+ ### Image Capturing Guidelines
199
+ - For each drawing, 4 images should be taken (96 images in total per drafter)
200
+ - Angle should vary
201
+ - Lighting should vary
202
+ - Moderate (e.g. motion) blur is allowed
203
+ - All circuit-related aspects of the drawing must be _human-recognicable_
204
+ - The drawing should be the main part of the image, but _naturally_ occurring objects from the environment are welcomed
205
+ - The first image should be _clean_, i.e. ideal capturing conditions
206
+ - Kinks and Buckling can be applied to the drawing between individual image capturing
207
+ - Try to use the file name convention (`CX_DY_PZ.jpg`) as early as possible
208
+ - The circuit range `X` will be given to you
209
+ - `Y` should be `1` or `2` for the drawing
210
+ - `Z` should be `1`,`2`,`3` or `4` for the picture
211
+
212
+ ### Object Annotation Guidelines
213
+ - General Placement
214
+ - A **RoI** must be **completely** surrounded by its **BB**
215
+ - A **BB** should be as tight as possible to the **RoI**
216
+ - In case of connecting lines not completely touching the symbol, the BB should extended (only by a small margin) to enclose those gaps (epecially considering junctions)
217
+ - Characters that are part of the **essential symbol definition** should be included in the BB (e.g. the `+` of a polarized capacitor should be included in its BB)
218
+ - **Junction** annotations
219
+ - Used for actual junction points (Connection of three or more wire segments with a small solid circle)
220
+ - Used for connection of three or more sraight line wire segements where a physical connection can be inferred by context (i.e. can be distinuished from **crossover**)
221
+ - Used for wire line corners
222
+ - Redundant Junction Points should **not** be annotated (small solid circle in the middle of a straight line segment)
223
+ - Should not be used for corners or junctions that are part of the symbol definition (e.g. Transistors)
224
+ - **Crossover** Annotations
225
+ - If dashed/dotted line: BB should cover the two next dots/dashes
226
+ - **Text** annotations
227
+ - Individual Text Lines should be annotated Individually
228
+ - Text Blocks should only be annotated If Related to Circuit or Circuit's Components
229
+ - Semantically meaningful chunks of information should be annotated Individually
230
+ - component characteristics enclosed in a single annotation (e.g. __100Ohms__, __10%__ tolerance, __5V__ max voltage)
231
+ - Component Names and Types (e.g. __C1__, __R5__, __ATTINY2313__)
232
+ - Custom Component Terminal Labels (i.e. __Integrated Circuit__ Pins)
233
+ - Circuit Descriptor (e.g. "Radio Amplifier")
234
+ - Texts not related to the Circuit should be ignored
235
+ - e.g. Brief paper, Company Logos
236
+ - Drafters auxiliary markings for internal organization like "D12"
237
+ - Texts on Surrounding or Background Papers
238
+ - Characters which are part of the essential symbol definition should __not__ be annotated as Text dedicatedly
239
+ - e.g. Schmitt Trigger __S__, , and gate __&__, motor __M__, Polarized capacitor __+__
240
+ - Only add terminal text annotation if the terminal is not part of the essential symbol definition
241
+ - **Table** cells should be annotated independently
242
+ - **Operation Amplifiers**
243
+ - Both the triangular US symbols and the european IC-like symbols symbols for OpAmps should be labeled `operational_amplifier`
244
+ - The `+` and `-` signs at the OpAmp's input terminals are considered essential and should therefore not be annotated as texts
245
+ - **Complex Components**
246
+ - Both the entire Component and its sub-Components and internal connections should be annotated:
247
+
248
+ | Complex Component | Annotation |
249
+ | ----------------- | ------------------------------------------------------ |
250
+ | Optocoupler | 0. `optocoupler` as Overall Annotation |
251
+ | | 1. `diode.light_emitting` |
252
+ | | 2. `transistor.photo` (or `resistor.photo`) |
253
+ | | 3. `optical` if LED and Photo-Sensor arrows are shared |
254
+ | | Then the arrows area should be includes in all |
255
+ | Relay | 0. `relay` as Overall Annotation |
256
+ | (also for | 1. `inductor` |
257
+ | coupled switches) | 2. `switch` |
258
+ | | 3. `mechanical` for the dashed line between them |
259
+ | Transformer | 0. `transformer` as Overall Annotation |
260
+ | | 1. `inductor` or `inductor.coupled` (watch the dot) |
261
+ | | 3. `magnetic` for the core |
262
+
263
+
264
+ #### Rotation Annotations
265
+ The Rotation (integer in degree) should capture the overall rotation of the symbol shape. However, the position of the terminals should also be taked into consideration. Under idealized circumstances (no perspective distorion and accurately drawn symbols according to the symbol library), these two requirements equal each other. For pathological cases however, in which shape and the set of terminals (or even individual terminals) are conflicting, the rotation should compromise between all factors.
266
+
267
+ Rotation annotations are currently work in progress. They should be provided for at least the following classes:
268
+ - "voltage.dc"
269
+ - "resistor"
270
+ - "capacitor.unpolarized"
271
+ - "diode"
272
+ - "transistor.bjt"
273
+
274
+ #### Text Annotations
275
+ - The Character Sequence in the Text Label Annotations should describe the actual Characters depicted in the respective Bounding Box as Precisely as Possible
276
+ - Bounding Box Annotations of class `text`
277
+ - Bear an additional `<text>` tag in which their content is given as string
278
+ - The `Omega` and `Mikro` Symbols are escaped respectively
279
+ - Currently Work in Progress
280
+ - The utils script allows for migrating text annotations from one annotation file to another: `python3 utils.py source target`
281
+
282
+
283
+ ### Segmentation Map Guidelines
284
+ - Areas of __Intended__ drawing strokes (ink and pencil abrasion respectively) should be marked black, all other pixels (background) should be white
285
+ - shining through the paper (from the rear side or other sheets) should be considered background
286
+
287
+ ### Polygon Annotation Guidelines
288
+
289
+ 0. Before starting, make sure the respective files exist for the image sample to be polygon-annotated:
290
+ - BB Annotations (Pascal VOC XML File)
291
+ - (Binary) Segmentation Map
292
+ 1. Transform the BB annotations into raw polygons
293
+ - Use: `python3 segmentation.py transform`
294
+ 2. Refine the Polygons
295
+ - **To Avoid Embedding Image Data into the resulting JSON**, use: `labelme --nodata`
296
+ - Just make sure there are no overlaps between instances
297
+ - Especially take care about overlaps with structural elements like junctions and crossovers
298
+ 3. Generate Multi-Class Segmentation Maps from the refined polygons
299
+ - Use: `python3 segmentation.py create`
300
+ - Use the generated images for a visual inspection
301
+ - After spotting problems, continue with Step 2
302
+
303
+ ### Terminal Annotation Guidelines
304
+
305
+ ```
306
+ labelme --labels "connector" --config "{shift_auto_shape_color: 1}" --nodata
307
+ ```