stworzony raport

This commit is contained in:
Adam Osiowy 2020-05-13 01:06:23 +02:00
parent 015b60a006
commit 00d0db8dcb
112 changed files with 140 additions and 1 deletions

123
adamORaport.md Normal file
View File

@ -0,0 +1,123 @@
# Sztuczna Inteligencja
**Temat projektu:** Inteligenta Śmieciarka
**Zespół:** Kacper Borkowski, Adam Borowski, Adam Osiowy
**Podprojekt:** Adam Osiowy - *segregator śmieci*
---
## Opis podprojektu:
- w projekcie wykorzystane zostały drzewa decyzyjne jako metoda uczenia
- projekt podzielony jest na 4 pliki
- plik tworzenie_danych_AO.py jest odpowiedzialny za wydobycie z każdego zdjęcia własności i zapis ich do pliku
![4](resources/screenShots/adamo4.png)
- w pliku uczenie_adamO.py znajdują się funkcje odpowiedzialne za uczenie i testowanie modelu
![5](resources/screenShots/adamo5.png)
- plik parametry_zdjec.h5 zawiera własności wszystkich zdjęć wykorzystanych w projekcie
- plik etykiety.h5 zawiera odpowiedni typ każdego ze zdjęć (glass,paper,plastic,metal)
---
## Ogólne działanie:
- na początku zbierane są informacje o każdym zdjęciu
```
momenty = wyznaczHuMomenty(zdj)
haralick = wyznaczHaralick(zdj)
histogram = wyznaczHistogram(zdj)
```
- wybrane własności to:
1. Histogram kolorów okreslający rozkład jasności pixeli w każdej komórce na zdjęciu w skali szarości
![6](resources/screenShots/adamo6.png)
zdjęcie jest przekształcane do przestrzeni barw hsv
po czym wyliczany jest histogram podając do funkcji zdjęcie, kanały (hsv), maskę, podział zdjęcia na 512 przedziałów (8x8x8), zakres każdego kanału
2. Momenty obrazu (Hu Moments) określające kształt obiektu na zdjęciu
![8](resources/screenShots/adamo8.png)
są średnią ważoną intensywności pikseli obrazu.
Są liczone ze wzoru:
![10](resources/screenShots/adamo10.png)
gdzie I(x,y) to intensywność pixela w danym punkcie
*Momenty surowe* - informują o intensywności pikseli i ich położeniu na obrazie
*Momenty centralne* - otrzymujemy po odjęciu od momentów surowych środka ciężkości danego kształtu
![11](resources/screenShots/adamo11.png)
momenty te są niezmienne w wyliczaniu to znaczy że jeśli kształt jest ten sam to nie ważne jest jego położenie na zdjęciu
*Momenty Hu* - to zbiór 7 liczb obliczonych na podstawie momentów centralnych.
Pierwsze 6 momentów są niezmienne dla translacji, skali i rotacji.
Podczas gdy znak siódmej liczby zmienia się wraz z odbiciem kształu (względem osi).
![12](resources/screenShots/adamo12.png)
3. Tekstura Haralicka określająca nasycenie ilości pixeli w skali szarości
![7](resources/screenShots/adamo7.png)
Haralick zasugerował zastosowanie macierzy współwystępowania poziomu szarości (GLCM).
Ta metoda opiera się na połączonych rozkładach prawdopodobieństwa par pikseli.
GLCM pokazuje, jak często każdy poziom szarości występuje w pikselach umieszczonych w ustalonym położeniu
geometrycznym względem siebie, w zależności od poziomu szarości
![13](resources/screenShots/adamo13.png)
- własności sa zapisywane jako macierze, ustawiane w szereg jako wiersz i zapisywane do pliku z danymi .h5
```
wiersz = np.hstack([momenty, histogram, haralick])
```
- dane dzielone są losowo na 2 pary, jedna testowa druga treningowa
```
(uczenieDane, testowanieDane, uczenieEtykiety, testowanieEtykiety) =
train_test_split(np.array(dane), np.array(etykiety), test_size=rozmiar_zbioru_testowego)
```
gdzie rozmiar zbioru testowego określony wcześniej na 20%
- tworzony jest estymator
```
rfc = RandomForestClassifier(max_depth=15, n_jobs=4, random_state=1)
```
gdzie n_jobs to ilość wątków, random_state pilnuje aby zbiór był zawsze dzielony tak samo,
a max_depth to maksymalna głebokość każdego drzewa
estymator domyślnie korzysta ze strategii opierającej się o indeks Giniego
```
'indeks Giniego jest to miara która określa jak często losowo wybrany element zostanie błędnie zidentyfikowany'
```
to znaczy ze element z najmniejszym indeksem Giniego powinien zostać wybrany
indeks jest obliczany ze wzoru:
![9](resources/screenShots/adamo9.png)
[przykład](https://www.geeksforgeeks.org/decision-tree-introduction-example/)
- estymator rozpoczyna uczenie korzystając ze zbiorów treningowych
```
rfc.fit(uczenieDane, uczenieEtykiety)
```
- następnie wyliczana jest skuteczność na zbiorach testowych
```
rfc.score(testowanieDane, testowanieEtykiety)
```
---
## Integracja z projektem zespołowym:
- Przy starcie programu estymator rozpoczyna nauke
```
rfc = adamO.rozpocznijUczenie()
```
- Śmieciarka porusza się po domach zbierając z nich śmieci
- Po zebraniu wszystkich śmieci kieruje się na wysypisko
- Każde zdjęcie śmieci jest segregowane z wykorzystaniem funkcji przewidującej typ
```
rodzaj = adamO.przewidz(smiec, rfc)
```
![3](resources/screenShots/adamo3.png)
- Zdjęcia posegregowanych śmieci umieszczane są w odpowiednich folderach:
![1](resources/screenShots/adamo1.png)
- Na koniec wyświetlane są losowo wybrane zdjęcia śmieci z kontenerów wraz z informacją o typie ustalonym przez estymator
![2](resources/screenShots/adamo2.png)
1. górny napis to typ zwrócony przez estymator
2. drugi napis to wartości prawpopodobieństwa z jakim estymator ocenił typ
3. trzeci napis to nazwa zdjęcia
---
## Efekt działania programu w postaci drzewa decyzyjnego:
![10](graph.png)

BIN
graph.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

@ -1,2 +1,4 @@
pygame==1.9.6
numpy==1.18
Keras==2.3.1
tensorflow==2.2.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Some files were not shown because too many files have changed in this diff Show More