project restructurisation

This commit is contained in:
matixezor 2021-05-30 14:56:26 +02:00
parent cb4d638a0f
commit bbccb8bb98
2 changed files with 25 additions and 27 deletions

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]