aadhiya commited on
Commit
7dcef9f
·
1 Parent(s): 4d5bb3d

Update image-test.py

Browse files
Files changed (1) hide show
  1. image-test.py +58 -1
image-test.py CHANGED
@@ -1,5 +1,22 @@
1
 
 
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  descriptions=[
4
  "BotPeg Dance",
5
  "BotPeg Dance",
@@ -18,4 +35,44 @@ descriptions=[
18
  "BotPeg Thinking",
19
  "BotPeg Winner",
20
  "BotPeg Worried",
21
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ import datasets
3
 
4
+ _CITATION = """\
5
+ @InProceedings{huggingface:dataset,
6
+ title = {Small image-text set},
7
+ author={James Briggs},
8
+ year={2022}
9
+ }
10
+ """
11
+
12
+ _DESCRIPTION = """\
13
+ Demo dataset for testing or showing image-text capabilities.
14
+ """
15
+ _HOMEPAGE = "https://huggingface.co/datasets/jamescalam/image-text-demo"
16
+
17
+ _LICENSE = ""
18
+ _URL="https://huggingface.co/datasets/aadhiya/image-upoload/resolve/main/images.tar.gz"
19
+ _REPO = "https://huggingface.co/datasets/jamescalam/image-text-demo"
20
  descriptions=[
21
  "BotPeg Dance",
22
  "BotPeg Dance",
 
35
  "BotPeg Thinking",
36
  "BotPeg Winner",
37
  "BotPeg Worried",
38
+ ]
39
+
40
+ class ImageSet(datasets.GeneratorBasedBuilder):
41
+ """Small sample of image-text pairs"""
42
+
43
+ def _info(self):
44
+ return datasets.DatasetInfo(
45
+ description=_DESCRIPTION,
46
+ features=datasets.Features(
47
+ {
48
+ 'text': datasets.Value("string"),
49
+ 'image': datasets.Image(),
50
+ }
51
+ ),
52
+ supervised_keys=None,
53
+ homepage=_HOMEPAGE,
54
+ citation=_CITATION,
55
+ )
56
+
57
+ def _split_generators(self, dl_manager):
58
+ path=dl_manager.download(_URL)
59
+ image_iters=dl_manager.iter_archive(path)
60
+ return [
61
+ datasets.SplitGenerator(
62
+ name=datasets.Split.TRAIN,
63
+ gen_kwargs={
64
+ "images": image_iters
65
+ }
66
+ ),
67
+ ]
68
+
69
+ def _generate_examples(self, images):
70
+ """ This function returns the examples in the raw (text) form."""
71
+ idx=0
72
+ for filepath,image in images:
73
+ yield idx,{
74
+ "image":{"path":filepath,"bytes":image.read()},
75
+ "text":descriptions[idx]
76
+ }
77
+ idx+=1
78
+