Datasets:
Tasks:
Image-to-Text
Modalities:
Text
Formats:
webdataset
Languages:
English
Size:
1K - 10K
License:
Update README.md
Browse files
README.md
CHANGED
@@ -32,16 +32,38 @@ PDFA dataset is a document dataset filtered from the SafeDocs corpus, aka CC-MAI
|
|
32 |
|
33 |
### Usage
|
34 |
|
35 |
-
This instance of PDFA is in [webdataset](https://github.com/webdataset/webdataset/commits/main) .tar format.
|
36 |
-
|
|
|
|
|
37 |
|
38 |
```python
|
39 |
-
from
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
```
|
47 |
|
|
|
32 |
|
33 |
### Usage
|
34 |
|
35 |
+
This instance of PDFA is in [webdataset](https://github.com/webdataset/webdataset/commits/main) .tar format and can be used with derived forms of the `webdataset` library.
|
36 |
+
We recommend to use it with the [chug](https://github.com/huggingface/chug) library, an optimized library for distributed data loading.
|
37 |
+
|
38 |
+
# TODO The following example uses fitz which is AGPL. We should also recommend the same with pypdf.
|
39 |
|
40 |
```python
|
41 |
+
from chug import create_wds_loader, create_doc_anno_pipe
|
42 |
+
|
43 |
+
# TODO import image transforms and text transforms from pixparse.data
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
|
48 |
+
decoder = create_decoder_pipe(
|
49 |
+
image_preprocess=image_preprocess, # callable of transforms to image tensors
|
50 |
+
anno_preprocess=anno_preprocess, # callable of transforms to text into tensors of labels and targets
|
51 |
+
image_key="pdf",
|
52 |
+
image_fmt="RGB",
|
53 |
+
)
|
54 |
|
55 |
+
loader = create_wds_loader(
|
56 |
+
"/my_data/pdfa-eng-train-*.tar",
|
57 |
+
decoder,
|
58 |
+
is_train=True,
|
59 |
+
resampled=False,
|
60 |
+
start_interval=0,
|
61 |
+
num_samples=2159432,
|
62 |
+
workers=8,
|
63 |
+
batch_size=32, # adjust to your architecture capacity
|
64 |
+
seed=seed, # set a seed
|
65 |
+
world_size=world_size, # get world_size from your training environment
|
66 |
+
)
|
67 |
|
68 |
```
|
69 |
|