PreNeuralNetwork
This commit is contained in:
parent
29061f54ad
commit
efda9dd3e9
@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PyCharmProfessionalAdvertiser">
|
||||||
|
<option name="shown" value="true" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
40
bin/Main/NeuralNetwork.py
Normal file
40
bin/Main/NeuralNetwork.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
|
import keras
|
||||||
|
from keras.models import Sequential
|
||||||
|
from keras.layers import Dense, Conv2D , MaxPool2D , Flatten , Dropout
|
||||||
|
from keras.preprocessing.image import ImageDataGenerator
|
||||||
|
from keras.optimizers import Adam
|
||||||
|
|
||||||
|
from sklearn.metrics import classification_report,confusion_matrix
|
||||||
|
|
||||||
|
import tensorflow as tf
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
import os
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
labels = ['house', 'other']
|
||||||
|
img_size = 500
|
||||||
|
|
||||||
|
def get_data(data_dir):
|
||||||
|
data = []
|
||||||
|
for label in labels:
|
||||||
|
path = os.path.join(data_dir, label)
|
||||||
|
class_num = labels.index(label)
|
||||||
|
for img in os.listdir(path):
|
||||||
|
try:
|
||||||
|
img_arr = cv2.imread(os.path.join(path, img))[..., ::-1] # Convert BGR to RGB format
|
||||||
|
resized_arr = cv2.resize(img_arr, (img_size, img_size)) # Reshaping images to preferred size
|
||||||
|
data.append([resized_arr, class_num])
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return np.array(data)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
14
bin/Main/temp.py
Normal file
14
bin/Main/temp.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import tensorflow as tf
|
||||||
|
from tensorflow import keras
|
||||||
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
fashion_mnist = keras.datasets.fashion_mnist
|
||||||
|
(X_train_full, y_train_full), (X_test, y_test) = fashion_mnist.load_data()
|
||||||
|
|
||||||
|
# 16777216 - because 24 bits color pixels = 2^24
|
||||||
|
X_valid, X_train = X_train_full[:5000] / 16777216., X_train_full[5000:] / 16777216.
|
||||||
|
y_valid, y_train = y_train_full[:5000], y_train_full[5000:]
|
||||||
|
X_test = X_test / 16777216
|
||||||
|
|
Loading…
Reference in New Issue
Block a user