noshot 12.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.
Files changed (29) hide show
  1. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.1 DNN (Pytorch).ipynb +164 -0
  2. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.2 DNN (Tensorflow).ipynb +94 -0
  3. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.3 DNN (Image Classification).ipynb +134 -0
  4. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/2.1 DNN vs CNN.ipynb +127 -0
  5. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/2.2 DNN vs CNN.ipynb +123 -0
  6. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/4. FCNN (Image Segmentation).ipynb +108 -0
  7. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/Lab Excercise (Training DNN).ipynb +646 -0
  8. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/Load-Images.ipynb +553 -0
  9. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex1.ipynb +216 -0
  10. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex2.ipynb +195 -0
  11. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex3.ipynb +427 -0
  12. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex4.ipynb +186 -0
  13. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/DNN Ex No 1.ipynb +398 -0
  14. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/Ex No 1 Build in dataset.ipynb +171 -0
  15. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/Exp1-Short-DL_ANN_ImageClassification.ipynb +401 -0
  16. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/OR GATE .ipynb +8511 -0
  17. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp02/Exp2-Short-DL_CNN_ImageClassification.ipynb +737 -0
  18. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp03/DL-Ex3-RNN.ipynb +591 -0
  19. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp04/Ex no 4.ipynb +551 -0
  20. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/METADATA +1 -1
  21. noshot-13.0.0.dist-info/RECORD +32 -0
  22. noshot-12.0.0.dist-info/RECORD +0 -13
  23. /noshot/data/DLE FSD BDA/DLE/{1. DNN (Image Classification).ipynb → DLE 1 (Json)/1. DNN (Image Classification).ipynb} +0 -0
  24. /noshot/data/DLE FSD BDA/DLE/{2. DNN vs CNN.ipynb → DLE 1 (Json)/2. DNN vs CNN.ipynb} +0 -0
  25. /noshot/data/DLE FSD BDA/DLE/{3. CNN (Object Detecrion).ipynb → DLE 1 (Json)/3. CNN (Object Detecrion).ipynb} +0 -0
  26. /noshot/data/DLE FSD BDA/DLE/{4. FCN (Image Segmentaion).ipynb → DLE 1 (Json)/4. FCN (Image Segmentaion).ipynb} +0 -0
  27. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/WHEEL +0 -0
  28. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  29. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,216 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "30bd2975-4815-46e4-ad37-d069fc8e336a",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import numpy as np\n",
