Molbap HF staff commited on
Commit
7a61aed
1 Parent(s): 9b00900

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -6
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
- It can be used with webdataset library or current releases of Hugging Face `datasets` library. It can also be streamed directly from the hub that way.
 
 
37
 
38
  ```python
39
- from datasets import load_dataset
 
 
 
 
 
40
 
41
- pdfa_english = load_dataset('pixparse/pdfa-english-train', streaming=True)
 
 
 
 
 
42
 
43
- print(next(iter(dataset['train'])).keys())
44
- >> dict_keys(['__key__', '__url__', 'json', 'pdf'])
 
 
 
 
 
 
 
 
 
 
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