Sean676 commited on
Commit
e379953
·
verified ·
1 Parent(s): 4089101

Upload complete dataset

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. __pycache__/visualize_dataset.cpython-312.pyc +0 -0
  3. classes.txt +9 -0
  4. dataset.yaml +3 -1
  5. dataset_tools.py +166 -0
  6. images/test/000000000443.jpg +3 -0
  7. images/test/000000001085.jpg +3 -0
  8. images/test/000000004820.jpg +3 -0
  9. images/test/000000005115.jpg +3 -0
  10. images/test/000000009539.jpg +3 -0
  11. images/test/000000009807.jpg +3 -0
  12. images/test/000000012307.jpg +3 -0
  13. images/test/000000012690.jpg +3 -0
  14. images/test/000000014108.jpg +3 -0
  15. images/test/000000014138.jpg +3 -0
  16. images/test/000000018211.jpg +3 -0
  17. images/test/000000018633.jpg +3 -0
  18. images/test/000000019037.jpg +3 -0
  19. images/test/000000019322.jpg +3 -0
  20. images/test/000000020757.jpg +3 -0
  21. images/test/000000021076.jpg +3 -0
  22. images/test/000000026942.jpg +3 -0
  23. images/test/000000028006.jpg +3 -0
  24. images/test/000000029643.jpg +3 -0
  25. images/test/000000031090.jpg +3 -0
  26. images/test/000000031745.jpg +3 -0
  27. images/test/000000033924.jpg +3 -0
  28. images/test/000000036447.jpg +3 -0
  29. images/test/000000036523.jpg +3 -0
  30. images/test/000000037059.jpg +3 -0
  31. images/test/000000037707.jpg +3 -0
  32. images/test/000000038616.jpg +3 -0
  33. images/test/000000039368.jpg +3 -0
  34. images/test/000000041311.jpg +3 -0
  35. images/test/000000041392.jpg +3 -0
  36. images/test/000000044474.jpg +3 -0
  37. images/test/000000045586.jpg +3 -0
  38. images/test/000000050323.jpg +3 -0
  39. images/test/000000051095.jpg +3 -0
  40. images/test/000000051369.jpg +3 -0
  41. images/test/000000051403.jpg +3 -0
  42. images/test/000000052183.jpg +3 -0
  43. images/test/000000055607.jpg +3 -0
  44. images/test/000000055780.jpg +3 -0
  45. images/test/000000057460.jpg +3 -0
  46. images/test/000000059685.jpg +3 -0
  47. images/test/000000062547.jpg +3 -0
  48. images/test/000000064355.jpg +3 -0
  49. images/test/000000068717.jpg +3 -0
  50. images/test/000000072605.jpg +3 -0
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ labels/train.cache filter=lfs diff=lfs merge=lfs -text
__pycache__/visualize_dataset.cpython-312.pyc ADDED
Binary file (5.5 kB). View file
 
classes.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ cat
2
+ dog
3
+ cup
4
+ vase
5
+ potted plant
6
+ laptop
7
+ keyboard
8
+ remote
9
+ book
dataset.yaml CHANGED
@@ -7,7 +7,9 @@ names:
7
  5: laptop
8
  6: keyboard
9
  7: remote
10
- 8: book
 
 
11
  path: C:\Users\ymr\Documents\files\polyu\year3sem2\cv\proj\dataset
12
  test: .\images\test\
13
  train: .\images\train\
 
7
  5: laptop
8
  6: keyboard
9
  7: remote
10
+ 8: couch
11
+ 9: chair
12
+ 10: bed
13
  path: C:\Users\ymr\Documents\files\polyu\year3sem2\cv\proj\dataset
14
  test: .\images\test\
15
  train: .\images\train\
