automatyczny_kelner/Network.py

45 lines
1.0 KiB
Python
Raw Normal View History

2023-06-01 20:15:18 +02:00
import tensorflow as tf
from keras import layers
from keras.models import Sequential
from keras.optimizers import Adam
from keras.utils import to_categorical
from keras.preprocessing.image import ImageDataGenerator
import os
import PIL
import PIL.Image
import numpy
# Set the paths to the folders containing the training data
train_data_dir = "Training/"
validation_data_dir = "Validation/"
# Set the number of classes and batch size
num_classes = 3
batch_size = 32
# Set the image size and input shape
img_width, img_height = 100, 100
input_shape = (img_width, img_height, 3)
train_ds = tf.keras.utils.image_dataset_from_directory(
train_data_dir,
validation_split=0.2,
subset="training",
shuffle=True,
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
val_ds = tf.keras.utils.image_dataset_from_directory(
train_data_dir,
validation_split=0.2,
subset="validation",
shuffle=True,
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
class_names = train_ds.class_names
print(class_names)