Teen-Different commited on
Commit
223495d
·
verified ·
1 Parent(s): 0131d1d

Upload 4 files

Browse files
Final_classes.txt ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all_purpose_flour
2
+ almonds
3
+ apple
4
+ apricot
5
+ asparagus
6
+ avocado
7
+ bacon
8
+ banana
9
+ barley
10
+ basil
11
+ basmati_rice
12
+ beans
13
+ beef
14
+ beets
15
+ bell_pepper
16
+ berries
17
+ biscuits
18
+ blackberries
19
+ black_pepper
20
+ blueberries
21
+ bread
22
+ bread_crumbs
23
+ bread_flour
24
+ broccoli
25
+ brownie_mix
26
+ brown_rice
27
+ butter
28
+ cabbage
29
+ cake
30
+ cardamom
31
+ carrot
32
+ cashews
33
+ cauliflower
34
+ celery
35
+ cereal
36
+ cheese
37
+ cherries
38
+ chicken
39
+ chickpeas
40
+ chocolate
41
+ chocolate_chips
42
+ chocolate_syrup
43
+ cilantro
44
+ cinnamon
45
+ clove
46
+ cocoa_powder
47
+ coconut
48
+ cookies
49
+ corn
50
+ cucumber
51
+ dates
52
+ eggplant
53
+ eggs
54
+ fish
55
+ garlic
56
+ ginger
57
+ grapes
58
+ honey
59
+ jalapeno
60
+ kidney_beans
61
+ lemon
62
+ mango
63
+ marshmallows
64
+ milk
65
+ mint
66
+ muffins
67
+ mushroom
68
+ noodles
69
+ nuts
70
+ oats
71
+ okra
72
+ olive
73
+ onion
74
+ orange
75
+ oreo_cookies
76
+ pasta
77
+ pear
78
+ pepper
79
+ pineapple
80
+ pistachios
81
+ pork
82
+ potato
83
+ pumpkin
84
+ radishes
85
+ raisins
86
+ red_chilies
87
+ rice
88
+ rosemary
89
+ salmon
90
+ salt
91
+ shrimp
92
+ spinach
93
+ strawberries
94
+ sugar
95
+ sweet_potato
96
+ tomato
97
+ vanilla_ice_cream
98
+ walnuts
99
+ watermelon
100
+ yogurt
Initial_data_correction_n_augmentation.ipynb ADDED
@@ -0,0 +1,699 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "## Check for if class names in the txt file matches with the label dir "
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "markdown",
12
+ "metadata": {},
13
+ "source": [
14
+ "### Rename to bring the consistency"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": 1,
20
+ "metadata": {},
21
+ "outputs": [
22
+ {
23
+ "name": "stdout",
24
+ "output_type": "stream",
25
+ "text": [
26
+ "Renamed 'all purpose flour' to 'all_purpose_flour'\n",
27
+ "Renamed 'basmati rice' to 'basmati_rice'\n",
28
+ "Renamed 'bell pepper' to 'bell_pepper'\n",
29
+ "Renamed 'black pepper' to 'black_pepper'\n",
30
+ "Renamed 'bread crumbs' to 'bread_crumbs'\n",
31
+ "Renamed 'bread flour' to 'bread_flour'\n",
32
+ "Renamed 'brown rice' to 'brown_rice'\n",
33
+ "Renamed 'brownie mix' to 'brownie_mix'\n",
34
+ "Renamed 'chocolate chips' to 'chocolate_chips'\n",
35
+ "Renamed 'chocolate syrup' to 'chocolate_syrup'\n",
36
+ "Renamed 'cocoa powder' to 'cocoa_powder'\n",
37
+ "Renamed 'kidney beans' to 'kidney_beans'\n",
38
+ "Renamed 'oreo cookies' to 'oreo_cookies'\n",
39
+ "Renamed 'red chilies' to 'red_chilies'\n",
40
+ "Renamed 'sweet potato' to 'sweet_potato'\n",
41
+ "Renamed 'vanilla ice cream' to 'vanilla_ice_cream'\n",
42
+ "Directory renaming completed.\n"
43
+ ]
44
+ }
45
+ ],
46
+ "source": [
47
+ "import os\n",
48
+ "\n",
49
+ "def rename_directories(dataset_directory):\n",
50
+ " for dirname in os.listdir(dataset_directory):\n",
51
+ " current_dir_path = os.path.join(dataset_directory, dirname)\n",
52
+ " if os.path.isdir(current_dir_path):\n",
53
+ " new_dirname = dirname.replace(' ', '_')\n",
54
+ " new_dir_path = os.path.join(dataset_directory, new_dirname)\n",
55
+ " if current_dir_path != new_dir_path: \n",
56
+ " os.rename(current_dir_path, new_dir_path)\n",
57
+ " print(f\"Renamed '{dirname}' to '{new_dirname}'\")\n",
58
+ "dataset_directory = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data'\n",
59
+ "rename_directories(dataset_directory)\n",
60
+ "\n",
61
+ "print(\"Directory renaming completed.\")\n"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "code",
66
+ "execution_count": 2,
67
+ "metadata": {},
68
+ "outputs": [
69
+ {
70
+ "name": "stdout",
71
+ "output_type": "stream",
72
+ "text": [
73
+ "All classes in 'Final_classes.txt' have corresponding directories in the dataset.\n",
74
+ "No extra directories in the dataset that are not listed in 'Final_classes.txt'.\n"
75
+ ]
76
+ }
77
+ ],
78
+ "source": [
79
+ "\n",
80
+ "# dataset directory and class names file\n",
81
+ "dataset_dir = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data'\n",
82
+ "class_names_file = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\Final_classes.txt'\n",
83
+ "\n",
84
+ "# Load class names from file\n",
85
+ "with open(class_names_file, 'r') as f:\n",
86
+ " class_names = [line.strip().replace(' ', '_') for line in f]\n",
87
+ "\n",
88
+ "# Get a list of actual directory names in the dataset\n",
89
+ "actual_dirs = [d for d in os.listdir(dataset_dir) if os.path.isdir(os.path.join(dataset_dir, d))]\n",
90
+ "\n",
91
+ "# Check for discrepancies\n",
92
+ "missing_dirs = set(class_names) - set(actual_dirs)\n",
93
+ "extra_dirs = set(actual_dirs) - set(class_names)\n",
94
+ "\n",
95
+ "if missing_dirs:\n",
96
+ " print(f\"Missing directories for classes in 'Final_classes.txt': {missing_dirs}\")\n",
97
+ "else:\n",
98
+ " print(\"All classes in 'Final_classes.txt' have corresponding directories in the dataset.\")\n",
99
+ "\n",
100
+ "if extra_dirs:\n",
101
+ " print(f\"Extra directories in the dataset that are not listed in 'Final_classes.txt': {extra_dirs}\")\n",
102
+ "else:\n",
103
+ " print(\"No extra directories in the dataset that are not listed in 'Final_classes.txt'.\")\n"
104
+ ]
105
+ },
106
+ {
107
+ "cell_type": "markdown",
108
+ "metadata": {},
109
+ "source": [
110
+ "## Removing files other than jpg"
111
+ ]
112
+ },
113
+ {
114
+ "cell_type": "code",
115
+ "execution_count": 17,
116
+ "metadata": {},
117
+ "outputs": [
118
+ {
119
+ "name": "stdout",
120
+ "output_type": "stream",
121
+ "text": [
122
+ "No non-JPG files found in the dataset.\n"
123
+ ]
124
+ }
125
+ ],
126
+ "source": [
127
+ "\n",
128
+ "def remove_non_jpg_images(dataset_dir):\n",
129
+ " removed_files = []\n",
130
+ " for root, dirs, files in os.walk(dataset_dir):\n",
131
+ " for file in files:\n",
132
+ " # Check if the file extension is not .jpg\n",
133
+ " if not file.lower().endswith('.jpg'):\n",
134
+ " file_path = os.path.join(root, file)\n",
135
+ " os.remove(file_path) # Remove the non-JPG file\n",
136
+ " removed_files.append(file_path)\n",
137
+ " return removed_files\n",
138
+ "\n",
139
+ "\n",
140
+ "dataset_dir = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data'\n",
141
+ "removed_files = remove_non_jpg_images(dataset_dir)\n",
142
+ "\n",
143
+ "if removed_files:\n",
144
+ " print(f\"Removed {len(removed_files)} non-JPG files:\")\n",
145
+ " for file in removed_files:\n",
146
+ " print(file)\n",
147
+ "else:\n",
148
+ " print(\"No non-JPG files found in the dataset.\")\n"
149
+ ]
150
+ },
151
+ {
152
+ "cell_type": "code",
153
+ "execution_count": 20,
154
+ "metadata": {},
155
+ "outputs": [
156
+ {
157
+ "name": "stdout",
158
+ "output_type": "stream",
159
+ "text": [
160
+ "all_purpose_flour: 50 images\n",
161
+ "almonds: 50 images\n",
162
+ "apple: 50 images\n",
163
+ "apricot: 50 images\n",
164
+ "asparagus: 50 images\n",
165
+ "avocado: 50 images\n",
166
+ "bacon: 50 images\n",
167
+ "banana: 50 images\n",
168
+ "barley: 50 images\n",
169
+ "basil: 50 images\n",
170
+ "basmati_rice: 50 images\n",
171
+ "beans: 50 images\n",
172
+ "beef: 50 images\n",
173
+ "beets: 50 images\n",
174
+ "bell_pepper: 50 images\n",
175
+ "berries: 50 images\n",
176
+ "biscuits: 50 images\n",
177
+ "blackberries: 50 images\n",
178
+ "black_pepper: 50 images\n",
179
+ "blueberries: 50 images\n",
180
+ "bread: 50 images\n",
181
+ "bread_crumbs: 50 images\n",
182
+ "bread_flour: 50 images\n",
183
+ "broccoli: 50 images\n",
184
+ "brownie_mix: 50 images\n",
185
+ "brown_rice: 50 images\n",
186
+ "butter: 50 images\n",
187
+ "cabbage: 50 images\n",
188
+ "cake: 50 images\n",
189
+ "cardamom: 50 images\n",
190
+ "carrot: 50 images\n",
191
+ "cashews: 50 images\n",
192
+ "cauliflower: 50 images\n",
193
+ "celery: 50 images\n",
194
+ "cereal: 50 images\n",
195
+ "cheese: 50 images\n",
196
+ "cherries: 50 images\n",
197
+ "chicken: 50 images\n",
198
+ "chickpeas: 50 images\n",
199
+ "chocolate: 50 images\n",
200
+ "chocolate_chips: 50 images\n",
201
+ "chocolate_syrup: 50 images\n",
202
+ "cilantro: 50 images\n",
203
+ "cinnamon: 50 images\n",
204
+ "clove: 50 images\n",
205
+ "cocoa_powder: 50 images\n",
206
+ "coconut: 50 images\n",
207
+ "cookies: 50 images\n",
208
+ "corn: 50 images\n",
209
+ "cucumber: 50 images\n",
210
+ "dates: 50 images\n",
211
+ "eggplant: 50 images\n",
212
+ "eggs: 50 images\n",
213
+ "fish: 50 images\n",
214
+ "garlic: 50 images\n",
215
+ "ginger: 50 images\n",
216
+ "grapes: 50 images\n",
217
+ "honey: 50 images\n",
218
+ "jalapeno: 50 images\n",
219
+ "kidney_beans: 50 images\n",
220
+ "lemon: 50 images\n",
221
+ "mango: 50 images\n",
222
+ "marshmallows: 50 images\n",
223
+ "milk: 50 images\n",
224
+ "mint: 50 images\n",
225
+ "muffins: 50 images\n",
226
+ "mushroom: 50 images\n",
227
+ "noodles: 50 images\n",
228
+ "nuts: 50 images\n",
229
+ "oats: 50 images\n",
230
+ "okra: 50 images\n",
231
+ "olive: 50 images\n",
232
+ "onion: 50 images\n",
233
+ "orange: 50 images\n",
234
+ "oreo_cookies: 50 images\n",
235
+ "pasta: 50 images\n",
236
+ "pear: 50 images\n",
237
+ "pepper: 50 images\n",
238
+ "pineapple: 50 images\n",
239
+ "pistachios: 50 images\n",
240
+ "pork: 50 images\n",
241
+ "potato: 50 images\n",
242
+ "pumpkin: 50 images\n",
243
+ "radishes: 50 images\n",
244
+ "raisins: 50 images\n",
245
+ "red_chilies: 50 images\n",
246
+ "rice: 50 images\n",
247
+ "rosemary: 50 images\n",
248
+ "salmon: 50 images\n",
249
+ "salt: 50 images\n",
250
+ "shrimp: 50 images\n",
251
+ "spinach: 50 images\n",
252
+ "strawberries: 50 images\n",
253
+ "sugar: 50 images\n",
254
+ "sweet_potato: 50 images\n",
255
+ "tomato: 50 images\n",
256
+ "vanilla_ice_cream: 50 images\n",
257
+ "walnuts: 50 images\n",
258
+ "watermelon: 50 images\n",
259
+ "yogurt: 50 images\n",
260
+ "\n",
261
+ "Total images in dataset: 5000\n"
262
+ ]
263
+ }
264
+ ],
265
+ "source": [
266
+ "def count_images(dataset_dir):\n",
267
+ " class_image_counts = {}\n",
268
+ " for class_name in os.listdir(dataset_dir):\n",
269
+ " class_dir = os.path.join(dataset_dir, class_name)\n",
270
+ " if os.path.isdir(class_dir):\n",
271
+ " image_count = sum(1 for file in os.listdir(class_dir) if file.lower().endswith('.jpg'))\n",
272
+ " class_image_counts[class_name] = image_count\n",
273
+ " return class_image_counts\n",
274
+ "\n",
275
+ "#\n",
276
+ "dataset_dir = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data'\n",
277
+ "image_counts = count_images(dataset_dir)\n",
278
+ "\n",
279
+ "# Print out the counts\n",
280
+ "for class_name, count in image_counts.items():\n",
281
+ " print(f\"{class_name}: {count} images\")\n",
282
+ "\n",
283
+ "# Optional: total image count\n",
284
+ "total_images = sum(image_counts.values())\n",
285
+ "print(f\"\\nTotal images in dataset: {total_images}\")"
286
+ ]
287
+ },
288
+ {
289
+ "cell_type": "markdown",
290
+ "metadata": {},
291
+ "source": [
292
+ "- remove images that count is more than 50 per class "
293
+ ]
294
+ },
295
+ {
296
+ "cell_type": "code",
297
+ "execution_count": 5,
298
+ "metadata": {},
299
+ "outputs": [
300
+ {
301
+ "name": "stdout",
302
+ "output_type": "stream",
303
+ "text": [
304
+ "Class 'all_purpose_flour' meets the maximum image requirement.\n",
305
+ "Class 'almonds' meets the maximum image requirement.\n",
306
+ "Class 'apple' meets the maximum image requirement.\n",
307
+ "Class 'apricot' meets the maximum image requirement.\n",
308
+ "Class 'asparagus' meets the maximum image requirement.\n",
309
+ "Class 'avocado' meets the maximum image requirement.\n",
310
+ "Class 'bacon' meets the maximum image requirement.\n",
311
+ "Class 'banana' meets the maximum image requirement.\n",
312
+ "Class 'barley' meets the maximum image requirement.\n",
313
+ "Class 'basil' meets the maximum image requirement.\n",
314
+ "Class 'basmati_rice' meets the maximum image requirement.\n",
315
+ "Class 'beans' meets the maximum image requirement.\n",
316
+ "Class 'beef' meets the maximum image requirement.\n",
317
+ "Class 'beets' meets the maximum image requirement.\n",
318
+ "Class 'bell_pepper' meets the maximum image requirement.\n",
319
+ "Class 'berries' meets the maximum image requirement.\n",
320
+ "Class 'biscuits' meets the maximum image requirement.\n",
321
+ "Class 'blackberries' meets the maximum image requirement.\n",
322
+ "Class 'black_pepper' meets the maximum image requirement.\n",
323
+ "Class 'blueberries' meets the maximum image requirement.\n",
324
+ "Class 'bread' meets the maximum image requirement.\n",
325
+ "Class 'bread_crumbs' meets the maximum image requirement.\n",
326
+ "Class 'bread_flour' meets the maximum image requirement.\n",
327
+ "Class 'broccoli' meets the maximum image requirement.\n",
328
+ "Class 'brownie_mix' meets the maximum image requirement.\n",
329
+ "Class 'brown_rice' meets the maximum image requirement.\n",
330
+ "Class 'butter' meets the maximum image requirement.\n",
331
+ "Class 'cabbage' meets the maximum image requirement.\n",
332
+ "Class 'cake' meets the maximum image requirement.\n",
333
+ "Class 'cardamom' meets the maximum image requirement.\n",
334
+ "Class 'carrot' meets the maximum image requirement.\n",
335
+ "Class 'cashews' meets the maximum image requirement.\n",
336
+ "Class 'cauliflower' meets the maximum image requirement.\n",
337
+ "Class 'celery' meets the maximum image requirement.\n",
338
+ "Class 'cereal' meets the maximum image requirement.\n",
339
+ "Class 'cheese' meets the maximum image requirement.\n",
340
+ "Class 'cherries' meets the maximum image requirement.\n",
341
+ "Class 'chicken' meets the maximum image requirement.\n",
342
+ "Class 'chickpeas' meets the maximum image requirement.\n",
343
+ "Class 'chocolate' meets the maximum image requirement.\n",
344
+ "Class 'chocolate_chips' meets the maximum image requirement.\n",
345
+ "Class 'chocolate_syrup' meets the maximum image requirement.\n",
346
+ "Class 'cilantro' meets the maximum image requirement.\n",
347
+ "Class 'cinnamon' meets the maximum image requirement.\n",
348
+ "Class 'clove' meets the maximum image requirement.\n",
349
+ "Removed 15 images from 'cocoa_powder' to meet the maximum of 50 images.\n",
350
+ "Removed 57 images from 'coconut' to meet the maximum of 50 images.\n",
351
+ "Class 'cookies' meets the maximum image requirement.\n",
352
+ "Class 'corn' meets the maximum image requirement.\n",
353
+ "Class 'cucumber' meets the maximum image requirement.\n",
354
+ "Class 'dates' meets the maximum image requirement.\n",
355
+ "Class 'eggplant' meets the maximum image requirement.\n",
356
+ "Class 'eggs' meets the maximum image requirement.\n",
357
+ "Class 'fish' meets the maximum image requirement.\n",
358
+ "Class 'garlic' meets the maximum image requirement.\n",
359
+ "Class 'ginger' meets the maximum image requirement.\n",
360
+ "Class 'grapes' meets the maximum image requirement.\n",
361
+ "Class 'honey' meets the maximum image requirement.\n",
362
+ "Class 'jalapeno' meets the maximum image requirement.\n",
363
+ "Class 'kidney_beans' meets the maximum image requirement.\n",
364
+ "Class 'lemon' meets the maximum image requirement.\n",
365
+ "Class 'mango' meets the maximum image requirement.\n",
366
+ "Class 'marshmallows' meets the maximum image requirement.\n",
367
+ "Class 'milk' meets the maximum image requirement.\n",
368
+ "Class 'mint' meets the maximum image requirement.\n",
369
+ "Class 'muffins' meets the maximum image requirement.\n",
370
+ "Class 'mushroom' meets the maximum image requirement.\n",
371
+ "Class 'noodles' meets the maximum image requirement.\n",
372
+ "Class 'nuts' meets the maximum image requirement.\n",
373
+ "Class 'oats' meets the maximum image requirement.\n",
374
+ "Class 'okra' meets the maximum image requirement.\n",
375
+ "Class 'olive' meets the maximum image requirement.\n",
376
+ "Class 'onion' meets the maximum image requirement.\n",
377
+ "Class 'orange' meets the maximum image requirement.\n",
378
+ "Class 'oreo_cookies' meets the maximum image requirement.\n",
379
+ "Class 'pasta' meets the maximum image requirement.\n",
380
+ "Class 'pear' meets the maximum image requirement.\n",
381
+ "Class 'pepper' meets the maximum image requirement.\n",
382
+ "Class 'pineapple' meets the maximum image requirement.\n",
383
+ "Class 'pistachios' meets the maximum image requirement.\n",
384
+ "Class 'pork' meets the maximum image requirement.\n",
385
+ "Class 'potato' meets the maximum image requirement.\n",
386
+ "Class 'pumpkin' meets the maximum image requirement.\n",
387
+ "Class 'radishes' meets the maximum image requirement.\n",
388
+ "Class 'raisins' meets the maximum image requirement.\n",
389
+ "Class 'red_chilies' meets the maximum image requirement.\n",
390
+ "Class 'rice' meets the maximum image requirement.\n",
391
+ "Removed 8 images from 'rosemary' to meet the maximum of 50 images.\n",
392
+ "Removed 3 images from 'salmon' to meet the maximum of 50 images.\n",
393
+ "Removed 3 images from 'salt' to meet the maximum of 50 images.\n",
394
+ "Removed 9 images from 'shrimp' to meet the maximum of 50 images.\n",
395
+ "Removed 8 images from 'spinach' to meet the maximum of 50 images.\n",
396
+ "Removed 9 images from 'strawberries' to meet the maximum of 50 images.\n",
397
+ "Removed 8 images from 'sugar' to meet the maximum of 50 images.\n",
398
+ "Removed 9 images from 'sweet_potato' to meet the maximum of 50 images.\n",
399
+ "Removed 4 images from 'tomato' to meet the maximum of 50 images.\n",
400
+ "Removed 8 images from 'vanilla_ice_cream' to meet the maximum of 50 images.\n",
401
+ "Class 'walnuts' meets the maximum image requirement.\n",
402
+ "Class 'watermelon' meets the maximum image requirement.\n",
403
+ "Class 'yogurt' meets the maximum image requirement.\n",
404
+ "Image reduction completed.\n"
405
+ ]
406
+ }
407
+ ],
408
+ "source": [
409
+ "import random\n",
410
+ "\n",
411
+ "def remove_images_if_more_than(dataset_dir, max_images=50):\n",
412
+ " for class_name in os.listdir(dataset_dir):\n",
413
+ " class_dir = os.path.join(dataset_dir, class_name)\n",
414
+ " if os.path.isdir(class_dir):\n",
415
+ " images = [file for file in os.listdir(class_dir) if file.lower().endswith('.jpg')]\n",
416
+ " if len(images) > max_images:\n",
417
+ " images_to_remove = random.sample(images, len(images) - max_images)\n",
418
+ " for image in images_to_remove:\n",
419
+ " image_path = os.path.join(class_dir, image)\n",
420
+ " os.remove(image_path)\n",
421
+ " print(f\"Removed {len(images_to_remove)} images from '{class_name}' to meet the maximum of {max_images} images.\")\n",
422
+ " else:\n",
423
+ " print(f\"Class '{class_name}' meets the maximum image requirement.\")\n",
424
+ "\n",
425
+ "# Specify the path to your dataset directory\n",
426
+ "dataset_dir = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data'\n",
427
+ "remove_images_if_more_than(dataset_dir, 50)\n",
428
+ "\n",
429
+ "print(\"Image reduction completed.\")"
430
+ ]
431
+ },
432
+ {
433
+ "cell_type": "markdown",
434
+ "metadata": {},
435
+ "source": [
436
+ "- augemnet to make every class contains count of 50"
437
+ ]
438
+ },
439
+ {
440
+ "cell_type": "code",
441
+ "execution_count": 10,
442
+ "metadata": {},
443
+ "outputs": [
444
+ {
445
+ "name": "stdout",
446
+ "output_type": "stream",
447
+ "text": [
448
+ "Collecting imgaug\n",
449
+ " Downloading imgaug-0.4.0-py2.py3-none-any.whl.metadata (1.8 kB)\n",
450
+ "Requirement already satisfied: six in c:\\users\\kiyo\\appdata\\roaming\\python\\python312\\site-packages (from imgaug) (1.16.0)\n",
451
+ "Requirement already satisfied: numpy>=1.15 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (1.26.3)\n",
452
+ "Requirement already satisfied: scipy in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (1.12.0)\n",
453
+ "Requirement already satisfied: Pillow in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (10.2.0)\n",
454
+ "Requirement already satisfied: matplotlib in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (3.8.2)\n",
455
+ "Requirement already satisfied: scikit-image>=0.14.2 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (0.22.0)\n",
456
+ "Requirement already satisfied: opencv-python in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (4.9.0.80)\n",
457
+ "Requirement already satisfied: imageio in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (2.34.0)\n",
458
+ "Requirement already satisfied: Shapely in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from imgaug) (2.0.2)\n",
459
+ "Requirement already satisfied: networkx>=2.8 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from scikit-image>=0.14.2->imgaug) (3.2.1)\n",
460
+ "Requirement already satisfied: tifffile>=2022.8.12 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from scikit-image>=0.14.2->imgaug) (2024.2.12)\n",
461
+ "Requirement already satisfied: packaging>=21 in c:\\users\\kiyo\\appdata\\roaming\\python\\python312\\site-packages (from scikit-image>=0.14.2->imgaug) (23.2)\n",
462
+ "Requirement already satisfied: lazy_loader>=0.3 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from scikit-image>=0.14.2->imgaug) (0.3)\n",
463
+ "Requirement already satisfied: contourpy>=1.0.1 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from matplotlib->imgaug) (1.2.0)\n",
464
+ "Requirement already satisfied: cycler>=0.10 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from matplotlib->imgaug) (0.12.1)\n",
465
+ "Requirement already satisfied: fonttools>=4.22.0 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from matplotlib->imgaug) (4.47.2)\n",
466
+ "Requirement already satisfied: kiwisolver>=1.3.1 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from matplotlib->imgaug) (1.4.5)\n",
467
+ "Requirement already satisfied: pyparsing>=2.3.1 in c:\\users\\kiyo\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from matplotlib->imgaug) (3.1.1)\n",
468
+ "Requirement already satisfied: python-dateutil>=2.7 in c:\\users\\kiyo\\appdata\\roaming\\python\\python312\\site-packages (from matplotlib->imgaug) (2.8.2)\n",
469
+ "Downloading imgaug-0.4.0-py2.py3-none-any.whl (948 kB)\n",
470
+ " ---------------------------------------- 0.0/948.0 kB ? eta -:--:--\n",
471
+ " ---------------------------------------- 10.2/948.0 kB ? eta -:--:--\n",
472
+ " - ------------------------------------- 30.7/948.0 kB 660.6 kB/s eta 0:00:02\n",
473
+ " ------ --------------------------------- 153.6/948.0 kB 1.5 MB/s eta 0:00:01\n",
474
+ " ------------------------ --------------- 583.7/948.0 kB 4.6 MB/s eta 0:00:01\n",
475
+ " ---------------------------------------- 948.0/948.0 kB 5.0 MB/s eta 0:00:00\n",
476
+ "Installing collected packages: imgaug\n",
477
+ "Successfully installed imgaug-0.4.0\n"
478
+ ]
479
+ },
480
+ {
481
+ "name": "stderr",
482
+ "output_type": "stream",
483
+ "text": [
484
+ "DEPRECATION: celery 4.2.0 has a non-standard dependency specifier pytz>dev. pip 24.1 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of celery or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063\n"
485
+ ]
486
+ }
487
+ ],
488
+ "source": [
489
+ "!pip install imgaug\n"
490
+ ]
491
+ },
492
+ {
493
+ "cell_type": "code",
494
+ "execution_count": 19,
495
+ "metadata": {},
496
+ "outputs": [
497
+ {
498
+ "name": "stdout",
499
+ "output_type": "stream",
500
+ "text": [
501
+ "Completed augmentation for class 'all_purpose_flour'.\n",
502
+ "Completed augmentation for class 'almonds'.\n",
503
+ "Completed augmentation for class 'apple'.\n",
504
+ "Completed augmentation for class 'apricot'.\n",
505
+ "Completed augmentation for class 'asparagus'.\n",
506
+ "Completed augmentation for class 'avocado'.\n",
507
+ "Completed augmentation for class 'bacon'.\n",
508
+ "Completed augmentation for class 'banana'.\n",
509
+ "Completed augmentation for class 'barley'.\n",
510
+ "Completed augmentation for class 'basil'.\n",
511
+ "Completed augmentation for class 'basmati_rice'.\n",
512
+ "Completed augmentation for class 'beans'.\n",
513
+ "Completed augmentation for class 'beef'.\n",
514
+ "Completed augmentation for class 'beets'.\n",
515
+ "Completed augmentation for class 'bell_pepper'.\n",
516
+ "Completed augmentation for class 'berries'.\n",
517
+ "Completed augmentation for class 'biscuits'.\n",
518
+ "Completed augmentation for class 'blackberries'.\n",
519
+ "Completed augmentation for class 'black_pepper'.\n",
520
+ "Completed augmentation for class 'blueberries'.\n",
521
+ "Completed augmentation for class 'bread'.\n",
522
+ "Completed augmentation for class 'bread_crumbs'.\n",
523
+ "Completed augmentation for class 'bread_flour'.\n",
524
+ "Completed augmentation for class 'broccoli'.\n",
525
+ "Completed augmentation for class 'brownie_mix'.\n",
526
+ "Completed augmentation for class 'brown_rice'.\n",
527
+ "Completed augmentation for class 'butter'.\n",
528
+ "Completed augmentation for class 'cabbage'.\n",
529
+ "Completed augmentation for class 'cake'.\n",
530
+ "Completed augmentation for class 'cardamom'.\n",
531
+ "Completed augmentation for class 'carrot'.\n",
532
+ "Completed augmentation for class 'cashews'.\n",
533
+ "Completed augmentation for class 'cauliflower'.\n",
534
+ "Completed augmentation for class 'celery'.\n",
535
+ "Completed augmentation for class 'cereal'.\n",
536
+ "Completed augmentation for class 'cheese'.\n",
537
+ "Completed augmentation for class 'cherries'.\n",
538
+ "Completed augmentation for class 'chicken'.\n",
539
+ "Completed augmentation for class 'chickpeas'.\n",
540
+ "Completed augmentation for class 'chocolate'.\n",
541
+ "Completed augmentation for class 'chocolate_chips'.\n",
542
+ "Completed augmentation for class 'chocolate_syrup'.\n",
543
+ "Completed augmentation for class 'cilantro'.\n",
544
+ "Completed augmentation for class 'cinnamon'.\n",
545
+ "Completed augmentation for class 'clove'.\n",
546
+ "Completed augmentation for class 'cocoa_powder'.\n",
547
+ "Completed augmentation for class 'coconut'.\n",
548
+ "Completed augmentation for class 'cookies'.\n",
549
+ "Completed augmentation for class 'corn'.\n",
550
+ "Completed augmentation for class 'cucumber'.\n",
551
+ "Completed augmentation for class 'dates'.\n",
552
+ "Completed augmentation for class 'eggplant'.\n",
553
+ "Completed augmentation for class 'eggs'.\n",
554
+ "Completed augmentation for class 'fish'.\n",
555
+ "Completed augmentation for class 'garlic'.\n",
556
+ "Completed augmentation for class 'ginger'.\n",
557
+ "Completed augmentation for class 'grapes'.\n",
558
+ "Completed augmentation for class 'honey'.\n",
559
+ "Completed augmentation for class 'jalapeno'.\n",
560
+ "Completed augmentation for class 'kidney_beans'.\n",
561
+ "Completed augmentation for class 'lemon'.\n",
562
+ "Completed augmentation for class 'mango'.\n",
563
+ "Completed augmentation for class 'marshmallows'.\n",
564
+ "Completed augmentation for class 'milk'.\n",
565
+ "Completed augmentation for class 'mint'.\n",
566
+ "Completed augmentation for class 'muffins'.\n",
567
+ "Completed augmentation for class 'mushroom'.\n",
568
+ "Completed augmentation for class 'noodles'.\n",
569
+ "Completed augmentation for class 'nuts'.\n",
570
+ "Completed augmentation for class 'oats'.\n",
571
+ "Completed augmentation for class 'okra'.\n",
572
+ "Completed augmentation for class 'olive'.\n",
573
+ "Completed augmentation for class 'onion'.\n",
574
+ "Completed augmentation for class 'orange'.\n",
575
+ "Completed augmentation for class 'oreo_cookies'.\n",
576
+ "Completed augmentation for class 'pasta'.\n",
577
+ "Completed augmentation for class 'pear'.\n",
578
+ "Completed augmentation for class 'pepper'.\n",
579
+ "Completed augmentation for class 'pineapple'.\n",
580
+ "Completed augmentation for class 'pistachios'.\n",
581
+ "Completed augmentation for class 'pork'.\n",
582
+ "Completed augmentation for class 'potato'.\n",
583
+ "Completed augmentation for class 'pumpkin'.\n",
584
+ "Completed augmentation for class 'radishes'.\n",
585
+ "Completed augmentation for class 'raisins'.\n",
586
+ "Completed augmentation for class 'red_chilies'.\n",
587
+ "Completed augmentation for class 'rice'.\n",
588
+ "Completed augmentation for class 'rosemary'.\n",
589
+ "Completed augmentation for class 'salmon'.\n",
590
+ "Completed augmentation for class 'salt'.\n",
591
+ "Completed augmentation for class 'shrimp'.\n",
592
+ "Completed augmentation for class 'spinach'.\n",
593
+ "Completed augmentation for class 'strawberries'.\n",
594
+ "Completed augmentation for class 'sugar'.\n",
595
+ "Completed augmentation for class 'sweet_potato'.\n",
596
+ "Completed augmentation for class 'tomato'.\n",
597
+ "Completed augmentation for class 'vanilla_ice_cream'.\n",
598
+ "Completed augmentation for class 'walnuts'.\n",
599
+ "Completed augmentation for class 'watermelon'.\n",
600
+ "Completed augmentation for class 'yogurt'.\n",
601
+ "Dataset augmentation completed.\n"
602
+ ]
603
+ }
604
+ ],
605
+ "source": [
606
+ "import os\n",
607
+ "import random\n",
608
+ "from PIL import Image\n",
609
+ "import imgaug as ia\n",
610
+ "import imgaug.augmenters as iaa\n",
611
+ "import numpy as np\n",
612
+ "\n",
613
+ "ia.seed(1)\n",
614
+ "\n",
615
+ "def augment_image(image_path, save_dir, augmentation, img_count):\n",
616
+ " image = Image.open(image_path)\n",
617
+ " # Convert image to RGB if it's not already in that format\n",
618
+ " if image.mode != 'RGB':\n",
619
+ " image = image.convert('RGB')\n",
620
+ " image_np = np.array(image)\n",
621
+ " augmented_image_np = augmentation(image=image_np)\n",
622
+ " augmented_image = Image.fromarray(augmented_image_np)\n",
623
+ " base_name = os.path.basename(image_path)\n",
624
+ " new_image_path = os.path.join(save_dir, f\"{os.path.splitext(base_name)[0]}_aug_{img_count}.jpg\")\n",
625
+ " augmented_image.save(new_image_path)\n",
626
+ "\n",
627
+ "\n",
628
+ "def augment_class_images(class_dir, target_count=50):\n",
629
+ " images = [file for file in os.listdir(class_dir) if file.lower().endswith('.jpg')]\n",
630
+ " current_count = len(images)\n",
631
+ " \n",
632
+ " augmentation = iaa.Sequential([\n",
633
+ " iaa.Fliplr(0.5), # Horizontally flip 50% of the images\n",
634
+ " iaa.Crop(percent=(0, 0.1)), # Perform random crops\n",
635
+ " \n",
636
+ " # Apply affine transformations\n",
637
+ " iaa.Affine(\n",
638
+ " scale={\"x\": (0.8, 1.2), \"y\": (0.8, 1.2)},\n",
639
+ " translate_percent={\"x\": (-0.2, 0.2), \"y\": (-0.2, 0.2)},\n",
640
+ " rotate=(-25, 25),\n",
641
+ " shear=(-8, 8)\n",
642
+ " ),\n",
643
+ " \n",
644
+ " # Adjust brightness and contrast\n",
645
+ " iaa.Multiply((0.8, 1.2)), # Change brightness (80-120% of original value)\n",
646
+ " iaa.LinearContrast((0.75, 1.5)), # Strengthen or weaken the contrast in each image.\n",
647
+ " \n",
648
+ " # Apply color temperature changes\n",
649
+ " iaa.Sequential([\n",
650
+ " iaa.ChangeColorTemperature((1100, 10000)), # Simulate different color temperatures\n",
651
+ " iaa.WithChannels(0, iaa.Add((10, 100))) # Optionally, add more red for warmth\n",
652
+ " ], random_order=True) # Apply these changes in a random order\n",
653
+ " ])\n",
654
+ " \n",
655
+ " if current_count < target_count:\n",
656
+ " while current_count < target_count:\n",
657
+ " for img_file in random.sample(images, min(len(images), target_count - current_count)):\n",
658
+ " augment_image(os.path.join(class_dir, img_file), class_dir, augmentation, current_count)\n",
659
+ " current_count += 1\n",
660
+ " if current_count >= target_count:\n",
661
+ " break\n",
662
+ "\n",
663
+ "def augment_dataset_if_needed(dataset_dir, target_count=50):\n",
664
+ " for class_name in os.listdir(dataset_dir):\n",
665
+ " class_dir = os.path.join(dataset_dir, class_name)\n",
666
+ " if os.path.isdir(class_dir):\n",
667
+ " augment_class_images(class_dir, target_count)\n",
668
+ " print(f\"Completed augmentation for class '{class_name}'.\")\n",
669
+ "\n",
670
+ "# Specify the path to your dataset directory\n",
671
+ "dataset_dir = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data'\n",
672
+ "augment_dataset_if_needed(dataset_dir, 50)\n",
673
+ "\n",
674
+ "print(\"Dataset augmentation completed.\")\n"
675
+ ]
676
+ }
677
+ ],
678
+ "metadata": {
679
+ "kernelspec": {
680
+ "display_name": "Python 3",
681
+ "language": "python",
682
+ "name": "python3"
683
+ },
684
+ "language_info": {
685
+ "codemirror_mode": {
686
+ "name": "ipython",
687
+ "version": 3
688
+ },
689
+ "file_extension": ".py",
690
+ "mimetype": "text/x-python",
691
+ "name": "python",
692
+ "nbconvert_exporter": "python",
693
+ "pygments_lexer": "ipython3",
694
+ "version": "3.12.1"
695
+ }
696
+ },
697
+ "nbformat": 4,
698
+ "nbformat_minor": 2
699
+ }
automating_annotation.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
correction_for_augmented data.ipynb ADDED
@@ -0,0 +1,567 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "### Check for the corrections in the augmented data"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 2,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "\n",
17
+ "import os\n"
18
+ ]
19
+ },
20
+ {
21
+ "cell_type": "code",
22
+ "execution_count": 3,
23
+ "metadata": {},
24
+ "outputs": [
25
+ {
26
+ "name": "stdout",
27
+ "output_type": "stream",
28
+ "text": [
29
+ "Class 'all_purpose_flour_annotated': Perfect\n",
30
+ "Class 'almonds_annotated': Perfect\n",
31
+ "Class 'apple_annotated': Perfect\n",
32
+ "Class 'apricot_annotated': Perfect\n",
33
+ "Class 'asparagus_annotated': Perfect\n",
34
+ "Class 'avocado_annotated': Perfect\n",
35
+ "Class 'bacon_annotated': Perfect\n",
36
+ "Class 'banana_annotated': Perfect\n",
37
+ "Class 'barley_annotated': Perfect\n",
38
+ "Class 'basil_annotated': Perfect\n",
39
+ "Class 'basmati_rice_annotated': Perfect\n",
40
+ "Class 'beans_annotated': Perfect\n",
41
+ "Class 'beef_annotated': Perfect\n",
42
+ "Class 'beets_annotated': Perfect\n",
43
+ "Class 'bell_pepper_annotated': Perfect\n",
44
+ "Class 'berries_annotated': Perfect\n",
45
+ "Class 'biscuits_annotated': Perfect\n",
46
+ "Class 'blackberries_annotated': Perfect\n",
47
+ "Class 'black_pepper_annotated': Perfect\n",
48
+ "Class 'blueberries_annotated': Perfect\n",
49
+ "Class 'bread_annotated': Perfect\n",
50
+ "Class 'bread_crumbs_annotated': Perfect\n",
51
+ "Class 'bread_flour_annotated': Perfect\n",
52
+ "Class 'broccoli_annotated': Perfect\n",
53
+ "Class 'brownie_mix_annotated': Perfect\n",
54
+ "Class 'brown_rice_annotated': Perfect\n",
55
+ "Class 'butter_annotated': Perfect\n",
56
+ "Class 'cabbage_annotated': Perfect\n",
57
+ "Class 'cake_annotated': Perfect\n",
58
+ "Class 'cardamom_annotated': Perfect\n",
59
+ "Class 'carrot_annotated': Perfect\n",
60
+ "Class 'cashews_annotated': Perfect\n",
61
+ "Class 'cauliflower_annotated': Perfect\n",
62
+ "Class 'celery_annotated': Perfect\n",
63
+ "Class 'cereal_annotated': Perfect\n",
64
+ "Class 'cheese_annotated': Perfect\n",
65
+ "Class 'cherries_annotated': Perfect\n",
66
+ "Class 'chicken_annotated': Perfect\n",
67
+ "Class 'chickpeas_annotated': Perfect\n",
68
+ "Class 'chocolate_annotated': Perfect\n",
69
+ "Class 'chocolate_chips_annotated': Perfect\n",
70
+ "Class 'chocolate_syrup_annotated': Perfect\n",
71
+ "Class 'cilantro_annotated': Perfect\n",
72
+ "Class 'cinnamon_annotated': Perfect\n",
73
+ "Class 'clove_annotated': Perfect\n",
74
+ "Class 'cocoa_powder_annotated': Perfect\n",
75
+ "Class 'coconut_annotated': Perfect\n",
76
+ "Class 'cookies_annotated': Perfect\n",
77
+ "Class 'corn_annotated': Perfect\n",
78
+ "Class 'cucumber_annotated': Perfect\n",
79
+ "Class 'dates_annotated': Perfect\n",
80
+ "Class 'eggplant_annotated': Perfect\n",
81
+ "Class 'eggs_annotated': Perfect\n",
82
+ "Class 'fish_annotated': Perfect\n",
83
+ "Class 'garlic_annotated': Perfect\n",
84
+ "Class 'ginger_annotated': Perfect\n",
85
+ "Class 'grapes_annotated': Perfect\n",
86
+ "Class 'honey_annotated': Perfect\n",
87
+ "Class 'jalapeno_annotated': Perfect\n",
88
+ "Class 'kidney_beans_annotated': Perfect\n",
89
+ "Class 'lemon_annotated': Perfect\n",
90
+ "Class 'mango_annotated': Perfect\n",
91
+ "Class 'marshmallows_annotated': Perfect\n",
92
+ "Class 'milk_annotated': Perfect\n",
93
+ "Class 'mint_annotated': Perfect\n",
94
+ "Class 'muffins_annotated': Perfect\n",
95
+ "Class 'mushroom_annotated': Perfect\n",
96
+ "Class 'noodles_annotated': Perfect\n",
97
+ "Class 'nuts_annotated': Perfect\n",
98
+ "Class 'oats_annotated': Perfect\n",
99
+ "Class 'okra_annotated': Perfect\n",
100
+ "Class 'olive_annotated': Perfect\n",
101
+ "Class 'onion_annotated': Perfect\n",
102
+ "Class 'orange_annotated': Perfect\n",
103
+ "Class 'oreo_cookies_annotated': Perfect\n",
104
+ "Class 'pasta_annotated': Perfect\n",
105
+ "Class 'pear_annotated': Perfect\n",
106
+ "Class 'pepper_annotated': Perfect\n",
107
+ "Class 'pineapple_annotated': Perfect\n",
108
+ "Class 'pistachios_annotated': Perfect\n",
109
+ "Class 'pork_annotated': Perfect\n",
110
+ "Class 'potato_annotated': Perfect\n",
111
+ "Class 'pumpkin_annotated': Perfect\n",
112
+ "Class 'radishes_annotated': Perfect\n",
113
+ "Class 'raisins_annotated': Perfect\n",
114
+ "Class 'red_chilies_annotated': Discrepancies Found\n",
115
+ " Missing JPG files for: Image_21\n",
116
+ " Non-JPG/XML files: Image_21.JPG\n",
117
+ "Class 'rice_annotated': Discrepancies Found\n",
118
+ " Missing JPG files for: Image_30\n",
119
+ " Non-JPG/XML files: Image_30.JPG\n",
120
+ "Class 'rosemary_annotated': Discrepancies Found\n",
121
+ " Missing JPG files for: Image_26\n",
122
+ " Non-JPG/XML files: Image_26.JPG\n",
123
+ "Class 'salmon_annotated': Perfect\n",
124
+ "Class 'salt_annotated': Perfect\n",
125
+ "Class 'shrimp_annotated': Discrepancies Found\n",
126
+ " Missing JPG files for: Image_16, Image_17\n",
127
+ " Non-JPG/XML files: Image_16.JPG, Image_17.JPG\n",
128
+ "Class 'spinach_annotated': Discrepancies Found\n",
129
+ " Missing JPG files for: Image_27\n",
130
+ " Non-JPG/XML files: Image_27.JPG\n",
131
+ "Class 'strawberries_annotated': Discrepancies Found\n",
132
+ " Missing JPG files for: Image_10, Image_20\n",
133
+ " Non-JPG/XML files: Image_10.JPG, Image_20.JPG\n",
134
+ "Class 'sugar_annotated': Perfect\n",
135
+ "Class 'sweet_potato_annotated': Discrepancies Found\n",
136
+ " Missing JPG files for: Image_15, Image_21\n",
137
+ " Non-JPG/XML files: Image_15.JPG, Image_21.JPG\n",
138
+ "Class 'tomato_annotated': Perfect\n",
139
+ "Class 'vanilla_ice_cream_annotated': Discrepancies Found\n",
140
+ " Missing JPG files for: Image_12, Image_15, Image_17, Image_20\n",
141
+ " Non-JPG/XML files: Image_12.JPG, Image_15.JPG, Image_17.JPG, Image_20.JPG\n",
142
+ "Class 'walnuts_annotated': Perfect\n",
143
+ "Class 'watermelon_annotated': Perfect\n",
144
+ "Class 'yogurt_annotated': Perfect\n"
145
+ ]
146
+ }
147
+ ],
148
+ "source": [
149
+ "\n",
150
+ "\n",
151
+ "def check_dataset_integrity(dataset_directory):\n",
152
+ " for class_name in os.listdir(dataset_directory):\n",
153
+ " class_path = os.path.join(dataset_directory, class_name)\n",
154
+ " if os.path.isdir(class_path):\n",
155
+ " jpg_files = set()\n",
156
+ " xml_files = set()\n",
157
+ " other_files = set()\n",
158
+ "\n",
159
+ " # Collect file names for each extension\n",
160
+ " for file_name in os.listdir(class_path):\n",
161
+ " if file_name.endswith('.jpg'):\n",
162
+ " jpg_files.add(os.path.splitext(file_name)[0])\n",
163
+ " elif file_name.endswith('.xml'):\n",
164
+ " xml_files.add(os.path.splitext(file_name)[0])\n",
165
+ " else:\n",
166
+ " other_files.add(file_name)\n",
167
+ "\n",
168
+ " # Check for discrepancies\n",
169
+ " missing_xmls = jpg_files - xml_files\n",
170
+ " missing_jpgs = xml_files - jpg_files\n",
171
+ " is_perfect = len(missing_xmls) == 0 and len(missing_jpgs) == 0 and len(other_files) == 0\n",
172
+ "\n",
173
+ " # Report\n",
174
+ " print(f\"Class '{class_name}':\", \"Perfect\" if is_perfect else \"Discrepancies Found\")\n",
175
+ " if missing_xmls:\n",
176
+ " print(f\" Missing XML files for: {', '.join(sorted(missing_xmls))}\")\n",
177
+ " if missing_jpgs:\n",
178
+ " print(f\" Missing JPG files for: {', '.join(sorted(missing_jpgs))}\")\n",
179
+ " if other_files:\n",
180
+ " print(f\" Non-JPG/XML files: {', '.join(sorted(other_files))}\")\n",
181
+ " else:\n",
182
+ " print(f\"'{class_name}' is not a directory. Skipping.\")\n",
183
+ "\n",
184
+ "# Specify the path to the dataset directory\n",
185
+ "dataset_directory = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated'\n",
186
+ "check_dataset_integrity(dataset_directory)\n"
187
+ ]
188
+ },
189
+ {
190
+ "cell_type": "code",
191
+ "execution_count": 4,
192
+ "metadata": {},
193
+ "outputs": [],
194
+ "source": [
195
+ "import os\n",
196
+ "\n",
197
+ "def count_files_in_classes(dataset_directory):\n",
198
+ " # Iterate over all items in dataset_directory\n",
199
+ " for item in os.listdir(dataset_directory):\n",
200
+ " item_path = os.path.join(dataset_directory, item)\n",
201
+ " # Check if the item is a directory\n",
202
+ " if os.path.isdir(item_path):\n",
203
+ " # List all files in the directory\n",
204
+ " files = [f for f in os.listdir(item_path) if os.path.isfile(os.path.join(item_path, f))]\n",
205
+ " # Print the count of files\n",
206
+ " if len(files) < 100:\n",
207
+ " print(f\"{item}: {len(files)} files\")\n",
208
+ "\n",
209
+ "dataset_directory = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated'\n",
210
+ "count_files_in_classes(dataset_directory)\n"
211
+ ]
212
+ },
213
+ {
214
+ "cell_type": "code",
215
+ "execution_count": 5,
216
+ "metadata": {},
217
+ "outputs": [
218
+ {
219
+ "name": "stdout",
220
+ "output_type": "stream",
221
+ "text": [
222
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\all_purpose_flour_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\all_purpose_flour'.\n",
223
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\almonds_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\almonds'.\n",
224
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\apple_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\apple'.\n",
225
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\apricot_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\apricot'.\n",
226
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\asparagus_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\asparagus'.\n",
227
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\avocado_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\avocado'.\n",
228
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bacon_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bacon'.\n",
229
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\banana_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\banana'.\n",
230
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\barley_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\barley'.\n",
231
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\basil_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\basil'.\n",
232
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\basmati_rice_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\basmati_rice'.\n",
233
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\beans_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\beans'.\n",
234
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\beef_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\beef'.\n",
235
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\beets_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\beets'.\n",
236
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bell_pepper_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bell_pepper'.\n",
237
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\berries_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\berries'.\n",
238
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\biscuits_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\biscuits'.\n",
239
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\blackberries_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\blackberries'.\n",
240
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\black_pepper_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\black_pepper'.\n",
241
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\blueberries_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\blueberries'.\n",
242
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bread_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bread'.\n",
243
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bread_crumbs_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bread_crumbs'.\n",
244
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bread_flour_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\bread_flour'.\n",
245
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\broccoli_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\broccoli'.\n",
246
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\brownie_mix_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\brownie_mix'.\n",
247
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\brown_rice_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\brown_rice'.\n",
248
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\butter_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\butter'.\n",
249
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cabbage_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cabbage'.\n",
250
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cake_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cake'.\n",
251
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cardamom_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cardamom'.\n",
252
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\carrot_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\carrot'.\n",
253
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cashews_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cashews'.\n",
254
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cauliflower_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cauliflower'.\n",
255
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\celery_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\celery'.\n",
256
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cereal_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cereal'.\n",
257
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cheese_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cheese'.\n",
258
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cherries_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cherries'.\n",
259
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chicken_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chicken'.\n",
260
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chickpeas_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chickpeas'.\n",
261
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chocolate_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chocolate'.\n",
262
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chocolate_chips_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chocolate_chips'.\n",
263
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chocolate_syrup_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\chocolate_syrup'.\n",
264
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cilantro_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cilantro'.\n",
265
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cinnamon_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cinnamon'.\n",
266
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\clove_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\clove'.\n",
267
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cocoa_powder_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cocoa_powder'.\n",
268
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\coconut_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\coconut'.\n",
269
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cookies_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cookies'.\n",
270
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\corn_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\corn'.\n",
271
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cucumber_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\cucumber'.\n",
272
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\dates_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\dates'.\n",
273
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\eggplant_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\eggplant'.\n",
274
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\eggs_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\eggs'.\n",
275
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\fish_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\fish'.\n",
276
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\garlic_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\garlic'.\n",
277
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\ginger_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\ginger'.\n",
278
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\grapes_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\grapes'.\n",
279
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\honey_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\honey'.\n",
280
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\jalapeno_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\jalapeno'.\n",
281
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\kidney_beans_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\kidney_beans'.\n",
282
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\lemon_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\lemon'.\n",
283
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\mango_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\mango'.\n",
284
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\marshmallows_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\marshmallows'.\n",
285
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\milk_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\milk'.\n",
286
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\mint_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\mint'.\n",
287
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\muffins_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\muffins'.\n",
288
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\mushroom_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\mushroom'.\n",
289
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\noodles_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\noodles'.\n",
290
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\nuts_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\nuts'.\n",
291
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\oats_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\oats'.\n",
292
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\okra_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\okra'.\n",
293
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\olive_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\olive'.\n",
294
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\onion_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\onion'.\n",
295
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\orange_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\orange'.\n",
296
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\oreo_cookies_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\oreo_cookies'.\n",
297
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pasta_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pasta'.\n",
298
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pear_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pear'.\n",
299
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pepper_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pepper'.\n",
300
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pineapple_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pineapple'.\n",
301
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pistachios_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pistachios'.\n",
302
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pork_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pork'.\n",
303
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\potato_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\potato'.\n",
304
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pumpkin_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\pumpkin'.\n",
305
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\radishes_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\radishes'.\n",
306
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\raisins_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\raisins'.\n",
307
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\red_chilies_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\red_chilies'.\n",
308
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\rice_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\rice'.\n",
309
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\rosemary_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\rosemary'.\n",
310
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\salmon_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\salmon'.\n",
311
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\salt_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\salt'.\n",
312
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\shrimp_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\shrimp'.\n",
313
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\spinach_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\spinach'.\n",
314
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\strawberries_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\strawberries'.\n",
315
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\sugar_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\sugar'.\n",
316
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\sweet_potato_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\sweet_potato'.\n",
317
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\tomato_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\tomato'.\n",
318
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\vanilla_ice_cream_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\vanilla_ice_cream'.\n",
319
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\walnuts_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\walnuts'.\n",
320
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\watermelon_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\watermelon'.\n",
321
+ "Renamed 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\yogurt_annotated' to 'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated\\yogurt'.\n",
322
+ "Directory renaming completed.\n"
323
+ ]
324
+ }
325
+ ],
326
+ "source": [
327
+ "def rename_directories(base_dir):\n",
328
+ " for dirname in os.listdir(base_dir):\n",
329
+ " if dirname.endswith('_annotated'):\n",
330
+ " original_dir_path = os.path.join(base_dir, dirname)\n",
331
+ " new_dirname = dirname.replace('_annotated', '')\n",
332
+ " new_dir_path = os.path.join(base_dir, new_dirname)\n",
333
+ " \n",
334
+ " # Check if the target directory already exists\n",
335
+ " if os.path.exists(new_dir_path):\n",
336
+ " print(f\"Target directory '{new_dir_path}' already exists. Skipping '{dirname}'.\")\n",
337
+ " continue\n",
338
+ " \n",
339
+ " os.rename(original_dir_path, new_dir_path)\n",
340
+ " print(f\"Renamed '{original_dir_path}' to '{new_dir_path}'.\")\n",
341
+ "\n",
342
+ "# Specify the base directory containing the class directories to be renamed\n",
343
+ "base_dir = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated'\n",
344
+ "rename_directories(base_dir)\n",
345
+ "\n",
346
+ "print(\"Directory renaming completed.\")\n"
347
+ ]
348
+ },
349
+ {
350
+ "cell_type": "code",
351
+ "execution_count": 7,
352
+ "metadata": {},
353
+ "outputs": [
354
+ {
355
+ "name": "stdout",
356
+ "output_type": "stream",
357
+ "text": [
358
+ "Class 'all_purpose_flour': Perfect\n",
359
+ "Class 'almonds': Perfect\n",
360
+ "Class 'apple': Perfect\n",
361
+ "Class 'apricot': Perfect\n",
362
+ "Class 'asparagus': Perfect\n",
363
+ "Class 'avocado': Perfect\n",
364
+ "Class 'bacon': Perfect\n",
365
+ "Class 'banana': Perfect\n",
366
+ "Class 'barley': Perfect\n",
367
+ "Class 'basil': Perfect\n",
368
+ "Class 'basmati_rice': Perfect\n",
369
+ "Class 'beans': Perfect\n",
370
+ "Class 'beef': Perfect\n",
371
+ "Class 'beets': Perfect\n",
372
+ "Class 'bell_pepper': Perfect\n",
373
+ "Class 'berries': Perfect\n",
374
+ "Class 'biscuits': Perfect\n",
375
+ "Class 'blackberries': Perfect\n",
376
+ "Class 'black_pepper': Perfect\n",
377
+ "Class 'blueberries': Perfect\n",
378
+ "Class 'bread': Perfect\n",
379
+ "Class 'bread_crumbs': Perfect\n",
380
+ "Class 'bread_flour': Perfect\n",
381
+ "Class 'broccoli': Perfect\n",
382
+ "Class 'brownie_mix': Perfect\n",
383
+ "Class 'brown_rice': Perfect\n",
384
+ "Class 'butter': Perfect\n",
385
+ "Class 'cabbage': Perfect\n",
386
+ "Class 'cake': Perfect\n",
387
+ "Class 'cardamom': Perfect\n",
388
+ "Class 'carrot': Perfect\n",
389
+ "Class 'cashews': Perfect\n",
390
+ "Class 'cauliflower': Perfect\n",
391
+ "Class 'celery': Perfect\n",
392
+ "Class 'cereal': Perfect\n",
393
+ "Class 'cheese': Perfect\n",
394
+ "Class 'cherries': Perfect\n",
395
+ "Class 'chicken': Perfect\n",
396
+ "Class 'chickpeas': Perfect\n",
397
+ "Class 'chocolate': Perfect\n",
398
+ "Class 'chocolate_chips': Perfect\n",
399
+ "Class 'chocolate_syrup': Perfect\n",
400
+ "Class 'cilantro': Perfect\n",
401
+ "Class 'cinnamon': Perfect\n",
402
+ "Class 'clove': Perfect\n",
403
+ "Class 'cocoa_powder': Perfect\n",
404
+ "Class 'coconut': Perfect\n",
405
+ "Class 'cookies': Perfect\n",
406
+ "Class 'corn': Perfect\n",
407
+ "Class 'cucumber': Perfect\n",
408
+ "Class 'dates': Perfect\n",
409
+ "Class 'eggplant': Perfect\n",
410
+ "Class 'eggs': Perfect\n",
411
+ "Class 'fish': Perfect\n",
412
+ "Class 'garlic': Perfect\n",
413
+ "Class 'ginger': Perfect\n",
414
+ "Class 'grapes': Perfect\n",
415
+ "Class 'honey': Perfect\n",
416
+ "Class 'jalapeno': Perfect\n",
417
+ "Class 'kidney_beans': Perfect\n",
418
+ "Class 'lemon': Perfect\n",
419
+ "Class 'mango': Perfect\n",
420
+ "Class 'marshmallows': Perfect\n",
421
+ "Class 'milk': Perfect\n",
422
+ "Class 'mint': Perfect\n",
423
+ "Class 'muffins': Perfect\n",
424
+ "Class 'mushroom': Perfect\n",
425
+ "Class 'noodles': Perfect\n",
426
+ "Class 'nuts': Perfect\n",
427
+ "Class 'oats': Perfect\n",
428
+ "Class 'okra': Perfect\n",
429
+ "Class 'olive': Perfect\n",
430
+ "Class 'onion': Perfect\n",
431
+ "Class 'orange': Perfect\n",
432
+ "Class 'oreo_cookies': Perfect\n",
433
+ "Class 'pasta': Perfect\n",
434
+ "Class 'pear': Perfect\n",
435
+ "Class 'pepper': Perfect\n",
436
+ "Class 'pineapple': Perfect\n",
437
+ "Class 'pistachios': Perfect\n",
438
+ "Class 'pork': Perfect\n",
439
+ "Class 'potato': Perfect\n",
440
+ "Class 'pumpkin': Perfect\n",
441
+ "Class 'radishes': Perfect\n",
442
+ "Class 'raisins': Perfect\n",
443
+ "Class 'red_chilies': Perfect\n",
444
+ "Class 'rice': Perfect\n",
445
+ "Class 'rosemary': Perfect\n",
446
+ "Class 'salmon': Perfect\n",
447
+ "Class 'salt': Perfect\n",
448
+ "Class 'shrimp': Perfect\n",
449
+ "Class 'spinach': Perfect\n",
450
+ "Class 'strawberries': Perfect\n",
451
+ "Class 'sugar': Perfect\n",
452
+ "Class 'sweet_potato': Perfect\n",
453
+ "Class 'tomato': Perfect\n",
454
+ "Class 'vanilla_ice_cream': Perfect\n",
455
+ "Class 'walnuts': Perfect\n",
456
+ "Class 'watermelon': Perfect\n",
457
+ "Class 'yogurt': Perfect\n"
458
+ ]
459
+ }
460
+ ],
461
+ "source": [
462
+ "\n",
463
+ "\n",
464
+ "def check_dataset_integrity(dataset_directory):\n",
465
+ " for class_name in os.listdir(dataset_directory):\n",
466
+ " class_path = os.path.join(dataset_directory, class_name)\n",
467
+ " if os.path.isdir(class_path):\n",
468
+ " jpg_files = set()\n",
469
+ " xml_files = set()\n",
470
+ " other_files = set()\n",
471
+ "\n",
472
+ " # Collect file names for each extension\n",
473
+ " for file_name in os.listdir(class_path):\n",
474
+ " if file_name.endswith('.jpg'):\n",
475
+ " jpg_files.add(os.path.splitext(file_name)[0])\n",
476
+ " elif file_name.endswith('.xml'):\n",
477
+ " xml_files.add(os.path.splitext(file_name)[0])\n",
478
+ " else:\n",
479
+ " other_files.add(file_name)\n",
480
+ "\n",
481
+ " # Check for discrepancies\n",
482
+ " missing_xmls = jpg_files - xml_files\n",
483
+ " missing_jpgs = xml_files - jpg_files\n",
484
+ " is_perfect = len(missing_xmls) == 0 and len(missing_jpgs) == 0 and len(other_files) == 0\n",
485
+ "\n",
486
+ " # Report\n",
487
+ " print(f\"Class '{class_name}':\", \"Perfect\" if is_perfect else \"Discrepancies Found\")\n",
488
+ " if missing_xmls:\n",
489
+ " print(f\" Missing XML files for: {', '.join(sorted(missing_xmls))}\")\n",
490
+ " if missing_jpgs:\n",
491
+ " print(f\" Missing JPG files for: {', '.join(sorted(missing_jpgs))}\")\n",
492
+ " if other_files:\n",
493
+ " print(f\" Non-JPG/XML files: {', '.join(sorted(other_files))}\")\n",
494
+ " else:\n",
495
+ " print(f\"'{class_name}' is not a directory. Skipping.\")\n",
496
+ "\n",
497
+ "# Specify the path to the dataset directory\n",
498
+ "dataset_directory = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated'\n",
499
+ "check_dataset_integrity(dataset_directory)\n"
500
+ ]
501
+ },
502
+ {
503
+ "cell_type": "code",
504
+ "execution_count": 6,
505
+ "metadata": {},
506
+ "outputs": [
507
+ {
508
+ "name": "stdout",
509
+ "output_type": "stream",
510
+ "text": [
511
+ "All class names from 'Final_classes.txt' match the dataset directories perfectly.\n"
512
+ ]
513
+ }
514
+ ],
515
+ "source": [
516
+ "import os\n",
517
+ "\n",
518
+ "# Path to the directory containing the class directories\n",
519
+ "dataset_dir = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\initial_data_annotated'\n",
520
+ "\n",
521
+ "# Path to the file containing the final class names\n",
522
+ "classes_file = r'C:\\Users\\Kiyo\\Desktop\\DL\\Project\\image_data\\Final_classes.txt'\n",
523
+ "\n",
524
+ "# Load class names from file\n",
525
+ "with open(classes_file, 'r') as f:\n",
526
+ " class_names = {line.strip() for line in f}\n",
527
+ "\n",
528
+ "# List directory names in the dataset\n",
529
+ "dataset_dirs = {d for d in os.listdir(dataset_dir) if os.path.isdir(os.path.join(dataset_dir, d))}\n",
530
+ "\n",
531
+ "# Find discrepancies\n",
532
+ "missing_dirs = class_names - dataset_dirs\n",
533
+ "extra_dirs = dataset_dirs - class_names\n",
534
+ "\n",
535
+ "# Report results\n",
536
+ "if not missing_dirs and not extra_dirs:\n",
537
+ " print(\"All class names from 'Final_classes.txt' match the dataset directories perfectly.\")\n",
538
+ "else:\n",
539
+ " if missing_dirs:\n",
540
+ " print(f\"Missing directories for these classes: {', '.join(sorted(missing_dirs))}\")\n",
541
+ " if extra_dirs:\n",
542
+ " print(f\"Extra directories in the dataset not listed in 'Final_classes.txt': {', '.join(sorted(extra_dirs))}\")\n"
543
+ ]
544
+ }
545
+ ],
546
+ "metadata": {
547
+ "kernelspec": {
548
+ "display_name": "Python 3",
549
+ "language": "python",
550
+ "name": "python3"
551
+ },
552
+ "language_info": {
553
+ "codemirror_mode": {
554
+ "name": "ipython",
555
+ "version": 3
556
+ },
557
+ "file_extension": ".py",
558
+ "mimetype": "text/x-python",
559
+ "name": "python",
560
+ "nbconvert_exporter": "python",
561
+ "pygments_lexer": "ipython3",
562
+ "version": "3.12.1"
563
+ }
564
+ },
565
+ "nbformat": 4,
566
+ "nbformat_minor": 2
567
+ }