qgyd2021 commited on
Commit
47126d8
·
1 Parent(s): 7dc4d81

[update]add data

Browse files
Files changed (5) hide show
  1. .gitignore +6 -0
  2. data/train.zip +3 -0
  3. main.py +16 -0
  4. requirements.txt +1 -0
  5. wechat_or_qq_icon_detection.py +121 -0
.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ .idea/
2
+ .git/
3
+
4
+ **/__pycache__/
5
+
6
+ **/*.tmp
data/train.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b417be9196db8eb252f8f31759504aea6ffdfbc84987b010eb4c3fabd0056cc3
3
+ size 15934756
main.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ from datasets import load_dataset
4
+
5
+ dataset = load_dataset(
6
+ "wechat_or_qq_icon_detection.py",
7
+ split="train",
8
+ )
9
+ print(dataset)
10
+
11
+ for sample in dataset:
12
+ print(sample)
13
+
14
+
15
+ if __name__ == '__main__':
16
+ pass
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ datasets
wechat_or_qq_icon_detection.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ from glob import glob
4
+ import os
5
+ from pathlib import Path
6
+
7
+ import datasets
8
+
9
+
10
+ _URL = "data/train.zip"
11
+
12
+
13
+ _CITATION = """\
14
+ @dataset{early_media,
15
+ author = {Xing Tian},
16
+ title = {wechat_or_qq_icon_detection},
17
+ month = aug,
18
+ year = 2023,
19
+ publisher = {Xing Tian},
20
+ version = {1.0},
21
+ }
22
+ """
23
+
24
+
25
+ _CATEGORIES = [
26
+ "红黑白QQ图标", "绿边白色微信图标", "淡蓝底全白QQ图标",
27
+ "绿底全白微信图标", "大绿小白微信图标", "纯色微信图标", "纯色QQ图标"
28
+ ]
29
+
30
+
31
+ class TelemarketingVoiceClassification(datasets.GeneratorBasedBuilder):
32
+ VERSION = datasets.Version("1.0.0")
33
+
34
+ BUILDER_CONFIGS = [
35
+ datasets.BuilderConfig(
36
+ name="default",
37
+ version=VERSION,
38
+ description="wechat_or_qq_icon_detection",
39
+ ),
40
+ ]
41
+
42
+ def _info(self):
43
+ features = datasets.Features(
44
+ {
45
+ "image_id": datasets.Value("string"),
46
+ "image": datasets.Image(),
47
+ "objects": datasets.Sequence({
48
+ "object_id": datasets.Value("int64"),
49
+ "bbox": datasets.Sequence(datasets.Value("float32"), length=4),
50
+ "category": datasets.ClassLabel(names=_CATEGORIES)
51
+ }),
52
+ "source": datasets.Value("string"),
53
+ }
54
+ )
55
+
56
+ return datasets.DatasetInfo(
57
+ features=features,
58
+ supervised_keys=None,
59
+ homepage="",
60
+ license="",
61
+ citation=_CITATION,
62
+ )
63
+
64
+ def _split_generators(self, dl_manager):
65
+ """Returns SplitGenerators."""
66
+ dl_path = dl_manager.download_and_extract(_URL)
67
+ archive_path = os.path.join(dl_path, self.config.name)
68
+
69
+ return [
70
+ datasets.SplitGenerator(
71
+ name=datasets.Split.TRAIN,
72
+ gen_kwargs={"archive_path": archive_path, "split": "train"},
73
+ ),
74
+ ]
75
+
76
+ def _generate_examples(self, archive_path, split):
77
+ """Yields examples."""
78
+ archive_path = Path(archive_path)
79
+ archive_path = archive_path.parent
80
+
81
+ annotation_file = archive_path / split / "annotation.txt"
82
+
83
+ idx = 0
84
+ source = 0
85
+ image_path = None
86
+ objects = list()
87
+ with open(annotation_file, "r", encoding="utf-8") as f:
88
+ for row in f:
89
+ row = str(row).strip()
90
+
91
+ if len(row) == 0:
92
+ image_path_ = archive_path / split / image_path
93
+
94
+ with open(image_path_.as_posix(), "rb") as f_image:
95
+ image_bytes = f_image.read()
96
+ yield idx, {
97
+ "image_id": image_path.name,
98
+ "image": {"path": image_path.as_posix(), "bytes": image_bytes},
99
+ "objects": objects,
100
+ "source": source,
101
+ }
102
+ idx += 1
103
+ source = 0
104
+ image_path = None
105
+ objects = list()
106
+
107
+ elif image_path is None:
108
+ image_path = Path(row)
109
+ else:
110
+ splits = row.split(",")
111
+ splits = [int(str(split).strip()) for split in splits]
112
+ objects.append({
113
+ "object_id": len(objects),
114
+ "bbox": splits[:4],
115
+ "category": _CATEGORIES[splits[4]],
116
+ })
117
+ source = splits[5]
118
+
119
+
120
+ if __name__ == '__main__':
121
+ pass