Upload image-upoload.py
Browse files- image-upoload.py +37 -0
image-upoload.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import datasets
|
3 |
+
|
4 |
+
_URL="https://huggingface.co/datasets/aadhiya/image-upoload/resolve/main/images.tar.gz"
|
5 |
+
class Builddata(datasets.GeneratorBasedBuilder):
|
6 |
+
def _info(self):
|
7 |
+
return datasets.DatasetInfo(
|
8 |
+
description=_DESCRIPTION,
|
9 |
+
features=datasets.Features(
|
10 |
+
{
|
11 |
+
"text":datasets.Value("string"),
|
12 |
+
"image":datasets.Image(),
|
13 |
+
}
|
14 |
+
),
|
15 |
+
supervised_keys=None
|
16 |
+
)
|
17 |
+
def _split_generators(self,dl_manager):
|
18 |
+
path=dl_manager.download(_URL)
|
19 |
+
image_iters=dl_manager.iter_archive(path)
|
20 |
+
return [
|
21 |
+
datasets.SplitGenerator(
|
22 |
+
name=datasets.Split.TRAIN,
|
23 |
+
gen_kwargs={
|
24 |
+
"images":image_iters
|
25 |
+
}
|
26 |
+
),
|
27 |
+
]
|
28 |
+
|
29 |
+
|
30 |
+
def _generate_examples(self,images):
|
31 |
+
idx=0
|
32 |
+
for filepath,image in images:
|
33 |
+
yield idx,{
|
34 |
+
"image":{"path":filepath,"bytes":image.read()},
|
35 |
+
"text":descriptions[idx]
|
36 |
+
}
|
37 |
+
idx+=1
|