Convert dataset to Parquet

#1
PatFig_Dataset_Documentation.pdf DELETED
Binary file (306 kB)
 
README.md CHANGED
@@ -1,21 +1,66 @@
1
  ---
 
 
2
  license: cc-by-nc-4.0
 
 
3
  task_categories:
4
  - image-to-text
5
  - visual-question-answering
6
  - image-classification
7
- language:
8
- - en
9
  pretty_name: PatFig
10
- size_categories:
11
- - 10K<n<100K
12
  configs:
13
  - config_name: default
14
  data_files:
15
  - split: train
16
- path: "train/*"
17
  - split: test
18
- path: "test/*"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ---
20
 
21
  # PatFig Dataset
 
1
  ---
2
+ language:
3
+ - en
4
  license: cc-by-nc-4.0
5
+ size_categories:
6
+ - 10K<n<100K
7
  task_categories:
8
  - image-to-text
9
  - visual-question-answering
10
  - image-classification
 
 
11
  pretty_name: PatFig
 
 
12
  configs:
13
  - config_name: default
14
  data_files:
15
  - split: train
16
+ path: data/train-*
17
  - split: test
18
+ path: data/test-*
19
+ dataset_info:
20
+ features:
21
+ - name: image
22
+ dtype: image
23
+ - name: image_name
24
+ dtype: string
25
+ - name: pub_number
26
+ dtype: string
27
+ - name: title
28
+ dtype: string
29
+ - name: figs_norm
30
+ sequence: string
31
+ - name: short_description
32
+ sequence: string
33
+ - name: long_description
34
+ sequence: string
35
+ - name: short_description_token_count
36
+ dtype: int64
37
+ - name: long_description_token_count
38
+ dtype: int64
39
+ - name: draft_class
40
+ dtype: string
41
+ - name: cpc_class
42
+ dtype: string
43
+ - name: relevant_terms
44
+ list:
45
+ - name: element_identifier
46
+ dtype: string
47
+ - name: terms
48
+ sequence: string
49
+ - name: associated_claims
50
+ dtype: string
51
+ - name: compound
52
+ dtype: bool
53
+ - name: references
54
+ sequence: string
55
+ splits:
56
+ - name: train
57
+ num_bytes: 1998632864.066
58
+ num_examples: 17386
59
+ - name: test
60
+ num_bytes: 118291788.0
61
+ num_examples: 998
62
+ download_size: 1735361199
63
+ dataset_size: 2116924652.066
64
  ---
65
 
66
  # PatFig Dataset
