summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-08-21 17:50:49 -0600
committerHombreLaser <sebastian-440@live.com>2023-08-21 17:50:49 -0600
commite30eeba4e1b230a0fced7af6161d41fa21a7d4f4 (patch)
treee41d0376f19028908b539e473541fad7343a7e69
parent4c35c2a17299c6327d356e0a6abb618488475585 (diff)
Add DatasetUtils class
-rw-r--r--dataset_utils.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/dataset_utils.py b/dataset_utils.py
new file mode 100644
index 0000000..865d5be
--- /dev/null
+++ b/dataset_utils.py
@@ -0,0 +1,28 @@
+import numpy
+from PIL import Image
+from pathlib import Path
+
+"""Class to interface the training and testing data."""
+class DatasetUtils:
+ def __init__(self) -> None:
+ self.data_path = Path('./data')
+ # self.current_directory = 'I'
+
+ """Convert the dataset to a 2 dimension array."""
+ def data_to_arrays(self):
+ for dir in self.data_path.iterdir():
+ if not dir.is_dir(): continue
+
+ for file in dir.glob('/*.png'):
+ image = Image.open(str(file)).convert(mode='L')
+ # Return the image's pixel values as an array alongside
+ # the character that it represents.
+ yield (dir.name, numpy.asarray(image))
+
+ """Search for a file in the dataset."""
+ def search(self, filename: str):
+ dataset = [image for image in self.data_path.rglob('*.png')]
+
+
+ def get_random_sample(self):
+ pass