noshot 11.0.0__py3-none-any.whl → 13.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- noshot/data/DLE FSD BDA/DLE/DLE 1 (Json)/1. DNN (Image Classification).ipynb +389 -0
- noshot/data/DLE FSD BDA/DLE/DLE 1 (Json)/2. DNN vs CNN.ipynb +516 -0
- noshot/data/DLE FSD BDA/DLE/DLE 1 (Json)/3. CNN (Object Detecrion).ipynb +259 -0
- noshot/data/DLE FSD BDA/DLE/DLE 1 (Json)/4. FCN (Image Segmentaion).ipynb +274 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.1 DNN (Pytorch).ipynb +164 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.2 DNN (Tensorflow).ipynb +94 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.3 DNN (Image Classification).ipynb +134 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/2.1 DNN vs CNN.ipynb +127 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/2.2 DNN vs CNN.ipynb +123 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/4. FCNN (Image Segmentation).ipynb +108 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/Lab Excercise (Training DNN).ipynb +646 -0
- noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/Load-Images.ipynb +553 -0
- noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex1.ipynb +216 -0
- noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex2.ipynb +195 -0
- noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex3.ipynb +427 -0
- noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex4.ipynb +186 -0
- noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/DNN Ex No 1.ipynb +398 -0
- noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/Ex No 1 Build in dataset.ipynb +171 -0
- noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/Exp1-Short-DL_ANN_ImageClassification.ipynb +401 -0
- noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/OR GATE .ipynb +8511 -0
- noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp02/Exp2-Short-DL_CNN_ImageClassification.ipynb +737 -0
- noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp03/DL-Ex3-RNN.ipynb +591 -0
- noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp04/Ex no 4.ipynb +551 -0
- noshot/main.py +3 -3
- {noshot-11.0.0.dist-info → noshot-13.0.0.dist-info}/METADATA +1 -1
- noshot-13.0.0.dist-info/RECORD +32 -0
- noshot/data/ML TS XAI/ML/CNN(Image_for_Folders_5).ipynb +0 -201
- noshot/data/ML TS XAI/ML/CNN(Image_form_Folder_2).ipynb +0 -201
- noshot/data/ML TS XAI/ML/Json Codes/ML LAB CIA 2.ipynb +0 -409
- noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Balance Scale Dataset).ipynb +0 -147
- noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Rice Dataset).ipynb +0 -181
- noshot/data/ML TS XAI/ML/ML 1/10. HMM Veterbi.ipynb +0 -152
- noshot/data/ML TS XAI/ML/ML 1/2. KNN (Balance Scale Dataset).ipynb +0 -117
- noshot/data/ML TS XAI/ML/ML 1/2. KNN (Iris Dataset).ipynb +0 -156
- noshot/data/ML TS XAI/ML/ML 1/2. KNN (Sobar-72 Dataset).ipynb +0 -215
- noshot/data/ML TS XAI/ML/ML 1/3. LDA (Balance Scale Dataset).ipynb +0 -78
- noshot/data/ML TS XAI/ML/ML 1/3. LDA (NPHA Doctor Visits Dataset).ipynb +0 -114
- noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Machine Dataset).ipynb +0 -115
- noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Real Estate Dataset).ipynb +0 -146
- noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Magic04 Dataset).ipynb +0 -130
- noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Wine Dataset).ipynb +0 -112
- noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +0 -118
- noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Wine Dataset).ipynb +0 -89
- noshot/data/ML TS XAI/ML/ML 1/7. SVM (Rice Dataset).ipynb +0 -120
- noshot/data/ML TS XAI/ML/ML 1/8. FeedForward NN (Sobar72 Dataset).ipynb +0 -262
- noshot/data/ML TS XAI/ML/ML 1/9. CNN (Cifar10 Dataset).ipynb +0 -156
- noshot/data/ML TS XAI/ML/ML 2/1. PCA.ipynb +0 -162
- noshot/data/ML TS XAI/ML/ML 2/10. CNN.ipynb +0 -100
- noshot/data/ML TS XAI/ML/ML 2/11. HMM.ipynb +0 -336
- noshot/data/ML TS XAI/ML/ML 2/2. KNN.ipynb +0 -149
- noshot/data/ML TS XAI/ML/ML 2/3. LDA.ipynb +0 -132
- noshot/data/ML TS XAI/ML/ML 2/4. Linear Regression.ipynb +0 -86
- noshot/data/ML TS XAI/ML/ML 2/5. Logistic Regression.ipynb +0 -115
- noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Titanic).ipynb +0 -196
- noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Wine).ipynb +0 -98
- noshot/data/ML TS XAI/ML/ML 2/7. SVM Linear.ipynb +0 -109
- noshot/data/ML TS XAI/ML/ML 2/8. SVM Non-Linear.ipynb +0 -195
- noshot/data/ML TS XAI/ML/ML 2/9. FNN With Regularization.ipynb +0 -189
- noshot/data/ML TS XAI/ML/ML 2/9. FNN Without Regularization.ipynb +0 -197
- noshot/data/ML TS XAI/ML/ML 2/All in One Lab CIA 1 Q.ipynb +0 -1087
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/1. PCA EDA.ipynb +0 -274
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/10. CNN.ipynb +0 -170
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 2.ipynb +0 -1087
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 3.ipynb +0 -178
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 4.ipynb +0 -185
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM.ipynb +0 -106
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/2. KNN.ipynb +0 -177
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/3. LDA.ipynb +0 -195
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/4. Linear Regression.ipynb +0 -267
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/5. Logistic Regression.ipynb +0 -104
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/6. Bayesian Classifier.ipynb +0 -109
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/7. SVM.ipynb +0 -220
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/8. MLP.ipynb +0 -99
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge - Lasso.ipynb +0 -211
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge Lasso 2.ipynb +0 -99
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/Image Load Example.ipynb +0 -118
- noshot/data/ML TS XAI/ML/ML 3 (Latest)/Updated_Untitled.ipynb +0 -603
- noshot/data/ML TS XAI/ML/ML Lab AllinOne.ipynb +0 -961
- noshot/data/ML TS XAI/ML/ML Lab H Sec/1. Iris Dataset (Softmax vs Sigmoid).ipynb +0 -231
- noshot/data/ML TS XAI/ML/ML Lab H Sec/2. Student Dataset (Overfit vs Regularized).ipynb +0 -269
- noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Categorical (Overfit vs Regularized).ipynb +0 -274
- noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Numerical (Overfit vs Regularized).ipynb +0 -263
- noshot/data/ML TS XAI/ML/ML Lab H Sec/4. Smart House System HMM.ipynb +0 -198
- noshot/data/ML TS XAI/ML/ML Lab H Sec/5. Fraud Detection System HMM.ipynb +0 -201
- noshot/data/ML TS XAI/ML/ML Lab H Sec/insurance.csv +0 -1339
- noshot/data/ML TS XAI/ML/ML Lab H Sec/iris1.data +0 -151
- noshot/data/ML TS XAI/ML/ML Lab H Sec/student-mat.csv +0 -396
- noshot/data/ML TS XAI/ML/ML Lab H Sec/student-por.csv +0 -650
- noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +0 -691
- noshot-11.0.0.dist-info/RECORD +0 -72
- {noshot-11.0.0.dist-info → noshot-13.0.0.dist-info}/WHEEL +0 -0
- {noshot-11.0.0.dist-info → noshot-13.0.0.dist-info}/licenses/LICENSE.txt +0 -0
- {noshot-11.0.0.dist-info → noshot-13.0.0.dist-info}/top_level.txt +0 -0
@@ -1,201 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"nbformat": 4,
|
3
|
-
"nbformat_minor": 0,
|
4
|
-
"metadata": {
|
5
|
-
"colab": {
|
6
|
-
"provenance": []
|
7
|
-
},
|
8
|
-
"kernelspec": {
|
9
|
-
"name": "python3",
|
10
|
-
"display_name": "Python 3"
|
11
|
-
},
|
12
|
-
"language_info": {
|
13
|
-
"name": "python"
|
14
|
-
}
|
15
|
-
},
|
16
|
-
"cells": [
|
17
|
-
{
|
18
|
-
"cell_type": "code",
|
19
|
-
"execution_count": 3,
|
20
|
-
"metadata": {
|
21
|
-
"colab": {
|
22
|
-
"base_uri": "https://localhost:8080/"
|
23
|
-
},
|
24
|
-
"id": "BlWncmICrVwe",
|
25
|
-
"outputId": "a7219871-550c-456a-c487-f3a4cfcd4564"
|
26
|
-
},
|
27
|
-
"outputs": [
|
28
|
-
{
|
29
|
-
"output_type": "stream",
|
30
|
-
"name": "stdout",
|
31
|
-
"text": [
|
32
|
-
"Found 125 files belonging to 5 classes.\n",
|
33
|
-
"Using 100 files for training.\n",
|
34
|
-
"Found 125 files belonging to 5 classes.\n",
|
35
|
-
"Using 25 files for validation.\n",
|
36
|
-
"Epoch 1/10\n"
|
37
|
-
]
|
38
|
-
},
|
39
|
-
{
|
40
|
-
"output_type": "stream",
|
41
|
-
"name": "stderr",
|
42
|
-
"text": [
|
43
|
-
"/usr/local/lib/python3.11/dist-packages/keras/src/layers/preprocessing/tf_data_layer.py:19: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.\n",
|
44
|
-
" super().__init__(**kwargs)\n"
|
45
|
-
]
|
46
|
-
},
|
47
|
-
{
|
48
|
-
"output_type": "stream",
|
49
|
-
"name": "stdout",
|
50
|
-
"text": [
|
51
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 2s/step - accuracy: 0.5803 - loss: 1.1232 - val_accuracy: 1.0000 - val_loss: 0.0053\n",
|
52
|
-
"Epoch 2/10\n",
|
53
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m11s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 0.0041 - val_accuracy: 1.0000 - val_loss: 0.0000e+00\n",
|
54
|
-
"Epoch 3/10\n",
|
55
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 1.8428e-09 - val_accuracy: 1.0000 - val_loss: 0.0000e+00\n",
|
56
|
-
"Epoch 4/10\n",
|
57
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m7s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 0.0000e+00 - val_accuracy: 1.0000 - val_loss: 0.0000e+00\n",
|
58
|
-
"Epoch 5/10\n",
|
59
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m20s\u001b[0m 4s/step - accuracy: 1.0000 - loss: 0.0000e+00 - val_accuracy: 1.0000 - val_loss: 3.3379e-08\n",
|
60
|
-
"Epoch 6/10\n",
|
61
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m12s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 6.8267e-08 - val_accuracy: 1.0000 - val_loss: 2.5913e-05\n",
|
62
|
-
"Epoch 7/10\n",
|
63
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m9s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 2.7628e-05 - val_accuracy: 1.0000 - val_loss: 0.0000e+00\n",
|
64
|
-
"Epoch 8/10\n",
|
65
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 0.0000e+00 - val_accuracy: 1.0000 - val_loss: 0.0000e+00\n",
|
66
|
-
"Epoch 9/10\n",
|
67
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m12s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 0.0000e+00 - val_accuracy: 1.0000 - val_loss: 0.0000e+00\n",
|
68
|
-
"Epoch 10/10\n",
|
69
|
-
"\u001b[1m4/4\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m11s\u001b[0m 2s/step - accuracy: 1.0000 - loss: 0.0000e+00 - val_accuracy: 1.0000 - val_loss: 0.0000e+00\n"
|
70
|
-
]
|
71
|
-
},
|
72
|
-
{
|
73
|
-
"output_type": "stream",
|
74
|
-
"name": "stderr",
|
75
|
-
"text": [
|
76
|
-
"WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n"
|
77
|
-
]
|
78
|
-
}
|
79
|
-
],
|
80
|
-
"source": [
|
81
|
-
"import tensorflow as tf\n",
|
82
|
-
"from tensorflow.keras import layers, models\n",
|
83
|
-
"import os\n",
|
84
|
-
"\n",
|
85
|
-
"dataset_path = '/content/Dataset'\n",
|
86
|
-
"\n",
|
87
|
-
"img_height, img_width = 180, 180\n",
|
88
|
-
"batch_size = 32\n",
|
89
|
-
"\n",
|
90
|
-
"train_ds = tf.keras.utils.image_dataset_from_directory(\n",
|
91
|
-
" dataset_path,\n",
|
92
|
-
" validation_split=0.2,\n",
|
93
|
-
" subset=\"training\",\n",
|
94
|
-
" seed=123,\n",
|
95
|
-
" image_size=(img_height, img_width),\n",
|
96
|
-
" batch_size=batch_size)\n",
|
97
|
-
"\n",
|
98
|
-
"val_ds = tf.keras.utils.image_dataset_from_directory(\n",
|
99
|
-
" dataset_path,\n",
|
100
|
-
" validation_split=0.2,\n",
|
101
|
-
" subset=\"validation\",\n",
|
102
|
-
" seed=123,\n",
|
103
|
-
" image_size=(img_height, img_width),\n",
|
104
|
-
" batch_size=batch_size)\n",
|
105
|
-
"\n",
|
106
|
-
"model = models.Sequential([\n",
|
107
|
-
" layers.Rescaling(1./255, input_shape=(img_height, img_width, 3)),\n",
|
108
|
-
" layers.Conv2D(32, 3, activation='relu'),\n",
|
109
|
-
" layers.MaxPooling2D(),\n",
|
110
|
-
" layers.Conv2D(64, 3, activation='relu'),\n",
|
111
|
-
" layers.MaxPooling2D(),\n",
|
112
|
-
" layers.Conv2D(128, 3, activation='relu'),\n",
|
113
|
-
" layers.MaxPooling2D(),\n",
|
114
|
-
" layers.Flatten(),\n",
|
115
|
-
" layers.Dense(128, activation='relu'),\n",
|
116
|
-
" layers.Dense(5)\n",
|
117
|
-
"])\n",
|
118
|
-
"\n",
|
119
|
-
"model.compile(optimizer='adam',\n",
|
120
|
-
" loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n",
|
121
|
-
" metrics=['accuracy'])\n",
|
122
|
-
"\n",
|
123
|
-
"epochs = 10\n",
|
124
|
-
"history = model.fit(\n",
|
125
|
-
" train_ds,\n",
|
126
|
-
" validation_data=val_ds,\n",
|
127
|
-
" epochs=epochs\n",
|
128
|
-
")\n",
|
129
|
-
"\n",
|
130
|
-
"model.save('pistachio_classifier.h5')\n"
|
131
|
-
]
|
132
|
-
},
|
133
|
-
{
|
134
|
-
"cell_type": "code",
|
135
|
-
"source": [
|
136
|
-
"import tensorflow as tf\n",
|
137
|
-
"import numpy as np\n",
|
138
|
-
"from tensorflow.keras.preprocessing import image\n",
|
139
|
-
"\n",
|
140
|
-
"model = tf.keras.models.load_model('pistachio_classifier.h5')\n",
|
141
|
-
"\n",
|
142
|
-
"class_names = ['1','2','3','A','B']\n"
|
143
|
-
],
|
144
|
-
"metadata": {
|
145
|
-
"colab": {
|
146
|
-
"base_uri": "https://localhost:8080/"
|
147
|
-
},
|
148
|
-
"id": "5V8OLPNKsQSq",
|
149
|
-
"outputId": "9b62fcc7-fca4-4ee0-8e9e-66b4538d7771"
|
150
|
-
},
|
151
|
-
"execution_count": 4,
|
152
|
-
"outputs": [
|
153
|
-
{
|
154
|
-
"output_type": "stream",
|
155
|
-
"name": "stderr",
|
156
|
-
"text": [
|
157
|
-
"WARNING:absl:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.\n"
|
158
|
-
]
|
159
|
-
}
|
160
|
-
]
|
161
|
-
},
|
162
|
-
{
|
163
|
-
"cell_type": "code",
|
164
|
-
"source": [
|
165
|
-
"\n",
|
166
|
-
"img_path = '/content/2.jpg'\n",
|
167
|
-
"\n",
|
168
|
-
"\n",
|
169
|
-
"img = image.load_img(img_path, target_size=(180, 180))\n",
|
170
|
-
"img_array = image.img_to_array(img)\n",
|
171
|
-
"img_array = tf.expand_dims(img_array, 0)\n",
|
172
|
-
"\n",
|
173
|
-
"predictions = model.predict(img_array)\n",
|
174
|
-
"score = tf.nn.softmax(predictions[0])\n",
|
175
|
-
"\n",
|
176
|
-
"predicted_class = class_names[np.argmax(score)]\n",
|
177
|
-
"confidence = 100 * np.max(score)\n",
|
178
|
-
"\n",
|
179
|
-
"print(f\"This image most likely belongs to '{predicted_class}' with a {confidence:.2f}% confidence.\")\n"
|
180
|
-
],
|
181
|
-
"metadata": {
|
182
|
-
"colab": {
|
183
|
-
"base_uri": "https://localhost:8080/"
|
184
|
-
},
|
185
|
-
"id": "Cn_opNultOiQ",
|
186
|
-
"outputId": "ed80fd91-4da5-444a-8925-8509b1991727"
|
187
|
-
},
|
188
|
-
"execution_count": 5,
|
189
|
-
"outputs": [
|
190
|
-
{
|
191
|
-
"output_type": "stream",
|
192
|
-
"name": "stdout",
|
193
|
-
"text": [
|
194
|
-
"\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 151ms/step\n",
|
195
|
-
"This image most likely belongs to '2' with a 100.00% confidence.\n"
|
196
|
-
]
|
197
|
-
}
|
198
|
-
]
|
199
|
-
}
|
200
|
-
]
|
201
|
-
}
|
@@ -1,201 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"source": [
|
6
|
-
"import tensorflow as tf\n",
|
7
|
-
"from tensorflow.keras import layers, models\n",
|
8
|
-
"import os\n",
|
9
|
-
"\n",
|
10
|
-
"dataset_path = '/content/Dataset'\n",
|
11
|
-
"\n",
|
12
|
-
"img_height, img_width = 180, 180\n",
|
13
|
-
"batch_size = 32\n",
|
14
|
-
"\n",
|
15
|
-
"train_ds = tf.keras.utils.image_dataset_from_directory(\n",
|
16
|
-
" dataset_path,\n",
|
17
|
-
" validation_split=0.2,\n",
|
18
|
-
" subset=\"training\",\n",
|
19
|
-
" seed=123,\n",
|
20
|
-
" image_size=(img_height, img_width),\n",
|
21
|
-
" batch_size=batch_size)\n",
|
22
|
-
"\n",
|
23
|
-
"val_ds = tf.keras.utils.image_dataset_from_directory(\n",
|
24
|
-
" dataset_path,\n",
|
25
|
-
" validation_split=0.2,\n",
|
26
|
-
" subset=\"validation\",\n",
|
27
|
-
" seed=123,\n",
|
28
|
-
" image_size=(img_height, img_width),\n",
|
29
|
-
" batch_size=batch_size)\n",
|
30
|
-
"\n",
|
31
|
-
"model = models.Sequential([\n",
|
32
|
-
" layers.Rescaling(1./255, input_shape=(img_height, img_width, 3)),\n",
|
33
|
-
" layers.Conv2D(32, 3, activation='relu'),\n",
|
34
|
-
" layers.MaxPooling2D(),\n",
|
35
|
-
" layers.Conv2D(64, 3, activation='relu'),\n",
|
36
|
-
" layers.MaxPooling2D(),\n",
|
37
|
-
" layers.Conv2D(128, 3, activation='relu'),\n",
|
38
|
-
" layers.MaxPooling2D(),\n",
|
39
|
-
" layers.Flatten(),\n",
|
40
|
-
" layers.Dense(128, activation='relu'),\n",
|
41
|
-
" layers.Dense(2)\n",
|
42
|
-
"])\n",
|
43
|
-
"\n",
|
44
|
-
"model.compile(optimizer='adam',\n",
|
45
|
-
" loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n",
|
46
|
-
" metrics=['accuracy'])\n",
|
47
|
-
"\n",
|
48
|
-
"epochs = 10\n",
|
49
|
-
"history = model.fit(\n",
|
50
|
-
" train_ds,\n",
|
51
|
-
" validation_data=val_ds,\n",
|
52
|
-
" epochs=epochs\n",
|
53
|
-
")\n",
|
54
|
-
"\n",
|
55
|
-
"model.save('pistachio_classifier.h5')\n"
|
56
|
-
],
|
57
|
-
"metadata": {
|
58
|
-
"colab": {
|
59
|
-
"base_uri": "https://localhost:8080/"
|
60
|
-
},
|
61
|
-
"id": "X5rygqUYn0NL",
|
62
|
-
"outputId": "dfb18a11-ecb5-4221-c838-f2b0af4c87c3"
|
63
|
-
},
|
64
|
-
"execution_count": 1,
|
65
|
-
"outputs": [
|
66
|
-
{
|
67
|
-
"output_type": "stream",
|
68
|
-
"name": "stdout",
|
69
|
-
"text": [
|
70
|
-
"Found 100 files belonging to 2 classes.\n",
|
71
|
-
"Using 80 files for training.\n",
|
72
|
-
"Found 100 files belonging to 2 classes.\n",
|
73
|
-
"Using 20 files for validation.\n"
|
74
|
-
]
|
75
|
-
},
|
76
|
-
{
|
77
|
-
"output_type": "stream",
|
78
|
-
"name": "stderr",
|
79
|
-
"text": [
|
80
|
-
"/usr/local/lib/python3.11/dist-packages/keras/src/layers/preprocessing/tf_data_layer.py:19: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.\n",
|
81
|
-
" super().__init__(**kwargs)\n"
|
82
|
-
]
|
83
|
-
},
|
84
|
-
{
|
85
|
-
"output_type": "stream",
|
86
|
-
"name": "stdout",
|
87
|
-
"text": [
|
88
|
-
"Epoch 1/10\n",
|
89
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 2s/step - accuracy: 0.5469 - loss: 0.7486 - val_accuracy: 0.6000 - val_loss: 0.8673\n",
|
90
|
-
"Epoch 2/10\n",
|
91
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m8s\u001b[0m 2s/step - accuracy: 0.5352 - loss: 0.7847 - val_accuracy: 0.6500 - val_loss: 0.6347\n",
|
92
|
-
"Epoch 3/10\n",
|
93
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 1s/step - accuracy: 0.8211 - loss: 0.4471 - val_accuracy: 0.8000 - val_loss: 0.6110\n",
|
94
|
-
"Epoch 4/10\n",
|
95
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 2s/step - accuracy: 0.8797 - loss: 0.3727 - val_accuracy: 0.8500 - val_loss: 0.8057\n",
|
96
|
-
"Epoch 5/10\n",
|
97
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 2s/step - accuracy: 0.8742 - loss: 0.3163 - val_accuracy: 0.6500 - val_loss: 0.9343\n",
|
98
|
-
"Epoch 6/10\n",
|
99
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 2s/step - accuracy: 0.8070 - loss: 0.3726 - val_accuracy: 0.8000 - val_loss: 0.7291\n",
|
100
|
-
"Epoch 7/10\n",
|
101
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m9s\u001b[0m 1s/step - accuracy: 0.8766 - loss: 0.2542 - val_accuracy: 0.8000 - val_loss: 0.6933\n",
|
102
|
-
"Epoch 8/10\n",
|
103
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 2s/step - accuracy: 0.9453 - loss: 0.1739 - val_accuracy: 0.8500 - val_loss: 0.6692\n",
|
104
|
-
"Epoch 9/10\n",
|
105
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 2s/step - accuracy: 0.8969 - loss: 0.1860 - val_accuracy: 0.8500 - val_loss: 0.7117\n",
|
106
|
-
"Epoch 10/10\n",
|
107
|
-
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 2s/step - accuracy: 0.9250 - loss: 0.1766 - val_accuracy: 0.8500 - val_loss: 0.7313\n"
|
108
|
-
]
|
109
|
-
},
|
110
|
-
{
|
111
|
-
"output_type": "stream",
|
112
|
-
"name": "stderr",
|
113
|
-
"text": [
|
114
|
-
"WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`. \n"
|
115
|
-
]
|
116
|
-
}
|
117
|
-
]
|
118
|
-
},
|
119
|
-
{
|
120
|
-
"cell_type": "code",
|
121
|
-
"source": [
|
122
|
-
"import tensorflow as tf\n",
|
123
|
-
"import numpy as np\n",
|
124
|
-
"from tensorflow.keras.preprocessing import image\n",
|
125
|
-
"\n",
|
126
|
-
"model = tf.keras.models.load_model('pistachio_classifier.h5')\n",
|
127
|
-
"\n",
|
128
|
-
"class_names = ['Kirmizi_Pistachio', 'Siirt_Pistachio']\n"
|
129
|
-
],
|
130
|
-
"metadata": {
|
131
|
-
"colab": {
|
132
|
-
"base_uri": "https://localhost:8080/"
|
133
|
-
},
|
134
|
-
"id": "7GyugRDLpLlN",
|
135
|
-
"outputId": "8bad83c9-c088-405a-ec06-ac493f6d7072"
|
136
|
-
},
|
137
|
-
"execution_count": 2,
|
138
|
-
"outputs": [
|
139
|
-
{
|
140
|
-
"output_type": "stream",
|
141
|
-
"name": "stderr",
|
142
|
-
"text": [
|
143
|
-
"WARNING:absl:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.\n"
|
144
|
-
]
|
145
|
-
}
|
146
|
-
]
|
147
|
-
},
|
148
|
-
{
|
149
|
-
"cell_type": "code",
|
150
|
-
"source": [
|
151
|
-
"\n",
|
152
|
-
"img_path = '/content/siirt (3).jpg'\n",
|
153
|
-
"\n",
|
154
|
-
"\n",
|
155
|
-
"img = image.load_img(img_path, target_size=(180, 180))\n",
|
156
|
-
"img_array = image.img_to_array(img)\n",
|
157
|
-
"img_array = tf.expand_dims(img_array, 0)\n",
|
158
|
-
"\n",
|
159
|
-
"predictions = model.predict(img_array)\n",
|
160
|
-
"score = tf.nn.softmax(predictions[0])\n",
|
161
|
-
"\n",
|
162
|
-
"predicted_class = class_names[np.argmax(score)]\n",
|
163
|
-
"confidence = 100 * np.max(score)\n",
|
164
|
-
"\n",
|
165
|
-
"print(f\"This image most likely belongs to '{predicted_class}' with a {confidence:.2f}% confidence.\")\n"
|
166
|
-
],
|
167
|
-
"metadata": {
|
168
|
-
"colab": {
|
169
|
-
"base_uri": "https://localhost:8080/"
|
170
|
-
},
|
171
|
-
"id": "SwZcLQftpOYI",
|
172
|
-
"outputId": "90c61acd-31cd-4c49-97f8-59bc90fc029c"
|
173
|
-
},
|
174
|
-
"execution_count": 3,
|
175
|
-
"outputs": [
|
176
|
-
{
|
177
|
-
"output_type": "stream",
|
178
|
-
"name": "stdout",
|
179
|
-
"text": [
|
180
|
-
"\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 188ms/step\n",
|
181
|
-
"This image most likely belongs to 'Kirmizi_Pistachio' with a 94.41% confidence.\n"
|
182
|
-
]
|
183
|
-
}
|
184
|
-
]
|
185
|
-
}
|
186
|
-
],
|
187
|
-
"metadata": {
|
188
|
-
"colab": {
|
189
|
-
"provenance": []
|
190
|
-
},
|
191
|
-
"kernelspec": {
|
192
|
-
"display_name": "Python 3",
|
193
|
-
"name": "python3"
|
194
|
-
},
|
195
|
-
"language_info": {
|
196
|
-
"name": "python"
|
197
|
-
}
|
198
|
-
},
|
199
|
-
"nbformat": 4,
|
200
|
-
"nbformat_minor": 0
|
201
|
-
}
|