Update image-upoload.py
Browse files- image-upoload.py +34 -13
image-upoload.py
CHANGED
@@ -1,33 +1,53 @@
|
|
1 |
-
import json
|
2 |
import datasets
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
_URL="https://huggingface.co/datasets/aadhiya/image-upoload/resolve/main/images.tar.gz"
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
def _info(self):
|
7 |
return datasets.DatasetInfo(
|
8 |
description=_DESCRIPTION,
|
9 |
features=datasets.Features(
|
10 |
{
|
11 |
-
|
12 |
-
|
13 |
}
|
14 |
),
|
15 |
-
supervised_keys=None
|
|
|
|
|
16 |
)
|
17 |
-
|
18 |
-
|
|
|
19 |
image_iters=dl_manager.iter_archive(path)
|
20 |
return [
|
21 |
-
|
22 |
name=datasets.Split.TRAIN,
|
23 |
gen_kwargs={
|
24 |
-
"images":image_iters
|
25 |
}
|
26 |
),
|
27 |
]
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
idx=0
|
32 |
for filepath,image in images:
|
33 |
yield idx,{
|
@@ -35,3 +55,4 @@ class Builddata(datasets.GeneratorBasedBuilder):
|
|
35 |
"text":descriptions[idx]
|
36 |
}
|
37 |
idx+=1
|
|
|
|
|
|
1 |
import datasets
|
2 |
+
|
3 |
+
_CITATION = """\
|
4 |
+
@InProceedings{huggingface:dataset,
|
5 |
+
title = {Small image-text set},
|
6 |
+
author={James Briggs},
|
7 |
+
year={2022}
|
8 |
+
}
|
9 |
+
"""
|
10 |
+
|
11 |
+
_DESCRIPTION = """\
|
12 |
+
Demo dataset for testing or showing image-text capabilities.
|
13 |
+
"""
|
14 |
+
_HOMEPAGE = "https://huggingface.co/datasets/jamescalam/image-text-demo"
|
15 |
+
|
16 |
+
_LICENSE = ""
|
17 |
_URL="https://huggingface.co/datasets/aadhiya/image-upoload/resolve/main/images.tar.gz"
|
18 |
+
_REPO = "https://huggingface.co/datasets/jamescalam/image-text-demo"
|
19 |
+
|
20 |
+
class ImageSet(datasets.GeneratorBasedBuilder):
|
21 |
+
"""Small sample of image-text pairs"""
|
22 |
+
|
23 |
def _info(self):
|
24 |
return datasets.DatasetInfo(
|
25 |
description=_DESCRIPTION,
|
26 |
features=datasets.Features(
|
27 |
{
|
28 |
+
'text': datasets.Value("string"),
|
29 |
+
'image': datasets.Image(),
|
30 |
}
|
31 |
),
|
32 |
+
supervised_keys=None,
|
33 |
+
homepage=_HOMEPAGE,
|
34 |
+
citation=_CITATION,
|
35 |
)
|
36 |
+
|
37 |
+
def _split_generators(self, dl_manager):
|
38 |
+
path=dl_manager.download(_URL)
|
39 |
image_iters=dl_manager.iter_archive(path)
|
40 |
return [
|
41 |
+
datasets.SplitGenerator(
|
42 |
name=datasets.Split.TRAIN,
|
43 |
gen_kwargs={
|
44 |
+
"images": image_iters
|
45 |
}
|
46 |
),
|
47 |
]
|
48 |
+
|
49 |
+
def _generate_examples(self, images):
|
50 |
+
""" This function returns the examples in the raw (text) form."""
|
51 |
idx=0
|
52 |
for filepath,image in images:
|
53 |
yield idx,{
|
|
|
55 |
"text":descriptions[idx]
|
56 |
}
|
57 |
idx+=1
|
58 |
+
|