dataset_tools.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Dataset Tools for YOLO Object Detection
3
+ =====================================
4
+
5
+ This script provides tools to work with your YOLO dataset locally
6
+ and from Hugging Face Hub.
7
+ """
8
+
9
+ from datasets import load_dataset
10
+ import yaml
11
+ from pathlib import Path
12
+ import matplotlib.pyplot as plt
13
+ import cv2
14
+ import numpy as np
15
+
16
+ class YOLODatasetTools:
17
+ def __init__(self, dataset_path=".", hf_repo_id="Sean676/cv_proj"):
18
+ self.dataset_path = Path(dataset_path)
19
+ self.hf_repo_id = hf_repo_id
20
+ self.class_names = []
21
+ self.dataset_info = {}
22
+
23
+ def load_config(self):
24
+ """Load dataset configuration from dataset.yaml"""
25
+ config_path = self.dataset_path / "dataset.yaml"
26
+ if config_path.exists():
27
+ with open(config_path, 'r') as f:
28
+ config = yaml.safe_load(f)
29
+ self.class_names = list(config.get('names', {}).values())
30
+ self.dataset_info = config
31
+ return config
32
+ return None
33
+
34
+ def inspect_local_dataset(self):
35
+ """Inspect local dataset structure"""
36
+ print("=== Local Dataset Inspection ===")
37
+
38
+ # Load config
39
+ config = self.load_config()
40
+ if config:
41
+ print(f"Classes: {self.class_names}")
42
+ print(f"Total classes: {len(self.class_names)}")
43
+
44
+ # Check images and labels
45
+ images_dir = self.dataset_path / "images"
46
+ labels_dir = self.dataset_path / "labels"
47
+
48
+ if images_dir.exists():
49
+ print(f"\nImages directory: {images_dir}")
50
+ for split in ["train", "val", "test"]:
51
+ split_dir = images_dir / split
52
+ if split_dir.exists():
53
+ images = list(split_dir.glob("*.jpg")) + list(split_dir.glob("*.png"))
54
+ print(f" {split}: {len(images)} images")
55
+
56
+ if labels_dir.exists():
57
+ print(f"\nLabels directory: {labels_dir}")
58
+ for split in ["train", "val", "test"]:
59
+ split_dir = labels_dir / split
60
+ if split_dir.exists():
61
+ labels = list(split_dir.glob("*.txt"))
62
+ print(f" {split}: {len(labels)} label files")
63
+
64
+ def load_from_hf(self):
65
+ """Load dataset from Hugging Face Hub"""
66
+ try:
67
+ print("Loading dataset from Hugging Face Hub...")
68
+ dataset = load_dataset(self.hf_repo_id)
69
+ print(f"Dataset loaded successfully!")
70
+ print(dataset)
71
+ return dataset
72
+ except Exception as e:
73
+ print(f"Failed to load from Hub: {e}")
74
+ return None
75
+
76
+ def visualize_sample(self, split="train", max_samples=4):
77
+ """Visualize sample images with bounding boxes"""
78
+ images_dir = self.dataset_path / "images" / split
79
+ labels_dir = self.dataset_path / "labels" / split
80
+
81
+ if not images_dir.exists() or not labels_dir.exists():
82
+ print(f"Split '{split}' not found locally")
83
+ return
84
+
85
+ # Get sample images
86
+ image_files = list(images_dir.glob("*.jpg"))[:max_samples]
87
+
88
+ fig, axes = plt.subplots(2, 2, figsize=(12, 10))
89
+ axes = axes.flatten()
90
+
91
+ for i, img_path in enumerate(image_files):
92
+ if i >= max_samples:
93
+ break
94
+
95
+ # Load image
96
+ img = cv2.imread(str(img_path))
97
+ img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
98
+
99
+ # Load and draw bounding boxes
100
+ label_path = labels_dir / (img_path.stem + ".txt")
101
+ if label_path.exists():
102
+ with open(label_path, 'r') as f:
103
+ for line in f:
104
+ parts = line.strip().split()
105
+ if len(parts) >= 5:
106
+ class_id = int(parts[0])
107
+ x_center, y_center, width, height = map(float, parts[1:5])
108
+
109
+ # Convert to pixel coordinates
110
+ h, w = img.shape[:2]
111
+ x1 = int((x_center - width/2) * w)
112
+ y1 = int((y_center - height/2) * h)
113
+ x2 = int((x_center + width/2) * w)
114
+ y2 = int((y_center + height/2) * h)
115
+
116
+ # Draw rectangle
117
+ cv2.rectangle(img_rgb, (x1, y1), (x2, y2), (255, 0, 0), 2)
118
+
119
+ # Add class label
120
+ if class_id < len(self.class_names):
121
+ label = self.class_names[class_id]
122
+ cv2.putText(img_rgb, label, (x1, y1-10),
123
+ cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 2)
124
+
125
+ axes[i].imshow(img_rgb)
126
+ axes[i].set_title(f"Sample {i+1}: {img_path.name}")
127
+ axes[i].axis('off')
128
+
129
+ plt.tight_layout()
130
+ plt.savefig(f"{split}_samples.png")
131
+ print(f"Visualization saved as {split}_samples.png")
132
+ plt.show()
133
+
134
+ def download_from_hf(self, local_path="./downloaded_dataset"):
135
+ """Download dataset from Hugging Face to local folder"""
136
+ try:
137
+ dataset = load_dataset(self.hf_repo_id)
138
+ save_path = Path(local_path)
139
+ save_path.mkdir(exist_ok=True)
140
+
141
+ dataset.save_to_disk(str(save_path))
142
+ print(f"Dataset downloaded to: {save_path}")
143
+ return save_path
144
+ except Exception as e:
145
+ print(f"Download failed: {e}")
146
+ return None
147
+
148
+ def main():
149
+ tools = YOLODatasetTools()
150
+
151
+ print("=== YOLO Dataset Tools ===")
152
+ print("\n1. Inspect local dataset:")
153
+ tools.inspect_local_dataset()
154
+
155
+ print("\n2. Load from Hugging Face:")
156
+ hf_dataset = tools.load_from_hf()
157
+
158
+ print("\n3. Visualize samples (if matplotlib available):")
159
+ try:
160
+ tools.visualize_sample("train", max_samples=2)
161
+ except Exception as e:
162
+ print(f"Visualization failed: {e}")
163
+ print("Install matplotlib: pip install matplotlib")
164
+
165
+ if __name__ == "__main__":
166
+ main()
images/test/000000000443.jpg ADDED

Git LFS Details

  • SHA256: bbf4edc6f6e07240b693876bc7b8799780476e6434f13561cadb75fe9cdc1001
  • Pointer size: 130 Bytes
  • Size of remote file: 97.7 kB
images/test/000000001085.jpg ADDED

Git LFS Details

  • SHA256: 777d2e246b3c038462fba94fc3af2e126c8a42a00c49659da1a581e2a339ca5e
  • Pointer size: 131 Bytes
  • Size of remote file: 188 kB
images/test/000000004820.jpg ADDED

Git LFS Details

  • SHA256: 1c523cf7ff7561e8037f365bc90027531c8e68a475fa721268934c23b5ffc7dd
  • Pointer size: 131 Bytes
  • Size of remote file: 172 kB
images/test/000000005115.jpg ADDED

Git LFS Details

  • SHA256: 58eda08ddfa2ab5a0bc46a10982781cadd9c33932fd1fd08b99cdff39cfc6e6d
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
images/test/000000009539.jpg ADDED

Git LFS Details

  • SHA256: b4d0a62b438850ea5f4218c604f143a1643779d3c7d522444eb7bf6940954622
  • Pointer size: 131 Bytes
  • Size of remote file: 126 kB
images/test/000000009807.jpg ADDED

Git LFS Details

  • SHA256: ce8ee316dac2b0bba4e62fde0a0a41552c62e967ba522dd79bdb5ba99cf2fea0
  • Pointer size: 130 Bytes
  • Size of remote file: 90.8 kB
images/test/000000012307.jpg ADDED

Git LFS Details

  • SHA256: 1e375a52520a25b730f18f58015426fca29068b22b5dd392927d243bbea485d6
  • Pointer size: 131 Bytes
  • Size of remote file: 109 kB
images/test/000000012690.jpg ADDED

Git LFS Details

  • SHA256: 142f635916685663a5bad413b941941a5a2a2b7f354786b190523fd91b0a5fad
  • Pointer size: 131 Bytes
  • Size of remote file: 131 kB
images/test/000000014108.jpg ADDED

Git LFS Details

  • SHA256: b3a201b625c75d5be7b5913f57a09b14046e765607ce03901b9a5c20e210690a
  • Pointer size: 131 Bytes
  • Size of remote file: 120 kB
images/test/000000014138.jpg ADDED

Git LFS Details

  • SHA256: 3c686c59f55eacd2948643ee8e2c7c2a254fa494134163233ef73f993131e358
  • Pointer size: 131 Bytes
  • Size of remote file: 169 kB
images/test/000000018211.jpg ADDED

Git LFS Details

  • SHA256: cb7b08de226efc1b6cfa561155eef07f02ba57a06529328fb7b69b03eb54fe9c
  • Pointer size: 131 Bytes
  • Size of remote file: 136 kB
images/test/000000018633.jpg ADDED

Git LFS Details

  • SHA256: 15b07d389c6829daf2d5899e981af7c84ec73f34efca08366b07ff133b618738
  • Pointer size: 131 Bytes
  • Size of remote file: 205 kB
images/test/000000019037.jpg ADDED

Git LFS Details

  • SHA256: 465a6720033228d1ec13cf7481a4b4f7b1fc4c5777aa1c6495658d19e0f5b92e
  • Pointer size: 130 Bytes
  • Size of remote file: 68.3 kB
images/test/000000019322.jpg ADDED

Git LFS Details

  • SHA256: b8441d610dc7b0357768439ecb1a09a3fb4e3dd4c464e8116441b8c10b9da3e1
  • Pointer size: 131 Bytes
  • Size of remote file: 237 kB
images/test/000000020757.jpg ADDED

Git LFS Details

  • SHA256: 3ce9d3a4ac90a0107271985811b95a8914ea68300f7ed28449a0701039be598c
  • Pointer size: 131 Bytes
  • Size of remote file: 115 kB
images/test/000000021076.jpg ADDED

Git LFS Details

  • SHA256: 19ade84dcbf007937a0e743ef746f2f82c94141ad5bae5c83bc38b4e8ecf6f89
  • Pointer size: 130 Bytes
  • Size of remote file: 51.3 kB
images/test/000000026942.jpg ADDED

Git LFS Details

  • SHA256: eb10feb6400829fa1883e9917cb22bbde9e2716eb5d6700ae0b09ccff4d8c5ff
  • Pointer size: 131 Bytes
  • Size of remote file: 330 kB
images/test/000000028006.jpg ADDED

Git LFS Details

  • SHA256: ed3b1e65a3a1dab30f176436046370a3055198fbf6d54aa7e4741e7c7e63cd6d
  • Pointer size: 131 Bytes
  • Size of remote file: 148 kB
images/test/000000029643.jpg ADDED

Git LFS Details

  • SHA256: 9c494b3b86bc9d77310bdc230e9c1a41be985ce6e39ac9131f8d8bd7c4d45147
  • Pointer size: 131 Bytes
  • Size of remote file: 144 kB
images/test/000000031090.jpg ADDED

Git LFS Details

  • SHA256: ebfde9e1cab35c7eca18ec481d0065bcf080822bf8ba4ffedff7d2b52654cd17
  • Pointer size: 130 Bytes
  • Size of remote file: 73.2 kB
images/test/000000031745.jpg ADDED

Git LFS Details

  • SHA256: 5f3873efac8a5813f04ebcdec0fa6e50d2f340f6d391382676669ea21bfe3a8d
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
images/test/000000033924.jpg ADDED

Git LFS Details

  • SHA256: 7898f8fe131e61540d2d7d39706e1db0d59376c0cdf08fd16a54a44c5b5b7ce8
  • Pointer size: 131 Bytes
  • Size of remote file: 208 kB
images/test/000000036447.jpg ADDED

Git LFS Details

  • SHA256: d8fa71a5647c8f2ce2f367a2017a18d09649742df902355c40f48ae81e76db7f
  • Pointer size: 131 Bytes
  • Size of remote file: 167 kB
images/test/000000036523.jpg ADDED

Git LFS Details

  • SHA256: f85044a9474fe2c14feb8eb49b53054cbb2392bbee1304ef319b2cc1b3c89736
  • Pointer size: 131 Bytes
  • Size of remote file: 285 kB
images/test/000000037059.jpg ADDED

Git LFS Details

  • SHA256: de2c6f198b6d2298ddb0ac6750f1088d8496bd1501536cb8ced1b54b19463172
  • Pointer size: 131 Bytes
  • Size of remote file: 100 kB
images/test/000000037707.jpg ADDED

Git LFS Details

  • SHA256: f5d4d3a855d371e01589bfb104f745210cd1b91c518f319642f78345b2e0bf96
  • Pointer size: 131 Bytes
  • Size of remote file: 178 kB
images/test/000000038616.jpg ADDED

Git LFS Details

  • SHA256: 755e7a06496e09c56fc0767167cffe52b77cadf6985ad238f2f9c361e51e79e6
  • Pointer size: 131 Bytes
  • Size of remote file: 167 kB
images/test/000000039368.jpg ADDED

Git LFS Details

  • SHA256: c7efbd7aab4442c579e5a436b12d19c763735fca0697da066cdf3d386f1b20ae
  • Pointer size: 131 Bytes
  • Size of remote file: 204 kB
images/test/000000041311.jpg ADDED

Git LFS Details

  • SHA256: 14c6f5790a82f569180af21963695cf4d440ecb50ab18d9a53ed5782af9302b7
  • Pointer size: 131 Bytes
  • Size of remote file: 146 kB
images/test/000000041392.jpg ADDED

Git LFS Details

  • SHA256: 418b489a6287b4eddc5a5cdab5713bd4d4fedde449812d85afe1443757cce921
  • Pointer size: 131 Bytes
  • Size of remote file: 124 kB
images/test/000000044474.jpg ADDED

Git LFS Details

  • SHA256: 8c2c131d7106203772b05e0f98f3d96ff14823b1819e402c3118f6489b47228c
  • Pointer size: 130 Bytes
  • Size of remote file: 46.5 kB
images/test/000000045586.jpg ADDED

Git LFS Details

  • SHA256: 1a2b49ae3be481e83bda04c3a4a57e9ff9914c6ee27a5d621da00e7cb8263631
  • Pointer size: 130 Bytes
  • Size of remote file: 90.4 kB
images/test/000000050323.jpg ADDED

Git LFS Details

  • SHA256: ba035c0a5562c5af6bfec537ebd877ab9839b6e4e5b466075edf63a4ff7d7eaa
  • Pointer size: 131 Bytes
  • Size of remote file: 175 kB
images/test/000000051095.jpg ADDED

Git LFS Details

  • SHA256: 212481625a16169b78111e1b0c52a72679f323056fa16c88ff1f6dc191d8ab8b
  • Pointer size: 131 Bytes
  • Size of remote file: 108 kB
images/test/000000051369.jpg ADDED

Git LFS Details

  • SHA256: a08c9210c0dcb01a6658bdd1cc3e6d4cbddeb86079b7df20a3ae1e794e8202f8
  • Pointer size: 131 Bytes
  • Size of remote file: 138 kB
images/test/000000051403.jpg ADDED

Git LFS Details

  • SHA256: e1f01604c550fc338a57a38ef7b7d20e9b1ddd330c34523fd328fe35e168ee8e
  • Pointer size: 131 Bytes
  • Size of remote file: 191 kB
images/test/000000052183.jpg ADDED

Git LFS Details

  • SHA256: a1e4f2afe554d2540750d51aa08b0bceab1329a3c30d804d574f36f5cc04e955
  • Pointer size: 131 Bytes
  • Size of remote file: 252 kB
images/test/000000055607.jpg ADDED

Git LFS Details

  • SHA256: c52c49183bad273790a4613734b740b28244e1b256e82c0811f8651f83b89edd
  • Pointer size: 131 Bytes
  • Size of remote file: 175 kB
images/test/000000055780.jpg ADDED

Git LFS Details

  • SHA256: 8da793ef8757ced1af44ac3df5b2b92535beed6541fbb6ba7819151f160ef950
  • Pointer size: 131 Bytes
  • Size of remote file: 147 kB
images/test/000000057460.jpg ADDED

Git LFS Details

  • SHA256: 8c7085b585aae810e076c3c19ffe9c133841ef8ecb57cab03b8c8f4de08c9dfe
  • Pointer size: 131 Bytes
  • Size of remote file: 114 kB
images/test/000000059685.jpg ADDED

Git LFS Details

  • SHA256: a76dbb935258975c4581035c599e040ed1990b96bf7985c94c658c17a38a75c4
  • Pointer size: 131 Bytes
  • Size of remote file: 116 kB
images/test/000000062547.jpg ADDED

Git LFS Details

  • SHA256: 8ee6537e67b2e786c6782d5d99255b37afe53de981bd859a19edf97eaf4c12ae
  • Pointer size: 131 Bytes
  • Size of remote file: 197 kB
images/test/000000064355.jpg ADDED

Git LFS Details

  • SHA256: 085bf69bb5662a3d16b03fb70ffc4f8ccc06320cf5ba9de7b93e549c51b90e76
  • Pointer size: 131 Bytes
  • Size of remote file: 115 kB
images/test/000000068717.jpg ADDED

Git LFS Details

  • SHA256: a6a005713809d6d5093e69514d1da6c155529d63bb329cbb4291edd5917437dc
  • Pointer size: 131 Bytes
  • Size of remote file: 108 kB
images/test/000000072605.jpg ADDED

Git LFS Details

  • SHA256: 0cd1ef206a7c5e7dccac42bb06b386b46538e0409ccf1c8c2405a1dd0872e583
  • Pointer size: 130 Bytes
  • Size of remote file: 94.4 kB