PatFigVQA_example.png → data/test-00000-of-00001.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:532251dbff11e080a91b60d91956c49420a70381143cd8c43ea80fb94608d7f9
3
- size 544079
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9fc5a94199b4f6e957f61a6356b7d962e3a085f402a6c535a27df2f9209ab48
3
+ size 90327493
patfig_funny_logo.png → data/train-00000-of-00004.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1e79b8cf6cbe22d424c95e4816fc763e388d80cba4228908d707100f1f41182a
3
- size 4155552
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79f1ff7130306363c2e6a005052d7146c1d9f217b8724188159a390457f0a0e0
3
+ size 408046427
PatFig_example.png → data/train-00001-of-00004.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3c626eeb8727520da886493356c116cc5165a0104fa7a3445bce92cb4117591c
3
- size 260254
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c0164569ba8ddffb93d0609a36fcf51d5f25a77cadb231eff3beeb2ed922d0a
3
+ size 408133098
test/annotations_test.zip → data/train-00002-of-00004.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c32c89792df8ce01e34fb06ec0e7198972b7863b7bc8ae0447707f715f585ee2
3
- size 648128
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cbb82ca759a1a7dfa90cdb3cdcd208f552bcd7ec948f70d4545338cf8e76eaf
3
+ size 427019438
data/train-00003-of-00004.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84833998f19c27efbac5d61c0bdea5fad757ac8704c46b99057bcfba8be29ff8
3
+ size 401834743
patfig.py DELETED
@@ -1,78 +0,0 @@
1
- import datasets
2
- from datasets import load_dataset, Dataset, Value, Sequence, Features, DatasetInfo, GeneratorBasedBuilder, Image
3
-
4
- from pathlib import Path
5
- import os
6
- import pandas as pd
7
- import json
8
-
9
- _DESCRIPTION = """\ The PatFig Dataset is a curated collection of over 18,000 patent images from more than 7,
10
- 000 European patent applications, spanning the year 2020. It aims to provide a comprehensive resource for research
11
- and applications in image captioning, abstract reasoning, patent analysis, and automated documentprocessing. The
12
- overarching goal of this dataset is to advance the research in visually situated language understanding towards more
13
- hollistic consumption of the visual and textual data.
14
- """
15
-
16
- _BASE_URL = "https://huggingface.co/datasets/lcolonn/patfig/resolve/main/"
17
- _METADATA_URLS = {
18
- "annotations_train": "train/annotations_train.zip",
19
- "annotations_test": "test/annotations_test.zip"
20
- }
21
- _IMAGES_URLS = {
22
- "test_images": "train/train_images.tar.gz",
23
- "train_images": "test/test_images.tar.gz",
24
- }
25
- _URLS = {
26
- "train_images": "train/train_images.tar.gz",
27
- "test_images": "test/test_images.tar.gz",
28
- "annotations_train": "train/annotations_train.zip",
29
- "annotations_test": "test/annotations_test.zip",
30
- }
31
-
32
-
33
- class PatFig(GeneratorBasedBuilder):
34
- """DatasetBuilder for patfig dataset."""
35
-
36
- def _info(self):
37
- return DatasetInfo(
38
- description=_DESCRIPTION,
39
- features=Features({
40
- "image": Image(),
41
- "image_name": Value("string"),
42
- "pub_number": Value("string"),
43
- "title": Value("string"),
44
- "figs_norm": Sequence(feature=Value("string"), length=-1),
45
- "short_description": Sequence(feature=Value("string"), length=-1),
46
- "long_description": Sequence(feature=Value("string"), length=-1),
47
- "short_description_token_count": Value("int64"),
48
- "long_description_token_count": Value("int64"),
49
- "draft_class": Value("string"),
50
- "cpc_class": Value("string"),
51
- "relevant_terms": [{'element_identifier': Value("string"), "terms": Sequence(feature=Value("string"), length=-1)}],
52
- "associated_claims": Value("string"),
53
- "compound": Value("bool"),
54
- "references": Sequence(feature=Value(dtype='string'), length=-1),
55
- }),
56
- )
57
-
58
- def _split_generators(self, dl_manager: datasets.DownloadManager):
59
- urls_to_download = {key: _BASE_URL + fname for key, fname in _URLS.items()}
60
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
61
- return [
62
- datasets.SplitGenerator(
63
- name=datasets.Split.TRAIN, gen_kwargs={"images_dir": f'{downloaded_files["train_images"]}/train', "annotations_dir": f'{downloaded_files["annotations_train"]}/annotations_train.json'}
64
- ),
65
- datasets.SplitGenerator(
66
- name=datasets.Split.TEST, gen_kwargs={"images_dir": f'{downloaded_files["test_images"]}/test', "annotations_dir": f'{downloaded_files["annotations_test"]}/annotations_test.json'}
67
- ),
68
- ]
69
-
70
- def _generate_examples(self, images_dir: str, annotations_dir: str):
71
- with open(annotations_dir, "r") as f:
72
- data = json.load(f)
73
- for idx, record in data.items():
74
- image_path = os.path.join(images_dir, record["pub_number"], record["image_name"])
75
- yield idx, {
76
- "image": image_path,
77
- **record,
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test/test_images.tar.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:df6ee1008f158daa0201f3a95970864873710373f78a6b115890e44ba536a2b2
3
- size 82322544
 
 
 
 
train/annotations_train.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9df418bc565c227d40817b3198e65973ffa4f5fd06ba92ffc8e9664cba1bd37e
3
- size 10674301
 
 
 
 
train/train_images.tar.gz DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:47bd865fe030bb5ce5f3a75aeff35230ff256af37bf97f0496cadd3b2433c9fd
3
- size 1505465957