pengchao.spc commited on
Commit
68df4ef
·
1 Parent(s): 3f9ccf6
Files changed (3) hide show
  1. images.zip +3 -0
  2. toy_semiconductor_chip.py +82 -0
  3. train.jsonl +16 -0
images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5fe15aef5ef729d42530fbbafb53c747ae79a1fc09dc9d9c52e15b4afaf92996
3
+ size 13890649
toy_semiconductor_chip.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from huggingface_hub import hf_hub_url
3
+ import datasets
4
+ import os
5
+
6
+ _VERSION = datasets.Version("0.0.2")
7
+
8
+ _DESCRIPTION = "TODO"
9
+ _HOMEPAGE = "TODO"
10
+ _LICENSE = "TODO"
11
+ _CITATION = "TODO"
12
+
13
+ _FEATURES = datasets.Features(
14
+ {
15
+ "image": datasets.Image(),
16
+ "text": datasets.Value("string"),
17
+ },
18
+ )
19
+
20
+ METADATA_URL = hf_hub_url(
21
+ "Forrest2018/toy_semiconductor_chip",
22
+ filename="train.jsonl",
23
+ repo_type="dataset",
24
+ )
25
+
26
+ IMAGES_URL = hf_hub_url(
27
+ "Forrest2018/toy_semiconductor_chip",
28
+ filename="images.zip",
29
+ repo_type="dataset",
30
+ )
31
+
32
+
33
+ _DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
34
+
35
+
36
+ class Fill50k(datasets.GeneratorBasedBuilder):
37
+ BUILDER_CONFIGS = [_DEFAULT_CONFIG]
38
+ DEFAULT_CONFIG_NAME = "default"
39
+
40
+ def _info(self):
41
+ return datasets.DatasetInfo(
42
+ description=_DESCRIPTION,
43
+ features=_FEATURES,
44
+ supervised_keys=None,
45
+ homepage=_HOMEPAGE,
46
+ license=_LICENSE,
47
+ citation=_CITATION,
48
+ )
49
+
50
+ def _split_generators(self, dl_manager):
51
+ metadata_path = dl_manager.download(METADATA_URL)
52
+ images_dir = dl_manager.download_and_extract(IMAGES_URL)
53
+
54
+ return [
55
+ datasets.SplitGenerator(
56
+ name=datasets.Split.TRAIN,
57
+ # These kwargs will be passed to _generate_examples
58
+ gen_kwargs={
59
+ "metadata_path": metadata_path,
60
+ "images_dir": images_dir,
61
+ },
62
+ ),
63
+ ]
64
+
65
+ def _generate_examples(self, metadata_path, images_dir):
66
+ metadata = pd.read_json(metadata_path, lines=True)
67
+
68
+ for _, row in metadata.iterrows():
69
+ text = row["text"]
70
+
71
+ image_path = row["image"]
72
+ image_path = os.path.join(images_dir, image_path)
73
+ image = open(image_path, "rb").read()
74
+
75
+
76
+ yield row["image"], {
77
+ "text": text,
78
+ "image": {
79
+ "path": image_path,
80
+ "bytes": image,
81
+ },
82
+ }
train.jsonl ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"image": "images/0.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
2
+ {"image": "images/1.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
3
+ {"image": "images/2.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
4
+ {"image": "images/3.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
5
+ {"image": "images/4.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
6
+ {"image": "images/5.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
7
+ {"image": "images/6.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
8
+ {"image": "images/7.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
9
+ {"image": "images/8.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
10
+ {"image": "images/9.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
11
+ {"image": "images/10.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
12
+ {"image": "images/11.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
13
+ {"image": "images/12.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
14
+ {"image": "images/13.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
15
+ {"image": "images/14.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}
16
+ {"image": "images/15.png", "text": "a photo of semiconductor chip, best quality, extremely detailed"}