Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

data.py 1.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  1. # -*- coding: utf-8 -*-
  2. """Data Loader"""
  3. from tensorflow.keras.preprocessing.image import ImageDataGenerator
  4. class DataLoader():
  5. """Data Loader class"""
  6. def __init__(self):
  7. super().__init__()
  8. def load_train_data(self,path):
  9. """Loads dataset from path"""
  10. self.train_datagen = ImageDataGenerator(rescale=1./255, validation_split=0.1)
  11. return self.train_datagen.flow_from_directory(
  12. path,
  13. subset='training',
  14. target_size=(48,48),
  15. batch_size=64,
  16. color_mode="grayscale",
  17. class_mode='categorical')
  18. def load_val_data(self,path):
  19. """Loads dataset from path"""
  20. self.train_datagen = ImageDataGenerator(rescale=1./255, validation_split=0.1)
  21. return self.train_datagen.flow_from_directory(
  22. path,
  23. subset='validation',
  24. target_size=(48,48),
  25. batch_size=64,
  26. color_mode="grayscale",
  27. class_mode='categorical')
  28. def load_test_data(self,path):
  29. """Loads dataset from path"""
  30. self.test_datagen = ImageDataGenerator(rescale=1./255)
  31. return self.test_datagen.flow_from_directory(
  32. path,
  33. target_size=(48,48),
  34. batch_size=64,
  35. color_mode="grayscale",
  36. class_mode='categorical')
  37. if __name__ == "__main__":
  38. data_model = DataLoader()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...