neural_network #4

Merged
s452622 merged 34 commits from neural_network into master 2021-06-08 23:47:22 +02:00
2 changed files with 25 additions and 27 deletions
Showing only changes of commit bbccb8bb98 - Show all commits

View File

@ -0,0 +1,25 @@
import os
import cv2
IMG_SIZE = 28
CATEGORIES = ["bomby", "other"]
temp_path = os.path.abspath('../../..')
DIR = 'images\learning'
DIR = os.path.join(temp_path, DIR)
def create_training_data():
training_data = []
for category in CATEGORIES:
path = os.path.join(DIR, category)
category_index = CATEGORIES.index(category)
for img in os.listdir(path):
try:
img_array = cv2.imread(os.path.join(path, img), cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))
training_data.append((new_array, category_index))
except Exception as e:
print(e)
return training_data

View File

@ -1,27 +0,0 @@
import numpy as np
import os
import cv2
IMG_SIZE = 28
CATEGORIES = ["bomby","other"]
temp_path =os.path.abspath('../..')
DIR = 'images\learning'
DIR = os.path.join(temp_path, DIR)
def create_training_data():
training_data_label = []
training_data_images = []
for category in CATEGORIES:
path = os.path.join(DIR, category)
category_index = CATEGORIES.index(category)
for img in os.listdir(path):
try:
img_array = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize(img_array, (IMG_SIZE,IMG_SIZE))
training_data_label.append(category_index)
training_data_images.append(new_array)
except Exception as e:
pass
return [training_data_images, training_data_label]