File - Ipynb - JupyterLab
File - Ipynb - JupyterLab
File - Ipynb - JupyterLab
2024-03-05 15:37:25.626878: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightl
y different numerical results due to floating-point round-off errors from different computation orders. To turn them
off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-03-05 15:37:25.877079: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN
factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-05 15:37:25.877144: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT
factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-05 15:37:25.918724: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBL
AS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-03-05 15:37:25.999476: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized
to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the
appropriate compiler flags.
2024-03-05 15:37:26.845677: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find T
ensorRT
In [4]: img_array.shape
In [5]: plt.imshow(img_array)
localhost:8888/doc/tree/file.ipynb 1/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 2/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 3/30
3/6/24, 11:47 PM file
In [9]: new_array.shape
In [10]: train_data = []
def create_train_data():
for category in classes:
path = os.path.join(dir, category)
class_num = classes.index(category)
for img in os.listdir(path):
try:
img_path = os.path.join(path, img)
img_array = cv2.imread(img_path)
new_array = cv2.resize(img_array,(img_size,img_size))
localhost:8888/doc/tree/file.ipynb 4/30
3/6/24, 11:47 PM file
train_data.append([new_array,class_num])
except Exception as e:
pass
create_train_data()
In [11]: print(len(train_data))
28709
random.shuffle(train_data)
In [13]: x = []
y = []
In [14]: x.shape
In [15]: # x = x/255.0
In [16]: type(y)
Out[16]: list
In [17]: y[0]
Out[17]: 5
In [18]: y = np.array(y)
y.shape
localhost:8888/doc/tree/file.ipynb 5/30
3/6/24, 11:47 PM file
Out[18]: (28709,)
In [21]: model.summary()
localhost:8888/doc/tree/file.ipynb 6/30
3/6/24, 11:47 PM file
Model: "mobilenetv2_1.00_224"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) [(None, 224, 224, 3)] 0 []
localhost:8888/doc/tree/file.ipynb 7/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 8/30
3/6/24, 11:47 PM file
rmalization)
localhost:8888/doc/tree/file.ipynb 9/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 10/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 11/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 12/30
3/6/24, 11:47 PM file
']
localhost:8888/doc/tree/file.ipynb 13/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 14/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 15/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 16/30
3/6/24, 11:47 PM file
ormalization)
==================================================================================================
Total params: 3538984 (13.50 MB)
Trainable params: 3504872 (13.37 MB)
Non-trainable params: 34112 (133.25 KB)
__________________________________________________________________________________________________
localhost:8888/doc/tree/file.ipynb 17/30
3/6/24, 11:47 PM file
base_output = model.layers[-2].output
In [23]: base_input
base_output
In [25]: final_output
In [27]: new_model.summary()
localhost:8888/doc/tree/file.ipynb 18/30
3/6/24, 11:47 PM file
Model: "model"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) [(None, 224, 224, 3)] 0 []
localhost:8888/doc/tree/file.ipynb 19/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 20/30
3/6/24, 11:47 PM file
rmalization)
localhost:8888/doc/tree/file.ipynb 21/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 22/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 23/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 24/30
3/6/24, 11:47 PM file
']
localhost:8888/doc/tree/file.ipynb 25/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 26/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 27/30
3/6/24, 11:47 PM file
localhost:8888/doc/tree/file.ipynb 28/30
3/6/24, 11:47 PM file
ormalization)
localhost:8888/doc/tree/file.ipynb 29/30
3/6/24, 11:47 PM file
==================================================================================================
Total params: 2430663 (9.27 MB)
Trainable params: 2396551 (9.14 MB)
Non-trainable params: 34112 (133.25 KB)
__________________________________________________________________________________________________
The Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the ce
ll(s) to identify a possible cause of the failure. Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a>
for more info. View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details.
localhost:8888/doc/tree/file.ipynb 30/30