Spaces:
Running
Running
Download preprocess.py from Aditya150/Veritas-AI: direct link, hf CLI and curl.
- Browser
- Download file 816 Bytes
-
https://huggingface.co/spaces/Aditya150/Veritas-AI/resolve/main/preprocess.py
- Command line
-
hf download hf://spaces/Aditya150/Veritas-AI/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/spaces/Aditya150/Veritas-AI/resolve/main/preprocess.py
816 Bytes
| import tensorflow as tf | |
| IMG_SIZE = (224, 224) | |
| BATCH_SIZE = 16 | |
| TRAIN_DIR = "dataset/train" | |
| VAL_DIR = "dataset/validation" | |
| TEST_DIR = "dataset/test" | |
| def load_datasets(): | |
| train_ds = tf.keras.preprocessing.image_dataset_from_directory( | |
| TRAIN_DIR, | |
| image_size=IMG_SIZE, | |
| batch_size=BATCH_SIZE, | |
| label_mode="binary", | |
| shuffle=True | |
| ) | |
| val_ds = tf.keras.preprocessing.image_dataset_from_directory( | |
| VAL_DIR, | |
| image_size=IMG_SIZE, | |
| batch_size=BATCH_SIZE, | |
| label_mode="binary", | |
| shuffle=False | |
| ) | |
| test_ds = tf.keras.preprocessing.image_dataset_from_directory( | |
| TEST_DIR, | |
| image_size=IMG_SIZE, | |
| batch_size=BATCH_SIZE, | |
| label_mode="binary", | |
| shuffle=False | |
| ) | |
| return train_ds, val_ds, test_ds | |