sanshanya commited on
Commit
6ce39a8
·
1 Parent(s): 96c2142
Files changed (3) hide show
  1. data.zip +3 -0
  2. eyesdiffusion.py +122 -0
  3. metadata.jsonl +50 -50
data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77bb1caeb20268da846e6501f1cda2defeee5d01266050d191546faba1dde0fd
3
+ size 642689
eyesdiffusion.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 sans
2
+ """Loading script for eyes."""
3
+
4
+ import re
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ from json import load, dump
9
+ from os.path import join, basename
10
+ from huggingface_hub import hf_hub_url
11
+
12
+ import datasets
13
+
14
+ # You can copy an official description
15
+ _DESCRIPTION = """
16
+ Teyvat is the first small-scale text-to-image prompt dataset for eye.
17
+ """
18
+
19
+ _LICENSE = "CC0 1.0"
20
+ _VERSION = datasets.Version("0.0.1")
21
+
22
+ # The HuggingFace dataset library don't host the datasets but only point to the
23
+
24
+ _URLS = {"data" :hf_hub_url(
25
+ repo_id = "sanshanya/eyesdiffusion",
26
+ filename = "data.zip",
27
+ repo_type = "dataset",
28
+ ),
29
+ "metadata" :hf_hub_url(
30
+ repo_id = "sanshanya/eyesdiffusion",
31
+ filename = "metadata.jsonl",
32
+ repo_type = "dataset",
33
+ )
34
+ }
35
+
36
+
37
+ class Teyvat(datasets.GeneratorBasedBuilder):
38
+ """111111"""
39
+
40
+
41
+ def _info(self):
42
+ """Specify the information of ."""
43
+
44
+
45
+ features = datasets.Features(
46
+ {
47
+ "image": datasets.Image(),
48
+ "text": datasets.Value("string"),
49
+ },
50
+ )
51
+
52
+ return datasets.DatasetInfo(
53
+ description=_DESCRIPTION,
54
+ features=features,
55
+ supervised_keys=None,
56
+ license=_LICENSE,
57
+ version=_VERSION
58
+ )
59
+
60
+ def _split_generators(self, dl_manager):
61
+ # If several configurations are possible (listed in BUILDER_CONFIGS),
62
+ # the configuration selected by the user is in self.config.name
63
+
64
+ # dl_manager is a datasets.download.DownloadManager that can be used to
65
+ # download and extract URLS It can accept any type or nested list/dict
66
+ # and will give back the same structure with the url replaced with path
67
+ # to local files. By default the archives will be extracted and a path
68
+ # to a cached folder where they are extracted is returned instead of the
69
+ # archive
70
+
71
+
72
+ # Resolve the urls
73
+
74
+ urls = _URLS
75
+
76
+ # Also download the data
77
+ data_path = dl_manager.download_and_extract(urls["data"])
78
+ meta_data_path = dl_manager.download(urls["metadata"])
79
+
80
+ # data = load(open(meta_data_path, "r", encoding="utf8"))
81
+ # for image in data:
82
+ # image_path = "data/" + image["file_name"]
83
+ # image_path = hf_hub_url(
84
+ # "datasets/Fazzie/Teyvat",
85
+ # filename=image_path,
86
+ # ),
87
+ # dl_manager.download(image_path)
88
+
89
+ return [
90
+ datasets.SplitGenerator(
91
+ name=datasets.Split.TRAIN,
92
+ # These kwargs will be passed to _generate_examples
93
+ gen_kwargs={
94
+ "data_path": data_path,
95
+ "meta_data_path": meta_data_path
96
+ },
97
+ ),
98
+ ]
99
+
100
+ def _generate_examples(self, data_path, meta_data_path):
101
+ # This method handles input defined in _split_generators to yield
102
+ # (key, example) tuples from the dataset.
103
+ # The `key` is for legacy reasons (tfds) and is not important in itself,
104
+ # but must be unique for each example.
105
+
106
+ # Load the metadata parquet file if the config is text_only
107
+ print("Loading metadata...", meta_data_path)
108
+ data = load(open(meta_data_path, "r", encoding="utf8"))
109
+
110
+ for image in data:
111
+ image_path = join(data_path, "data", image["file_name"])
112
+ text = image["text"]
113
+
114
+
115
+
116
+ yield image_path, {
117
+ "image": {
118
+ "path": image_path,
119
+ "bytes": open(image_path, "rb").read(),
120
+ },
121
+ "text": text,
122
+ }
metadata.jsonl CHANGED
@@ -1,50 +1,50 @@
1
- {"image": "10005-L.jpg", "text": "左眼,眼底像模糊,眼底可见处未见明显异常"}
2
- {"image": "10005-R.jpg", "text": "右眼,眼底像模糊,眼底可见处未见明显异常"}
3
- {"image": "10006-L.jpg", "text": "左眼,眼底像模糊,眼底可见处未见明显异常"}
4
- {"image": "10007-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
5
- {"image": "10007-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
6
- {"image": "10012-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
7
- {"image": "10013-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
8
- {"image": "10013-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
9
- {"image": "10014-L.jpg", "text": "左眼,杯盘比大"}
10
- {"image": "10014-R.jpg", "text": "右眼,杯盘比大"}
11
- {"image": "10015-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
12
- {"image": "10015-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
13
- {"image": "10016-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
14
- {"image": "10016-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
15
- {"image": "10017-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
16
- {"image": "10017-R.jpg", "text": "右眼,颞下限局神经纤维层缺损"}
17
- {"image": "10018-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
18
- {"image": "10018-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
19
- {"image": "10020-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
20
- {"image": "10021-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
21
- {"image": "10021-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
22
- {"image": "10022-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
23
- {"image": "10022-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
24
- {"image": "10023-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
25
- {"image": "10023-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
26
- {"image": "10024-R.jpg", "text": "右眼,眼底像模糊,眼底可见处未见明显异常"}
27
- {"image": "10025-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
28
- {"image": "10025-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
29
- {"image": "10026-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
30
- {"image": "10026-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
31
- {"image": "10027-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
32
- {"image": "10027-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
33
- {"image": "10030-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
34
- {"image": "10030-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
35
- {"image": "10032-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
36
- {"image": "10032-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
37
- {"image": "10033-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
38
- {"image": "10033-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
39
- {"image": "10034-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
40
- {"image": "10034-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
41
- {"image": "10035-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
42
- {"image": "10035-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
43
- {"image": "10036-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
44
- {"image": "10037-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
45
- {"image": "10037-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
46
- {"image": "10038-L.jpg", "text": "左眼,豹纹状眼底,可见萎缩弧"}
47
- {"image": "10038-R.jpg", "text": "右眼,豹纹状眼底,可见萎缩弧"}
48
- {"image": "10040-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
49
- {"image": "10040-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
50
- {"image": "10041-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
 
1
+ {"file_name": "10005-L.jpg", "text": "左眼,眼底像模糊,眼底可见处未见明显异常"}
2
+ {"file_name": "10005-R.jpg", "text": "右眼,眼底像模糊,眼底可见处未见明显异常"}
3
+ {"file_name": "10006-L.jpg", "text": "左眼,眼底像模糊,眼底可见处未见明显异常"}
4
+ {"file_name": "10007-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
5
+ {"file_name": "10007-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
6
+ {"file_name": "10012-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
7
+ {"file_name": "10013-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
8
+ {"file_name": "10013-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
9
+ {"file_name": "10014-L.jpg", "text": "左眼,杯盘比大"}
10
+ {"file_name": "10014-R.jpg", "text": "右眼,杯盘比大"}
11
+ {"file_name": "10015-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
12
+ {"file_name": "10015-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
13
+ {"file_name": "10016-L.jpg", "text": "左眼,眼���可见处未见明显异常"}
14
+ {"file_name": "10016-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
15
+ {"file_name": "10017-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
16
+ {"file_name": "10017-R.jpg", "text": "右眼,颞下限局神经纤维层缺损"}
17
+ {"file_name": "10018-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
18
+ {"file_name": "10018-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
19
+ {"file_name": "10020-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
20
+ {"file_name": "10021-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
21
+ {"file_name": "10021-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
22
+ {"file_name": "10022-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
23
+ {"file_name": "10022-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
24
+ {"file_name": "10023-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
25
+ {"file_name": "10023-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
26
+ {"file_name": "10024-R.jpg", "text": "右眼,眼底像模糊,眼底可见处未见明显异常"}
27
+ {"file_name": "10025-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
28
+ {"file_name": "10025-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
29
+ {"file_name": "10026-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
30
+ {"file_name": "10026-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
31
+ {"file_name": "10027-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
32
+ {"file_name": "10027-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
33
+ {"file_name": "10030-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
34
+ {"file_name": "10030-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
35
+ {"file_name": "10032-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
36
+ {"file_name": "10032-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
37
+ {"file_name": "10033-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
38
+ {"file_name": "10033-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
39
+ {"file_name": "10034-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
40
+ {"file_name": "10034-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
41
+ {"file_name": "10035-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
42
+ {"file_name": "10035-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
43
+ {"file_name": "10036-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
44
+ {"file_name": "10037-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
45
+ {"file_name": "10037-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
46
+ {"file_name": "10038-L.jpg", "text": "左眼,豹纹状眼底,可见萎缩弧"}
47
+ {"file_name": "10038-R.jpg", "text": "右眼,豹纹状眼底,可见萎缩弧"}
48
+ {"file_name": "10040-L.jpg", "text": "左眼,眼底可见处未见明显异常"}
49
+ {"file_name": "10040-R.jpg", "text": "右眼,眼底可见处未见明显异常"}
50
+ {"file_name": "10041-L.jpg", "text": "左眼,眼底可见处未见明显异常"}