This commit is contained in:
Kamila Bobkowska 2020-05-24 14:17:49 +00:00
parent cd70306d93
commit 2eb83a3d02

View File

@ -57,21 +57,29 @@ trainingFileNames, testFileNames = np.split(np.array(allFileNames), [int(len(all
## Implementation
Functions in garbageDumpSorting.py:
* createSets - divides images between test and training set. This function should be run only once, unless the folders with training and test set are removed,
```
trainingFileNames, testFileNames = np.split(np.array(allFileNames), [int(len(allFileNames) * (1 - testRatio))])
```
* huMoments, haralick, histogram - calculate global feature descriptors,
* processTrainData, processTestData - both work in the same way, they iterate over files in train or test directory, saves features as a matrix and then saves results to h5 file, it is recommended to run it only once as it takes some time to finish.
```
allFeatures = np.hstack([histo, hara, huMoments])
```
* trainAndTest - creates classifier, trains it and scores it,
```
clf = RandomForestClassifier(n_estimators=100, max_depth=15, random_state=9)
```
* classifyImage - predicts what kind of garbage is visible on a single image,
```
prediction = clf.predict(features)[0]
```
* sortDump - checks what kinds of trash are inside the garbage truck and their quantity, empties the garbage truck and sorts its contents on the garbage dump.