Neural_network #4
34
source/NN/neural_network.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import torch
|
||||||
|
import torch.nn as nn
|
||||||
|
from torch.utils.data import DataLoader
|
||||||
|
from torchvision import datasets, transforms
|
||||||
|
from torchvision.transforms import Compose, Lambda, ToTensor
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
#data transform to tensors:
|
||||||
|
data_transformer = transforms.Compose
|
||||||
|
([
|
||||||
|
transforms.Resize((150, 150)),
|
||||||
|
transforms.ToTensor(),
|
||||||
|
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#loading data:
|
||||||
|
train_set = datasets.ImageFolder(root='source/resources/train', transform=data_transformer)
|
||||||
|
test_set = datasets.ImageFolder(root='source/resources/test', transform=data_transformer)
|
||||||
|
|
||||||
|
|
||||||
|
#to mozna nawet przerzucic do funkcji train:
|
||||||
|
train_loader = DataLoader(train_set, batch_size=32, shuffle=True, num_workers=2)
|
||||||
|
test_loader = DataLoader(test_set, batch_size=32, shuffle=True, num_workers=2)
|
||||||
|
|
||||||
|
#test if classes work properly:
|
||||||
|
print(train_set.classes)
|
||||||
|
print(train_set.class_to_idx)
|
||||||
|
print(train_set.targets[3002])
|
||||||
|
|
||||||
|
#loading your own image: <-- zrobię to na koniec - wrzucanie konkretnego obrazka aby uzyskac wynik
|
||||||
|
|
BIN
source/resources/test/Apple/img_1001.jpeg
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
source/resources/test/Apple/img_1071.jpeg
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
source/resources/test/Apple/img_1091.jpeg
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
source/resources/test/Apple/img_1101.jpeg
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
source/resources/test/Apple/img_1111.jpeg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
source/resources/test/Apple/img_1121.jpeg
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
source/resources/test/Apple/img_1131.jpeg
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
source/resources/test/Apple/img_1141.jpeg
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
source/resources/test/Apple/img_1181.jpeg
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
source/resources/test/Apple/img_1201.jpeg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
source/resources/test/Apple/img_1211.jpeg
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
source/resources/test/Apple/img_1221.jpeg
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
source/resources/test/Apple/img_1241.jpeg
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
source/resources/test/Apple/img_1251.jpeg
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
source/resources/test/Apple/img_1261.jpeg
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
source/resources/test/Apple/img_1271.jpeg
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
source/resources/test/Apple/img_1281.jpeg
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
source/resources/test/Apple/img_1301.jpeg
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
source/resources/test/Apple/img_1311.jpeg
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
source/resources/test/Apple/img_1321.jpeg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
source/resources/test/Apple/img_1331.jpeg
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
source/resources/test/Apple/img_1341.jpeg
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
source/resources/test/Apple/img_1351.jpeg
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
source/resources/test/Apple/img_1361.jpeg
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
source/resources/test/Apple/img_1401.jpeg
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
source/resources/test/Apple/img_1411.jpeg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
source/resources/test/Apple/img_1451.jpeg
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
source/resources/test/Apple/img_1461.jpeg
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
source/resources/test/Apple/img_1521.jpeg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
source/resources/test/Apple/img_1531.jpeg
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
source/resources/test/Apple/img_1541.jpeg
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
source/resources/test/Apple/img_1571.jpeg
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
source/resources/test/Apple/img_1581.jpeg
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
source/resources/test/Apple/img_1591.jpeg
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
source/resources/test/Apple/img_1601.jpeg
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
source/resources/test/Apple/img_1611.jpeg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
source/resources/test/Apple/img_1621.jpeg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
source/resources/test/Apple/img_1671.jpeg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
source/resources/test/Apple/img_1711.jpeg
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
source/resources/test/Apple/img_1741.jpeg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
source/resources/test/Apple/img_1771.jpeg
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
source/resources/test/Apple/img_1781.jpeg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
source/resources/test/Apple/img_1801.jpeg
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
source/resources/test/Apple/img_1811.jpeg
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
source/resources/test/Apple/img_1821.jpeg
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
source/resources/test/Apple/img_1831.jpeg
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
source/resources/test/Apple/img_1841.jpeg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
source/resources/test/Apple/img_1851.jpeg
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
source/resources/test/Apple/img_1911.jpeg
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
source/resources/test/Apple/img_1921.jpeg
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
source/resources/test/Apple/img_1931.jpeg
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
source/resources/test/Apple/img_1941.jpeg
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
source/resources/test/Apple/img_2011.jpeg
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
source/resources/test/Apple/img_2021.jpeg
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
source/resources/test/Apple/img_2041.jpeg
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
source/resources/test/Apple/img_2071.jpeg
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
source/resources/test/Apple/img_2101.jpeg
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
source/resources/test/Apple/img_2181.jpeg
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
source/resources/test/Apple/img_2201.jpeg
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
source/resources/test/Apple/img_2251.jpeg
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
source/resources/test/Apple/img_2261.jpeg
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
source/resources/test/Apple/img_2301.jpeg
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
source/resources/test/Apple/img_2311.jpeg
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
source/resources/test/Apple/img_2321.jpeg
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
source/resources/test/Apple/img_2351.jpeg
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
source/resources/test/Apple/img_2411.jpeg
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
source/resources/test/Apple/img_2531.jpeg
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
source/resources/test/Apple/img_2541.jpeg
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
source/resources/test/Apple/img_2571.jpeg
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
source/resources/test/Apple/img_2591.jpeg
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
source/resources/test/Apple/img_2611.jpeg
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
source/resources/test/Apple/img_2651.jpeg
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
source/resources/test/Apple/img_2681.jpeg
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
source/resources/test/Apple/img_2691.jpeg
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
source/resources/test/Apple/img_2701.jpeg
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
source/resources/test/Apple/img_2721.jpeg
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
source/resources/test/Apple/img_2731.jpeg
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
source/resources/test/Apple/img_2751.jpeg
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
source/resources/test/Apple/img_2761.jpeg
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
source/resources/test/Apple/img_2771.jpeg
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
source/resources/test/Apple/img_2841.jpeg
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
source/resources/test/Apple/img_2871.jpeg
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
source/resources/test/Apple/img_2881.jpeg
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
source/resources/test/Apple/img_2931.jpeg
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
source/resources/test/Apple/img_2981.jpeg
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
source/resources/test/Apple/img_3061.jpeg
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
source/resources/test/Apple/img_3101.jpeg
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
source/resources/test/Apple/img_3131.jpeg
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
source/resources/test/Apple/img_3191.jpeg
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
source/resources/test/Apple/img_3241.jpeg
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
source/resources/test/Apple/img_3251.jpeg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
source/resources/test/Apple/img_3301.jpeg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
source/resources/test/Apple/img_3351.jpeg
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
source/resources/test/Apple/img_3361.jpeg
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
source/resources/test/Apple/img_3371.jpeg
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
source/resources/test/Apple/img_3381.jpeg
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
source/resources/test/Apple/img_3451.jpeg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
source/resources/test/Apple/img_3481.jpeg
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
source/resources/test/Apple/img_3501.jpeg
Normal file
After Width: | Height: | Size: 5.9 KiB |