jalFaizy commited on
Commit
5f147b7
1 Parent(s): e18889e
.gitignore ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .nox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ nosetests.xml
46
+ coverage.xml
47
+ *.cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Django stuff:
56
+ *.log
57
+ local_settings.py
58
+ db.sqlite3
59
+
60
+ # Flask stuff:
61
+ instance/
62
+ .webassets-cache
63
+
64
+ # Scrapy stuff:
65
+ .scrapy
66
+
67
+ # Sphinx documentation
68
+ docs/_build/
69
+
70
+ # PyBuilder
71
+ target/
72
+
73
+ # Jupyter Notebook
74
+ .ipynb_checkpoints
75
+
76
+ # IPython
77
+ profile_default/
78
+ ipython_config.py
79
+
80
+ # pyenv
81
+ .python-version
82
+
83
+ # celery beat schedule file
84
+ celerybeat-schedule
85
+
86
+ # SageMath parsed files
87
+ *.sage.py
88
+
89
+ # Environments
90
+ .env
91
+ .venv
92
+ env/
93
+ venv/
94
+ ENV/
95
+ env.bak/
96
+ venv.bak/
97
+
98
+ # Spyder project settings
99
+ .spyderproject
100
+ .spyproject
101
+
102
+ # Rope project settings
103
+ .ropeproject
104
+
105
+ # mkdocs documentation
106
+ /site
107
+
108
+ # mypy
109
+ .mypy_cache/
110
+ .dmypy.json
111
+ dmypy.json
112
+
113
+ # Pyre type checker
114
+ .pyre/
115
+
116
+ # trial ipynb
117
+ trial.ipynb
118
+
119
+ # original data
120
+ original_data/
README.md CHANGED
@@ -48,8 +48,8 @@ task_ids: []
48
 
49
  - **Homepage:** https://github.com/faizankshaikh/chessDetection
50
  - **Repository:** https://github.com/faizankshaikh/chessDetection
51
- - **Paper:** [Needs More Information]
52
- - **Leaderboard:** [Needs More Information]
53
  - **Point of Contact:** [Faizan Shaikh](mailto:faizankshaikh@gmail.com)
54
 
55
  ### Dataset Summary
@@ -92,7 +92,6 @@ A data point comprises an image and its label.
92
 
93
  The data is split into training and validation set. The training set contains 204 images and the validation set 52 images.
94
 
95
- Train Valid 204 52
96
 
97
  ## Dataset Creation
98
 
 
48
 
49
  - **Homepage:** https://github.com/faizankshaikh/chessDetection
50
  - **Repository:** https://github.com/faizankshaikh/chessDetection
51
+ - **Paper:** -
52
+ - **Leaderboard:** -
53
  - **Point of Contact:** [Faizan Shaikh](mailto:faizankshaikh@gmail.com)
54
 
55
  ### Dataset Summary
 
92
 
93
  The data is split into training and validation set. The training set contains 204 images and the validation set 52 images.
94
 
 
95
 
96
  ## Dataset Creation
97
 
data/{training-00000-of-00001-4248b21f1fdef089.parquet → train.zip} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:84e6c820dc1a29066401911926430ed61dd4d173524c1341d7c0ab805969f1ff
3
- size 1238568
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c0717779d3b83d32ed81bfcdd91468ad9a00135978fde76ed1f4cdb02010ba3
3
+ size 1254072
data/{validation-00000-of-00001-4248b21f1fdef089.parquet → valid.zip} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:84e6c820dc1a29066401911926430ed61dd4d173524c1341d7c0ab805969f1ff
3
- size 1238568
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:438cad2398de0ba6af7f69c208459a65967d45272edd42186cf1bfcf2ecf13be
3
+ size 321278
detect_chess_pieces.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Script for reading 'Object Detection for Chess Pieces' dataset."""
15
+
16
+
17
+ import os
18
+
19
+ import datasets
20
+
21
+ _CITATION = ""
22
+
23
+ _DESCRIPTION = """\
24
+ The "Object Detection for Chess Pieces" dataset is a toy dataset created (as suggested by the name!) to introduce object detection in a beginner friendly way.
25
+ """
26
+
27
+ _HOMEPAGE = "https://github.com/faizankshaikh/chessDetection"
28
+
29
+ _LICENSE = "CC-BY-SA:2.0"
30
+
31
+ _REPO = "data" # "https://huggingface.co/datasets/jalFaizy/resolve/main/data"
32
+ _URLS = {"train": f"{_REPO}/train.zip", "valid": f"{_REPO}/valid.zip"}
33
+
34
+
35
+ class DetectChessPieces(datasets.GeneratorBasedBuilder):
36
+ """Object Detection for Chess Pieces dataset"""
37
+
38
+ VERSION = datasets.Version("1.0.0")
39
+
40
+ def _info(self):
41
+ return datasets.DatasetInfo(
42
+ features=datasets.Features(
43
+ {
44
+ "image": datasets.Image(),
45
+ "bboxes": datasets.Sequence(datasets.Value("int32"), length=5),
46
+ }
47
+ ),
48
+ supervised_keys=None,
49
+ description=_DESCRIPTION,
50
+ homepage=_HOMEPAGE,
51
+ license=_LICENSE,
52
+ citation=_CITATION,
53
+ task_templates=[
54
+ {
55
+ "task": "object-detection",
56
+ "image_column": "image",
57
+ "label_column": "bboxes",
58
+ }
59
+ ],
60
+ )
61
+
62
+ def _split_generators(self, dl_manager):
63
+ data_dir = dl_manager.download_and_extract(_URLS)
64
+ return [
65
+ datasets.SplitGenerator(
66
+ name=datasets.Split.TRAIN,
67
+ gen_kwargs={"split": "train", "data_dir": data_dir["train"]},
68
+ ),
69
+ datasets.SplitGenerator(
70
+ name=datasets.Split.VALIDATION,
71
+ gen_kwargs={"split": "valid", "data_dir": data_dir["valid"]},
72
+ ),
73
+ ]
74
+
75
+ def _generate_examples(self, split, data_dir):
76
+ image_dir = os.path.join(data_dir, "images")
77
+ label_dir = os.path.join(data_dir, "labels")
78
+ for idx, (image_path, label_path) in enumerate(zip(image_dir, label_dir)):
79
+ im = Image.open(image_path)
80
+ width, height = im.size
81
+
82
+ with open(label_path, "r") as f:
83
+ lines = f.readlines()
84
+
85
+ bboxes = []
86
+ for line in lines:
87
+ line = line.strip().split()
88
+ try:
89
+ bbox_class = int(line[0])
90
+ bbox_xcenter = int(float(line[1]) * width)
91
+ bbox_ycenter = int(float(line[2]) * height)
92
+ bbox_width = int(float(line[3]) * width)
93
+ bbox_height = int(float(line[4]) * height)
94
+ except:
95
+ print(f"Check file {f.name} for errors")
96
+
97
+ bbox = [bbox_class, bbox_xcenter, bbox_ycenter, bbox_width, bbox_height]
98
+ bboxes.append(bbox)
99
+
100
+ yield idx, {"image": image_path, "bboxes": bboxes}