<jupyter_start><jupyter_text>Download the Dataset from Kaggle Link: https://www.kaggle.com/vishalmane109/indian-currency-note-images-dataset-2020 Import the Libraries<jupyter_code>from mpl_toolkits.mplot3d import Axes3D
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt # plotting
import numpy as np # linear algebra
import os # accessing directory structure
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)<jupyter_output><empty_output><jupyter_text>Import the dataset<jupyter_code>!gdown --id https://www.kaggle.com/vishalmane109/indian-currency-note-images-dataset-2020/download<jupyter_output>Permission denied: https://drive.google.com/uc?id=https://www.kaggle.com/vishalmane109/indian-currency-note-images-dataset-2020/download
Maybe you need to change permission over 'Anyone with the link'?<jupyter_text>Initialise Kaggle<jupyter_code>! pip install kaggle
! mkdir ~/.kaggle
! cp kaggle.json ~/.kaggle/
! chmod 600 ~/.kaggle/kaggle.json<jupyter_output><empty_output><jupyter_text>Download Dataset from Kaggle<jupyter_code>!kaggle datasets download -d vishalmane109/indian-currency-note-images-dataset-2020<jupyter_output>indian-currency-note-images-dataset-2020.zip: Skipping, found more recently modified local copy (use --force to force download)<jupyter_text>Unzip<jupyter_code>!unzip /content/indian-currency-note-images-dataset-2020.zip<jupyter_output>Archive:  /content/indian-currency-note-images-dataset-2020.zip
replace Indian currency dataset v1/test/100_15.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename:<jupyter_text>Inception_V3<jupyter_code>import tensorflow as tf
import keras_preprocessing
from keras_preprocessing import image
from keras_preprocessing.image import ImageDataGenerator

TRAINING_DIR = "/content/Indian currency dataset v1/training"
training_datagen = ImageDataGenerator(
      rescale = 1./255)

VALIDATION_DIR = "/content/Indian currency dataset v1/validation"
validation_datagen = ImageDataGenerator(rescale = 1./255)

train_generator = training_datagen.flow_from_directory(
	TRAINING_DIR,
	target_size=(150,150),
	class_mode='categorical',
  batch_size=126
)

validation_generator = validation_datagen.flow_from_directory(
	VALIDATION_DIR,
	target_size=(150,150),
	class_mode='categorical',
  batch_size=126
)


import os

from tensorflow.keras import layers
from tensorflow.keras import Model
from tensorflow.keras.applications.inception_v3 import InceptionV3

!wget --no-check-certificate \
    https://storage.googleapis.com/mledu-datasets/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5 \
    -O /tmp/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5
local_weights_file = '/tmp/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5'
pre_trained_model = InceptionV3(input_shape = (150, 150, 3), 
                                include_top = False, 
                                weights = None)

pre_trained_model.load_weights(local_weights_file)

for layer in pre_trained_model.layers:
  layer.trainable = False #it_blocks_that_the_model_cannot_be_trained_anymore
  
# pre_trained_model.summary()

pre_trained_model.summary()
last_layer = pre_trained_model.get_layer('mixed7')
print('last layer output shape: ', last_layer.output_shape)
last_output = last_layer.output

from tensorflow.keras.optimizers import RMSprop

# Flatten the output layer to 1 dimension
x = layers.Flatten()(last_output)
# Add a fully connected layer with 1,024 hidden units and ReLU activation
x = layers.Dense(1024, activation='relu')(x)
# Add a dropout rate of 0.2
x = layers.Dropout(0.2)(x)                  
# Add a final sigmoid layer for classification
x = layers.Dense  (8, activation='softmax')(x)           

model = Model( pre_trained_model.input, x) 

model.compile(loss='categorical_crossentropy',optimizer='adam', metrics=['accuracy'])


model.summary()
from tensorflow.keras.callbacks import ModelCheckpoint, LearningRateScheduler, TensorBoard, EarlyStopping
checkpoint = ModelCheckpoint('Xception_model.h5', monitor = 'val_accuracy', verbose = 1,
                             save_best_only = True, save_weights_only = False,
                             mode = 'auto')
early = EarlyStopping(monitor = 'val_accuracy', min_delta = 0, patience = 10,
                      verbose = 1, mode = 'auto')

history = model.fit(train_generator, epochs=15, steps_per_epoch=20, validation_data = validation_generator, verbose = 1, callbacks = [checkpoint, early], validation_steps=3)

import matplotlib.pyplot as plt
acc = history.history['accuracy']
val_acc = history.history['val_accuracy']
loss = history.history['loss']
val_loss = history.history['val_loss']

epochs = range(len(acc))

plt.plot(epochs, acc, 'r', label='Training accuracy')
plt.plot(epochs, val_acc, 'b', label='Validation accuracy')
plt.title('Training and validation accuracy')
plt.legend(loc=0)
plt.figure()


plt.show()

model.save("rps.h5")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10364372469635627, 'fraction_numerical': 0.025303643724696356, 'mean_word_length': 5.326504481434059, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 5, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '465821', 'license': 'MIT', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1631, 'n_words': 323, 'path': 'TRR & CDI/CDI/Archive/cdi_inception_v3.ipynb', 'repo_name': 'ProxMaq/ProxVision', 'size': '4940'}