11
+ "import os\n",
12
+ "from sklearn.model_selection import train_test_split\n",
13
+ "from sklearn.metrics import classification_report, confusion_matrix, ConfusionMatrixDisplay\n",
14
+ "from tensorflow.keras.preprocessing.image import load_img, img_to_array\n",
15
+ "from tensorflow.keras.models import Sequential\n",
16
+ "from tensorflow.keras.layers import Dense, Flatten, Dropout\n",
17
+ "from tensorflow.keras.utils import to_categorical\n",
18
+ "import matplotlib.pyplot as plt"
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "execution_count": null,
24
+ "id": "efeb27d9-4b7f-4cee-911a-7e6856bc40d6",
25
+ "metadata": {},
26
+ "outputs": [],
27
+ "source": [
28
+ "# Function to load images and their labels from the dataset folder\n",
29
+ "def load_images_from_folder(folder_path, image_size=(128, 128)):\n",
30
+ " images = []\n",
31
+ " labels = []\n",
32
+ " class_names = os.listdir(folder_path)\n",
33
+ " for label, class_name in enumerate(class_names):\n",
34
+ " class_path = os.path.join(folder_path, class_name)\n",
35
+ " for filename in os.listdir(class_path):\n",
36
+ " img = load_img(os.path.join(class_path, filename), target_size=image_size)\n",
37
+ " img_array = img_to_array(img) / 255.0 # Normalize pixel values\n",
38
+ " images.append(img_array)\n",
39
+ " labels.append(label)\n",
40
+ "\n",
41
+ " return np.array(images), np.array(labels), class_names"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": null,
47
+ "id": "fe120487-1b1d-4d64-bd9a-379ed51c81b3",
48
+ "metadata": {},
49
+ "outputs": [],
50
+ "source": [
51
+ "# Load the dataset\n",
52
+ "dataset_path = r'D:\\Neeraj\\SEM 7\\DLE LAB\\Bean_Dataset\\Bean_Dataset'\n",
53
+ "X, y, class_names = load_images_from_folder(dataset_path)\n",
54
+ "print(f\"Loaded {X.shape[0]} images of size {X.shape[1:]}.\")"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "id": "b8e440f8-cb5b-405f-a2e3-765d0bb3710e",
61
+ "metadata": {},
62
+ "outputs": [],
63
+ "source": [
64
+ "# Train-test split\n",
65
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)"
66
+ ]
67
+ },
68
+ {
69
+ "cell_type": "code",
70
+ "execution_count": null,
71
+ "id": "e37f401f-e3b4-4e71-b9b4-bdcd4d94032b",
72
+ "metadata": {},
73
+ "outputs": [],
74
+ "source": [
75
+ "# Flatten the image data to feed into the DNN\n",
76
+ "X_train_flat = X_train.reshape(X_train.shape[0], -1)\n",
77
+ "X_test_flat = X_test.reshape(X_test.shape[0], -1)"
78
+ ]
79
+ },
80
+ {
81
+ "cell_type": "code",
82
+ "execution_count": null,
83
+ "id": "5f936ddd-44ac-42f5-8186-67ae6ffdab04",
84
+ "metadata": {},
85
+ "outputs": [],
86
+ "source": [
87
+ "# Convert labels to one-hot encoding\n",
88
+ "num_classes = len(class_names)\n",
89
+ "y_train = to_categorical(y_train, num_classes)\n",
90
+ "y_test = to_categorical(y_test, num_classes)"
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "execution_count": null,
96
+ "id": "144a1359-24d2-4875-b52a-6ece383e64eb",
97
+ "metadata": {},
98
+ "outputs": [],
99
+ "source": [
100
+ "# Build the DNN model\n",
101
+ "model = Sequential([\n",
102
+ " Dense(512, activation='relu', input_shape=(X_train_flat.shape[1],)),\n",
103
+ " Dense(256, activation='relu'),\n",
104
+ " Dense(num_classes, activation='softmax')\n",
105
+ "])\n",
106
+ "\n",
107
+ "# Compile the model\n",
108
+ "model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\n",
109
+ "\n",
110
+ "# Train the model\n",
111
+ "history = model.fit(X_train_flat, y_train, epochs=10, validation_split=0.2, batch_size=32)"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "code",
116
+ "execution_count": null,
117
+ "id": "e44ac332-bdb6-4bfc-b1b1-1a302641dd73",
118
+ "metadata": {},
119
+ "outputs": [],
120
+ "source": [
121
+ "# Evaluate the model\n",
122
+ "test_loss, test_accuracy = model.evaluate(X_test_flat, y_test)\n",
123
+ "print(f\"Test Accuracy: {test_accuracy * 100:.2f}%\")"
124
+ ]
125
+ },
126
+ {
127
+ "cell_type": "code",
128
+ "execution_count": null,
129
+ "id": "c0ce93d7-edac-4d35-9748-cce1208403e3",
130
+ "metadata": {},
131
+ "outputs": [],
132
+ "source": [
133
+ "# Generate predictions and evaluate the model\n",
134
+ "y_pred = np.argmax(model.predict(X_test_flat), axis=-1)\n",
135
+ "y_true = np.argmax(y_test, axis=-1)"
136
+ ]
137
+ },
138
+ {
139
+ "cell_type": "code",
140
+ "execution_count": null,
141
+ "id": "f1fbfd69-b688-4b04-85c7-ca968da6e6a4",
142
+ "metadata": {},
143
+ "outputs": [],
144
+ "source": [
145
+ "# Display the classification report and confusion matrix\n",
146
+ "print(\"Classification Report:\")\n",
147
+ "print(classification_report(y_true, y_pred, target_names=class_names))\n",
148
+ "\n",
149
+ "cm = confusion_matrix(y_true, y_pred)\n",
150
+ "disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=class_names)\n",
151
+ "disp.plot()\n",
152
+ "plt.title('Confusion Matrix')\n",
153
+ "plt.show()"
154
+ ]
155
+ },
156
+ {
157
+ "cell_type": "code",
158
+ "execution_count": null,
159
+ "id": "6dde7e3e-1995-4c4b-b483-ccc6d4e1c06d",
160
+ "metadata": {},
161
+ "outputs": [],
162
+ "source": [
163
+ "plt.figure(figsize=(16,4))\n",
164
+ "plt.plot(history.history['accuracy'], label='Train Accuracy')\n",
165
+ "plt.plot(history.history['val_accuracy'], label='Val Accuracy')\n",
166
+ "plt.title('Model Accuracy')\n",
167
+ "plt.legend()\n",
168
+ "plt.show()"
169
+ ]
170
+ },
171
+ {
172
+ "cell_type": "code",
173
+ "execution_count": null,
174
+ "id": "224407b5-9aca-4851-9282-d2452b8e907c",
175
+ "metadata": {},
176
+ "outputs": [],
177
+ "source": [
178
+ "plt.figure(figsize=(16,4))\n",
179
+ "plt.plot(history.history['loss'], label='Train Loss')\n",
180
+ "plt.plot(history.history['val_loss'], label='Val Loss')\n",
181
+ "plt.title('Model Loss')\n",
182
+ "plt.legend()\n",
183
+ "plt.show()"
184
+ ]
185
+ },
186
+ {
187
+ "cell_type": "code",
188
+ "execution_count": null,
189
+ "id": "85d68741-9136-4430-8d7d-b235284e5093",
190
+ "metadata": {},
191
+ "outputs": [],
192
+ "source": []
193
+ }
194
+ ],
195
+ "metadata": {
196
+ "kernelspec": {
197
+ "display_name": "Python 3 (ipykernel)",
198
+ "language": "python",
199
+ "name": "python3"
200
+ },
201
+ "language_info": {
202
+ "codemirror_mode": {
203
+ "name": "ipython",
204
+ "version": 3
205
+ },
206
+ "file_extension": ".py",
207
+ "mimetype": "text/x-python",
208
+ "name": "python",
209
+ "nbconvert_exporter": "python",
210
+ "pygments_lexer": "ipython3",
211
+ "version": "3.12.4"
212
+ }
213
+ },
214
+ "nbformat": 4,
215
+ "nbformat_minor": 5
216
+ }
@@ -0,0 +1,195 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "4fcc9ecd-e298-4292-964e-963369bf43f3",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import tensorflow as tf\n",
11
+ "from tensorflow.keras.models import Sequential\n",
12
+ "from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Dropout\n",
13
+ "from tensorflow.keras.utils import to_categorical\n",
14
+ "from sklearn.model_selection import train_test_split\n",
15
+ "from sklearn.metrics import classification_report, confusion_matrix, ConfusionMatrixDisplay\n",
16
+ "import numpy as np\n",
17
+ "import os\n",
18
+ "from tensorflow.keras.preprocessing.image import load_img, img_to_array\n",
19
+ "import matplotlib.pyplot as plt"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": null,
25
+ "id": "4b88cc71-ebb8-408e-998e-de7c58054a9e",
26
+ "metadata": {},
27
+ "outputs": [],
28
+ "source": [
29
+ "# Load and preprocess images from directories\n",
30
+ "def load_images_from_folder(folder_path, image_size=(128, 128)):\n",
31
+ " images = []\n",
32
+ " labels = []\n",
33
+ " class_names = os.listdir(folder_path)\n",
34
+ " \n",
35
+ " for label, class_name in enumerate(class_names):\n",
36
+ " class_path = os.path.join(folder_path, class_name)\n",
37
+ " for filename in os.listdir(class_path):\n",
38
+ " img = load_img(os.path.join(class_path, filename), target_size=image_size)\n",
39
+ " img_array = img_to_array(img) / 255.0 # Normalize\n",
40
+ " images.append(img_array)\n",
41
+ " labels.append(label)\n",
42
+ " \n",
43
+ " return np.array(images), np.array(labels), class_names"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": null,
49
+ "id": "053052e3-955e-4d34-a3c1-6d1561ed41fa",
50
+ "metadata": {},
51
+ "outputs": [],
52
+ "source": [
53
+ "# Path to your dataset folder (structured as folder/class_name/image.jpg)\n",
54
+ "dataset_path = r'D:\\Neeraj\\SEM 7\\DLE LAB\\Bean_Dataset\\Bean_Dataset'\n",
55
+ "\n",
56
+ "# Load data\n",
57
+ "X, y, class_names = load_images_from_folder(dataset_path)\n",
58
+ "print(f\"Loaded {X.shape[0]} images with shape {X.shape[1:]}.\")"
59
+ ]
60
+ },
61
+ {
62
+ "cell_type": "code",
63
+ "execution_count": null,
64
+ "id": "feaa5760-3239-4800-903c-bf554129c9bc",
65
+ "metadata": {},
66
+ "outputs": [],
67
+ "source": [
68
+ "# Train-test split\n",
69
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
70
+ "\n",
71
+ "# Convert labels to categorical (one-hot encoding)\n",
72
+ "num_classes = len(class_names)\n",
73
+ "y_train = to_categorical(y_train, num_classes)\n",
74
+ "y_test = to_categorical(y_test, num_classes)\n"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": null,
80
+ "id": "71b6c633-321b-4bc1-b9d7-cfd8e26ad44b",
81
+ "metadata": {},
82
+ "outputs": [],
83
+ "source": [
84
+ "# Define a simple CNN model\n",
85
+ "model = Sequential([\n",
86
+ " Conv2D(32, (3, 3), activation='relu', input_shape=(128, 128, 3)),\n",
87
+ " MaxPooling2D((2, 2)),\n",
88
+ " Conv2D(64, (3, 3), activation='relu'),\n",
89
+ " MaxPooling2D((2, 2)),\n",
90
+ " Flatten(),\n",
91
+ " Dense(128, activation='relu'),\n",
92
+ " Dropout(0.5),\n",
93
+ " Dense(num_classes, activation='softmax')\n",
94
+ "])\n",
95
+ "\n",
96
+ "# Compile the model\n",
97
+ "model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\n",
98
+ "\n",
99
+ "# Train the model\n",
100
+ "history = model.fit(X_train, y_train, epochs=10, validation_split=0.2, batch_size=32)"
101
+ ]
102
+ },
103
+ {
104
+ "cell_type": "code",
105
+ "execution_count": null,
106
+ "id": "bbd59250-745c-4bb4-a53f-830120d91fd3",
107
+ "metadata": {},
108
+ "outputs": [],
109
+ "source": [
110
+ "# Evaluate the model\n",
111
+ "test_loss, test_accuracy = model.evaluate(X_test, y_test)\n",
112
+ "print(f\"Test Accuracy: {test_accuracy * 100:.2f}%\")"
113
+ ]
114
+ },
115
+ {
116
+ "cell_type": "code",
117
+ "execution_count": null,
118
+ "id": "63d608fe-28e4-443c-8b59-cc4486d0ce68",
119
+ "metadata": {},
120
+ "outputs": [],
121
+ "source": [
122
+ "# Predictions and performance metrics\n",
123
+ "y_pred = np.argmax(model.predict(X_test), axis=-1)\n",
124
+ "y_true = np.argmax(y_test, axis=-1)\n",
125
+ "print(\"Classification Report:\")\n",
126
+ "print(classification_report(y_true, y_pred, target_names=class_names))\n",
127
+ "\n",
128
+ "cm = confusion_matrix(y_true, y_pred)\n",
129
+ "disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=class_names)\n",
130
+ "disp.plot()\n",
131
+ "plt.title('Confusion Matrix')\n",
132
+ "plt.show()"
133
+ ]
134
+ },
135
+ {
136
+ "cell_type": "code",
137
+ "execution_count": null,
138
+ "id": "091bff7a-cfb6-4680-baf2-d8007e8217d5",
139
+ "metadata": {},
140
+ "outputs": [],
141
+ "source": [
142
+ "plt.figure(figsize=(16,4))\n",
143
+ "plt.plot(history.history['accuracy'], label='Train Accuracy')\n",
144
+ "plt.plot(history.history['val_accuracy'], label='Val Accuracy')\n",
145
+ "plt.title('Model Accuracy')\n",
146
+ "plt.legend()\n",
147
+ "plt.show()"
148
+ ]
149
+ },
150
+ {
151
+ "cell_type": "code",
152
+ "execution_count": null,
153
+ "id": "b7f7411d-5bd1-4e3a-9b49-8e546bad7d82",
154
+ "metadata": {},
155
+ "outputs": [],
156
+ "source": [
157
+ "plt.figure(figsize=(16,4))\n",
158
+ "plt.plot(history.history['loss'], label='Train Loss')\n",
159
+ "plt.plot(history.history['val_loss'], label='Val Loss')\n",
160
+ "plt.title('Model Loss')\n",
161
+ "plt.legend()\n",
162
+ "plt.show()"
163
+ ]
164
+ },
165
+ {
166
+ "cell_type": "code",
167
+ "execution_count": null,
168
+ "id": "b16640de-0ae0-4fb1-803a-60aaccdd456a",
169
+ "metadata": {},
170
+ "outputs": [],
171
+ "source": []
172
+ }
173
+ ],
174
+ "metadata": {
175
+ "kernelspec": {
176
+ "display_name": "Python 3 (ipykernel)",
177
+ "language": "python",
178
+ "name": "python3"
179
+ },
180
+ "language_info": {
181
+ "codemirror_mode": {
182
+ "name": "ipython",
183
+ "version": 3
184
+ },
185
+ "file_extension": ".py",
186
+ "mimetype": "text/x-python",
187
+ "name": "python",
188
+ "nbconvert_exporter": "python",
189
+ "pygments_lexer": "ipython3",
190
+ "version": "3.12.4"
191
+ }
192
+ },
193
+ "nbformat": 4,
194
+ "nbformat_minor": 5
195
+ }