Datasets:
lcolonn
commited on
Commit
•
0ae7e86
1
Parent(s):
e22ef0a
refactor: structure
Browse files- annotations_test.csv +0 -0
- annotations_train.csv +0 -3
- patfig.py +0 -70
- annotations_test.parquet → test/annotations_test.parquet +0 -0
- test_images.tar.gz → test/test_images.tar.gz +0 -0
- annotations_train.parquet → train/annotations_train.parquet +0 -0
- train_images.tar.gz → train/train_images.tar.gz +0 -0
annotations_test.csv
DELETED
The diff for this file is too large to render.
See raw diff
|
|
annotations_train.csv
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:57df281915f932015eda3ad263b791c9459fad1918b57765fa33411d5e12f818
|
3 |
-
size 69511671
|
|
|
|
|
|
|
|
patfig.py
DELETED
@@ -1,70 +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 |
-
|
8 |
-
_DESCRIPTION = """\ The PatFig Dataset is a curated collection of over 18,000 patent images from more than 7,
|
9 |
-
000 European patent applications, spanning the year 2020. It aims to provide a comprehensive resource for research
|
10 |
-
and applications in image captioning, abstract reasoning, patent analysis, and automated documentprocessing. The
|
11 |
-
overarching goal of this dataset is to advance the research in visually situated language understanding towards more
|
12 |
-
hollistic consumption of the visual and textual data.
|
13 |
-
"""
|
14 |
-
|
15 |
-
_URL = "https://huggingface.co/datasets/lcolonn/patfig/resolve/main/"
|
16 |
-
_URLS = {
|
17 |
-
"train_images": "train_images.tar.gz",
|
18 |
-
"test_images": "test_images.tar.gz",
|
19 |
-
"annotations_train": "annotations_train.csv",
|
20 |
-
"annotations_test": "annotations_test.csv",
|
21 |
-
}
|
22 |
-
|
23 |
-
|
24 |
-
class PatFig(GeneratorBasedBuilder):
|
25 |
-
"""DatasetBuilder for patfig dataset."""
|
26 |
-
|
27 |
-
def _info(self):
|
28 |
-
return DatasetInfo(
|
29 |
-
description=_DESCRIPTION,
|
30 |
-
features=Features({
|
31 |
-
"image": Image(),
|
32 |
-
"image_name": Value("string"),
|
33 |
-
"pub_number": Value("string"),
|
34 |
-
"title": Value("string"),
|
35 |
-
"figs_norm": Sequence(feature=Value("string"), length=-1),
|
36 |
-
"short_description": Sequence(feature=Value("string"), length=-1),
|
37 |
-
"long_description": Sequence(feature=Value("string"), length=-1),
|
38 |
-
"short_description_token_count": Value("int64"),
|
39 |
-
"long_description_token_count": Value("int64"),
|
40 |
-
"draft_class": Value("string"),
|
41 |
-
"cpc_class": Value("string"),
|
42 |
-
"relevant_terms": [{'element_identifier': Value("string"), "terms": Sequence(feature=Value("string"), length=-1)}],
|
43 |
-
"associated_claims": Value("string"),
|
44 |
-
"compound": Value("bool"),
|
45 |
-
"references": Sequence(feature=Value(dtype='string'), length=-1),
|
46 |
-
}),
|
47 |
-
)
|
48 |
-
|
49 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
50 |
-
# FIXME: Currently downloads all the files regardless of the split
|
51 |
-
urls_to_download = {key: _URL + fname for key, fname in _URLS.items()}
|
52 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
53 |
-
return [
|
54 |
-
datasets.SplitGenerator(
|
55 |
-
name=datasets.Split.TRAIN, gen_kwargs={"images_dir": downloaded_files["train_images"], "annotations_dir": downloaded_files["annotations_train"]}
|
56 |
-
),
|
57 |
-
datasets.SplitGenerator(
|
58 |
-
name=datasets.Split.TEST, gen_kwargs={"images_dir": f'{downloaded_files["test_images"]}/test', "annotations_dir": downloaded_files["annotations_test"]}
|
59 |
-
),
|
60 |
-
]
|
61 |
-
|
62 |
-
def _generate_examples(self, images_dir: str, annotations_dir: str):
|
63 |
-
df = pd.read_csv(annotations_dir)
|
64 |
-
|
65 |
-
for idx, row in df.iterrows():
|
66 |
-
image_path = os.path.join(images_dir, row["pub_number"], row["image_name"])
|
67 |
-
yield idx, {
|
68 |
-
"image": image_path,
|
69 |
-
**row.to_dict(),
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
annotations_test.parquet → test/annotations_test.parquet
RENAMED
File without changes
|
test_images.tar.gz → test/test_images.tar.gz
RENAMED
File without changes
|
annotations_train.parquet → train/annotations_train.parquet
RENAMED
File without changes
|
train_images.tar.gz → train/train_images.tar.gz
RENAMED
File without changes
|