728x90
반응형

데이터라벨링 6

[딥러닝] 사용자 데이터로 CNN 학습하기- 6. 시험 데이터로 확인해보기

6. 시험 데이터로 확인해보기 _04_cnn_training_5.py from _04_cnn_training_3 import * from tensorflow.keras.models import load_model import matplotlib.pyplot as plt model1=load_model('model.h5') # Model predictions for the testing dataset y_test_predict=model1.predict(x_test) print(y_test_predict.shape, y_test_predict[0]) y_test_predict=np.argmax(x_test_predict, axis=1) print(y_test_predict.shape, y_test_pred..

[딥러닝] 사용자 데이터로 CNN 학습하기- 5. 인공신경망 학습시키기

5. 인공신경망 학습시키기 _04_cnn_training_4.py from _04_cnn_training_3 import * import tensorflow as tf model=tf.keras.Sequential([ # donkey car CNN tf.keras.layers.Conv2D(24,(5,5), strides=(2,2), padding='same', activation='relu', input_shape=x_train.shape[1:]), tf.keras.layers.Dropout(0.2), tf.keras.layers.Conv2D(32,(5,5), strides=(2,2), padding='same', activation='relu'), tf.keras.layers.Dropout(0.2), ..

[딥러닝] 사용자 데이터로 CNN 학습하기- 4. 훈련, 검증, 시험 데이터 분리하기

4. 훈련, 검증, 시험 데이터 분리하기. 훈련 데이터 80%, 검증 데이터 10%, 시험 데이터 10%로 임의로 분리합니다. 훈련 데이터는 인공신경망 학습에 사용 검증 데이터는 학습 도중에 검증용으로 사용 시험 데이터는 학습이 끝난 후에 사용합니다. _04_cnn_training_3.py from _04_cnn_training_1 import * from tensorflow.keras.utils import to_categorical from sklearn.model_selection import train_test_split tensors=tensors.astype('float32')/255 targets=to_categorical(targets, 4) x_train, x_test, y_train, ..

[딥러닝] 사용자 데이터로 CNN 학습하기- 3. 수집한 이미지 출력해보기

3. 수집한 이미지 출력해보기 _04_cnn_training_2.py from _04_cnn_training_1 import * import cv2 import matplotlib.pyplot as plt # Name list names=['_0_forward','_1_right','_2_left','_3_stop'] def display_images(img_path, ax): img=cv2.imread(os.path.join(dirname,img_path)) ax.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) fig=plt.figure(figsize=(10,3)) for i in range(4): ax=fig.add_subplot(1,4,i+1,xticks=[], yti..

[딥러닝] 사용자 데이터로 CNN 학습하기- 2. 수집한 데이터 불러오기

2. 수집한 데이터 불러오기 수집한 데이터를 읽어와서 인공 신경망에서 사용할 수 있는 텐서로 변경합니다. 텐서는 3차원 이상의 행렬을 의미하며 프로그래밍 언어 관점에서는 3차원 이상의 배열이 됩니다. 04_cnn_training_1.py from tensorflow.keras.preprocessing import image as keras_image import os import numpy as np from tqdm import tqdm from PIL import ImageFile import pandas as pd dirname="data.1695035538.287210" def image_to_tensor(img_path): img=keras_image.load_img( os.path.join(d..

[딥러닝] 사용자 데이터로 CNN 학습하기- 1. 라벨링하기

1. 라벨링하기 수집한 이미지 데이터에 라벨링 작업을 합니다. _03_data_labelling.py import os import csv dataDir='data.1695035538.287210' # 데이터 저장 디렉토리 print(os.getcwd()) # 현재 디렉터리 어딘지 확인(cwd=current working directory) os.chdir(dataDir) # 디렉터리 이동(change directory) roadDirs=os.listdir() # 현재 디렉터리 확인 print(roadDirs) f_csv=open('0_road_labels.csv','w',newline='') wr=csv.writer(f_csv) wr.writerow(["file","label","labelNames"]..

728x90
반응형