AI_PRO/createNeuralNetworkDatabase.py

42 lines
1.2 KiB
Python
Raw Normal View History

2021-06-01 22:47:53 +02:00
import os
import cv2
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
path_potatoes = 'neural_network\\images\\potatoes'
path_beetroot = 'neural_network\\images\\beetroot'
size = 250
#POTATOES
training_data_potatoes = []
for img in os.listdir(path_potatoes):
pic = cv2.imread(os.path.join(path_potatoes,img))
pic = cv2.cvtColor(pic,cv2.COLOR_BGR2RGB)
pic = cv2.resize(pic,(size,size))
training_data_potatoes.append([pic])
2021-06-02 01:32:48 +02:00
2021-06-01 22:47:53 +02:00
np.save(os.path.join('neural_network','potatoes-dataset'),np.array(training_data_potatoes))
saved_potatoes = np.load(os.path.join('neural_network','potatoes-dataset.npy'))
#BEETROOT
training_data_beetroot = []
for img in os.listdir(path_beetroot):
pic = cv2.imread(os.path.join(path_beetroot,img))
pic = cv2.cvtColor(pic,cv2.COLOR_BGR2RGB)
pic = cv2.resize(pic,(size,size))
training_data_beetroot.append([pic])
np.save(os.path.join('neural_network','beetroot-dataset'),np.array(training_data_beetroot))
saved_potatoes = np.load(os.path.join('neural_network','beetroot-dataset.npy'))
2021-06-02 01:32:48 +02:00
dict = {
'beetroots': training_data_beetroot,
'potatoes': training_data_potatoes
}
print(dict)
np.save(os.path.join('neural_network','dataset'), np.array(dict))