Skip to content

Commit b7a3b93

Browse files
caitlinwheelesscaitlinwheelessrobot-ci-heartexhlomzik
authored
docs: DOC-231: Update docs for multi-page doc annotation (#6725)
Co-authored-by: caitlinwheeless <[email protected]> Co-authored-by: robot-ci-heartex <[email protected]> Co-authored-by: hlomzik <[email protected]> Co-authored-by: caitlinwheeless <[email protected]>
1 parent 3f88d0a commit b7a3b93

File tree

4 files changed

+117
-170
lines changed

4 files changed

+117
-170
lines changed

docs/source/tags/image.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When you annotate image regions with this tag, the annotations are saved as perc
1818
| --- | --- | --- | --- |
1919
| name | <code>string</code> | | Name of the element |
2020
| value | <code>string</code> | | Data field containing a path or URL to the image |
21-
| [valueList] | <code>string</code> | | References a variable that holds a list of image URLs |
21+
| [valueList] | <code>string</code> | | References a variable that holds a list of image URLs. For an example, see the [Multi-Page Document Annotation](/templates/multi-page-document-annotation) template. |
2222
| [smoothing] | <code>boolean</code> | | Enable smoothing, by default it uses user settings |
2323
| [width] | <code>string</code> | <code>&quot;100%&quot;</code> | Image width |
2424
| [maxWidth] | <code>string</code> | <code>&quot;750px&quot;</code> | Maximum image width |
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,159 @@
11
---
2-
title: Multi-page Document Annotation
3-
2+
title: Multi-Page Document Annotation
3+
type: templates
44
category: Computer Vision
55
cat: computer-vision
6-
badge: <i class='ent'></i>
76
order: 112
8-
is_new: t
97
meta_title: Multi-page Document Annotation
108
meta_description: Template for labeling large, multi-page documents more easily and efficiently.
119
---
1210

13-
With Label Studio Enterprise, the multi-page document annotation feature allows you to label large multi-page documents more easily and efficiently. You can now upload hundreds of pages as a single document, allowing navigation and annotation on multiple pages while maintaining the entire document's context. This release eliminates the significant amount of lag in loading the images into the browser and enhances the labeling speed.
11+
<img src="/images/templates/multipage.png" alt="" class="gif-border" />
12+
13+
Multi-page document annotation allows you to annotate documents that consist of multiple pages. By representing each page as an image, you can import them into a single task and annotate each page while maintaining the context of the entire document.
1414

15+
If you just need to classify a PDF document as a whole, you can also use the [PDF Classification template](pdf_classification).
1516

1617
## Prerequisites
1718

18-
The prerequisites to use the multi-page document annotation detection feature are as follows:
19+
Multi-page document annotation requires that you first pre-process your document by converting it into separate images. There are multiple tools to do this, including a built-in option in [Adobe Acrobat](https://helpx.adobe.com/acrobat/using/pdf-to-jpg.html).
1920

20-
1. Before uploading a PDF document to Label Studio, you must pre-process the document by converting it into separate images. However, you can still annotate PDF documents directly, for example, by performing [classification on each document page](/templates/pdf_classification.html).
21-
2. In Label Studio, import all the images into the browser using the following format:
22-
```json
23-
[{
24-
"data": {
25-
"pages": [{
26-
"image": "image-1-url"
27-
}, {
28-
"image": "image-2-url"
29-
}, {
30-
"image": "image-3-url"
31-
}]
32-
}
33-
}]
21+
To improve performance, we preload images by downloading an image via XHR and storing it in the local browser’s storage. For this to function properly, you must set up a CORS policy on the CDN/storage where the images are located. Specifically, the following headers must be set:
22+
23+
```
24+
Access-Control-Allow-Origin: https://app.heartex.com
25+
Access-Control-Allow-Methods: GET, OPTIONS
26+
Access-Control-Allow-Headers: Content-Type
3427
```
35-
3. Now, check if the projects using **Repeater** tag is paginated.
3628

29+
## Limitations
3730

38-
## Key capabilities supported
31+
For performance reasons, we recommend that the maximum number of tasks per project be limited to around 100,000.
3932

40-
The following key capabilities are supported by the multi-page document annotation.
33+
If you are creating tasks with multiple images, you may need to plan for a smaller task limit within each project. For example, a task with 100 images would be roughly equivalent to 100 tasks (in terms of performance considerations).
4134

42-
1. Support one image per screen or one text per screen. This can include a large text, but it should be the only document that requires annotation. In several scenarios, there is a need to annotate multi-page documents. For example, when you have PDF documents that consist of multiple pages then you must annotate the whole document as one task. This implies the annotator receives this one multi-page document for annotation.
35+
## Page navigation
4336

44-
2. Use Hot-key driven annotation using the left arrow key to move upwards and the right arrow key to move downwards in a multi-page document.
37+
When performing multi-page annotations, you'll see a new navigation menu:
4538

46-
3. Introduce API driven process to customize the pagination in a multi-page document.
39+
![Multi-page navigation](../images/templates-misc/multipage_nav2.png)
4740

48-
4. Help companies and organizations that deal with large, complex documents, including extensive research papers and healthcare, legal, or financial documents that run between dozens and hundreds of pages long.
41+
!!! info Tip
42+
* To navigate to a specific page, click on the page numbers in the center and enter the desired page.
43+
* You can also use the following hot keys to navigate: `command + left`/`command + right` or `ctrl + left`/`ctrl + right`.
4944

5045

5146
## Labeling configuration
5247

53-
The simplest way to work with multi-page document annotation is to go in [project settings](/guide/setup.html#Modify-the-labeling-interface) and specify the following labeling configuration.
48+
Enable multi-page annotation by using the `<Image>` tag and setting the `valueList` parameter instead of the `value` parameter.
5449

55-
```html
50+
```xml
5651
<View>
57-
<Repeater on="$images" indexFlag="{{idx}}" mode="pagination">
58-
<Image name="page_{{idx}}" value="$images[{{idx}}].url"/>
59-
<Header value="Utterance Review"/>
60-
<RectangleLabels name="labels_{{idx}}" toName="page_{{idx}}">
61-
<Label value="Document Title" />
62-
<Label value="Document Date" />
63-
</RectangleLabels>
64-
<Taxonomy
65-
name="categories_{{idx}}"
66-
toName="page_{{idx}}"
67-
perRegion="true"
68-
visibleWhen="region-selected"
69-
>
70-
<Choices name="utterance_action_{{idx}}" showInline="true" toName="user_{{idx}}">
71-
<Choice value="Archaea"/>
72-
<Choice value="Bacteria"/>
73-
<Choice value="Eukarya">
74-
<Choice value="Human"/>
75-
<Choice value="Oppossum"/>
76-
<Choice value="Extraterrestrial"/>
77-
</Choices>
78-
</Taxonomy>
79-
</Repeater>
52+
<RectangleLabels name="rectangles" toName="pdf" showInline="true">
53+
<Label value="Title" background="red"/>
54+
<Label value="Summary" background="blue"/>
55+
<Label value="Author" background="green"/>
56+
<Label value="Table" background="gold"/>
57+
<Label value="Citation" background="purple"/>
58+
</RectangleLabels>
59+
<Image valueList="$pages" name="pdf"/>
8060
</View>
8161
```
8262

83-
## About the labeling configuration
63+
Similar to `value`, the `valueList` parameter accepts a variable. The difference in this case is that you are referencing an array in your JSON.
8464

85-
All labeling configurations must be wrapped in [View](/tags/view.html) tags.
65+
For example, the following references `pages` in the [example input data](#Input-data-format) below.
8666

87-
You can add a [header](/tags/header.html) tag to provide instructions to the annotator:
8867
```xml
89-
<Header>Label the video:</Header>
68+
<Image valueList="$pages" name="pdf"/>
9069
```
9170

92-
Use the [Choices](/tags/choices.html) tag to create a group of choices, with radio buttons, or checkboxes.
93-
94-
```xml
95-
<Choices name="utterance_action_{{idx}}" showInline="true" toName="user_{{idx}}">
96-
```
97-
98-
99-
## Label Studio UI enhancements
100-
101-
The multi-page document annotation feature includes the following UI enhancements:
102-
103-
1. Ability to add `<Repeater mode="pagination" ...>` parameter in the **Repeater** tab labeling configuration.
104-
105-
2. A pagination box that appears on every page (in a multi-page document) that allows quick navigation to the first page, last page, or specific page efficiently.
106-
107-
3. An option to use **Outliner** for scrolling from one page to another in a multi-page document.
108-
109-
110-
## Use cases
111-
The multi-page document annotation feature provides the following use cases:
112-
113-
### Draw bounding boxes
114-
115-
To draw bounding boxes over some specific elements inside a multi-page (100 pages) PDF document:
116-
117-
1. Convert the PDF document into 100 images because as per this example, there are 100 pages in a PDF document.
118-
2. Store the images to create a task (with 100 images).
119-
3. Import data as JSON tasks with the list of 100 images.
120-
4. When the interface is loaded with 100 images, you can draw bounding boxes inside the images. You can also use the **Repeater** tag with pagination to navigate back and forth throughout these multi-page documents and annotate images.
121-
122-
<img src="../images/draw-bb-multipage-document-annotation.png" class="gif-border" />
123-
124-
<i>Figure 1: Use bounding boxes. </i>
125-
126-
### Page scroll
127-
128-
By default, the multi-page document annotation did not support pagination as shown in Figure 2.
129-
130-
<img src="../images/without-pagination-option.png" class="gif-border" />
131-
132-
<i>Figure 2: Without pagination. </i>
133-
134-
To find a page or a specific page number, use your mouse pad to scroll down the multi-page document.
135-
136-
137-
### Page navigation control
138-
139-
You can use `mode` property to the **Repeater** tag and the multi-page document annotation with pagination capability to annotate multiple pages in a single document:
140-
141-
1. In the Label Studio UI, navigate to **Settings** >> **Labeling Interface** >> **Code**.
142-
143-
<img src="../images/add-mode-pagination-location.png" class="gif-border" />
71+
!!! note Classification
72+
This example uses bounding box labeling. However, you can modify the template to perform classification tasks instead (using the [`Choices` tag](/tags/choices)). When using the `Choices` tag, note the following:
73+
74+
* You can perform per-page classification using `perItem="true"`.
75+
* You can also leave `perItem="false"` (the default) to perform per-document classification.
76+
* `perRegion="true"` is supported when drawing regions on pages.
14477

145-
<i>Figure 3: Location to add mode pagination. </i>
78+
## Input data format
14679

80+
The following example would upload a 5-page PDF that had been pre-processed into 5 images. You would reference the pages in your labeling configuration using `valueList="$pages"`.
14781

148-
2. Add **mode="pagination"** inside the **Repeater** tag.
149-
150-
<img src="../images/add-mode-pagination.png" class="gif-border" />
151-
152-
<i>Figure 4: Added mode property. </i>
153-
154-
3. Now, return to the previous screen and click on the task.
155-
156-
<img src="../images/return-back-to-the same-project.png" class="gif-border" />
157-
158-
<i>Figure 5: Return to the previous screen. </i>
159-
160-
4. The pagination feature is available in the UI preview window.
161-
162-
<img src="../images/with-pagination-option.png" class="gif-border" />
163-
164-
<i>Figure 6: Pagination option in the UI preview. </i>
165-
166-
5. The pagination option is now available on every page of the multi-page document.
167-
<img src="../images/pagination-option-on-each-page.png" class="gif-border" />
168-
169-
<i>Figure 7: Pagination option on every page. </i>
170-
171-
172-
To find a page or a specific page number, use the navigation buttons in the pagination box.
173-
174-
1. Click the `<<` button to navigate to the first page and click the `<` button to navigate to the previous page in a multi-page document.
175-
176-
<img src="../images/button-to-navigate-to-first-page.png" class="gif-border" />
177-
178-
<i>Figure 11: Button to navigate to the first page. </i>
179-
180-
181-
View of the first page using the navigation button.
182-
<img src="../images/navigate-to-first-page.png" class="gif-border" />
183-
184-
<i>Figure 12: Navigated to the first page. </i>
185-
186-
187-
2. Click the `>>` button to navigate to the last page and click the `>` button to navigate to the next page in a multi-page document.
188-
189-
<img src="../images/button-to-navigate-to-last-page.png" class="gif-border" />
190-
191-
<i>Figure 13: Button to navigate to the last page. </i>
192-
193-
View of the last page using the navigation button.
194-
<img src="../images/navigate-to-last-page.png" class="gif-border" />
195-
196-
<i>Figure 14: Navigated to the first page. </i>
197-
198-
199-
### Page navigation with Outliner
82+
```json
83+
{
84+
"data": {
85+
"pages": [
86+
"https://htx-pub.s3.amazonaws.com/demo/images/demo_stock_purchase_agreement/0001.jpg",
87+
"https://htx-pub.s3.amazonaws.com/demo/images/demo_stock_purchase_agreement/0002.jpg",
88+
"https://htx-pub.s3.amazonaws.com/demo/images/demo_stock_purchase_agreement/0003.jpg"
89+
]
90+
}
91+
}
92+
```
20093

201-
To find a page or a specific page number, use the outliner feature.
94+
## Export format
20295

203-
Example of using outliner document title:
96+
When exporting your annotations, the `item_index` property returns the index of the image that a region is attached to. Indexes start with 0, meaning the first image will be `0`, the second will be `1`, and so on:
20497

205-
<img src="../images/navigate-to-pages-using-outliner-document-title.png" class="gif-border" />
206-
<i>Figure 9: Navigate using outliner document title. </i>
98+
```json
99+
[
100+
{
101+
"id": 859,
102+
"annotations": [
103+
{
104+
"id": 25569355,
105+
"result": [
106+
{
107+
"id": "tdS8Of63VJ",
108+
"type": "rectanglelabels",
109+
"value": {
110+
"x": 2.48868778280543,
111+
"y": 4.807692307692308,
112+
"width": 52.88461538461539,
113+
"height": 5.128205128205128,
114+
"rotation": 0,
115+
"rectanglelabels": [
116+
"Title"
117+
]
118+
},
119+
"origin": "manual",
120+
"to_name": "pdf",
121+
"from_name": "choices",
122+
"item_index": 0,
123+
"image_rotation": 0,
124+
"original_width": 2550,
125+
"original_height": 3300
126+
},
127+
{
128+
"id": "RGGrHm95R7",
129+
"type": "rectanglelabels",
130+
"value": {
131+
"x": 30.693815987933636,
132+
"y": 12.179487179487179,
133+
"width": 58.4841628959276,
134+
"height": 1.2820512820512828,
135+
"rotation": 0,
136+
"rectanglelabels": [
137+
"Citation"
138+
]
139+
},
140+
"origin": "manual",
141+
"to_name": "pdf",
142+
"from_name": "choices",
143+
"item_index": 1,
144+
"image_rotation": 0,
145+
"original_width": 2550,
146+
"original_height": 3300
147+
}
148+
]
149+
}
150+
]
151+
}
152+
]
207153

154+
```
208155

209156
## Related tags
210-
- [Choices](/tags/choices.html)
211-
- [Labels](/tags/labels.html)
212-
- [RectangleLabels](/tags/rectanglelabels.html)
157+
- [Image](/tags/image)
158+
- [Label](/tags/label)
159+
- [RectangleLabels](/tags/rectanglelabels)
Loading

web/libs/editor/src/tags/object/Image/Image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const IMAGE_PRELOAD_COUNT = 3;
6969
* @meta_description Customize Label Studio with the Image tag to annotate images for computer vision machine learning and data science projects.
7070
* @param {string} name - Name of the element
7171
* @param {string} value - Data field containing a path or URL to the image
72-
* @param {string} [valueList] - References a variable that holds a list of image URLs
72+
* @param {string} [valueList] - References a variable that holds a list of image URLs. For an example, see the [Multi-Page Document Annotation](/templates/multi-page-document-annotation) template.
7373
* @param {boolean} [smoothing] - Enable smoothing, by default it uses user settings
7474
* @param {string=} [width=100%] - Image width
7575
* @param {string=} [maxWidth=750px] - Maximum image width

0 commit comments

Comments
 (0)