Bambang Tri Wahyono
This program was created to classify hand gesture images that perform Rock, Paper, Scissor movements is taken from
https://www.kaggle.com/datasets/drgfreeman/rockpaperscissors?select=README_rpc-cv-images.txt
This dataset contains images of hand gestures from the Rock-Paper-Scissors game
METHOD
The downloaded hand gesture images dataset will be classified in three steps:
The first step:
create variable containing data from dataset using base_path . command :
base_path = '/content/drive/My Drive/datasets/RockPaperScissor/rps-cv-images'
Second step:
convert data into array using ImageDataGenerator function from Keras library:
from keras.preprocessing.image import ImageDataGenerator
Third step:
create your own generator with the code below
generator = ImageDataGenerator(
horizontal_flip = True,
vertical_flip = True,
height_shift_range = .2,
validation_split = 0.2
)
Figure 1 ImageDataGenerator
in the code above there is a value of 0.2 which means the dataset will be divided into 80% for training, and 20% for validation
horizontal_flip, vertical_flip, and height_shift_range is another function of ImageDataGenerator() to change image position.
The dataset is divided into 2 parts, train_image for training and val_image for validation
Adding subset='validation' indicates that the validation data uses 20% of the dataset as defined in the generator
Figure 2 train_image_code
target_size=(224,224) will make the image size 224 x 224 to equalize all images
class_mode made 'categorical' because we will define 3 classes: rock, scissors, and paper. If you only need 2 classes, then it's better to use 'binary’
shuffle will fetch data randomly if it is True
Figure 3 val_image_code
RESULT
when the program code is execute it produces output
Figure 4 Output Program
CONCLUSION
The dataset contains a total of 2188 images corresponding to the 'Rock' (726 images), 'Paper' (710 images) and 'Scissors' (752 images) hand gestures of the Rock-Paper-Scissors game
on the data training found 1751 images, and data validation found 437 images
The images are separated into three sub-folders named 'rock', 'paper', and 'scissors' according to their respective class