From d80eb6db6c902e5db4960e4dcde555fa921fe390 Mon Sep 17 00:00:00 2001 From: nlitkowski Date: Sun, 9 Jun 2019 23:18:35 +0200 Subject: [PATCH] Working trash node generation image based --- Logic/TrashRecognition/ImageClassification.py | 10 +++---- Logic/TrashRecognition/__init__.py | 0 .../ImageClassification.cpython-36.pyc | Bin 0 -> 3718 bytes .../__pycache__/__init__.cpython-36.pyc | Bin 0 -> 173 bytes Logic/TrashRecognition/init.py | 0 UI/grid.py | 25 +++++++++++++----- 6 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 Logic/TrashRecognition/__init__.py create mode 100644 Logic/TrashRecognition/__pycache__/ImageClassification.cpython-36.pyc create mode 100644 Logic/TrashRecognition/__pycache__/__init__.cpython-36.pyc create mode 100644 Logic/TrashRecognition/init.py diff --git a/Logic/TrashRecognition/ImageClassification.py b/Logic/TrashRecognition/ImageClassification.py index d79ea84..88f5591 100644 --- a/Logic/TrashRecognition/ImageClassification.py +++ b/Logic/TrashRecognition/ImageClassification.py @@ -72,13 +72,13 @@ def load_labels(label_file): label.append(l.rstrip()) return label -def classify(model="Model/graph.pb", - label_file="Model/retrained_labels.txt", +def classify(model_file="Model/graph.pb", + label_file="Model/graph_labels.txt", input_height=299, input_width=299, input_mean=128, input_std=128, - input_layer="input", #"input", + input_layer="Mul", #"input", output_layer="final_result"): # "InceptionV3/Predictions/Reshape_1"): """Returns list of tuples consisting of name of file, category and certainity (0 - 1)""" graph = load_graph(model_file) @@ -112,7 +112,7 @@ def classify(model="Model/graph.pb", if __name__ == "__main__": model_file = "Model/graph.pb" - label_file = "Model/retrained_labels.txt" + label_file = "Model/graph_labels.txt" input_height = 299 input_width = 299 input_mean = 128 @@ -165,7 +165,7 @@ if __name__ == "__main__": if args.output_layer: output_layer = args.output_layer - classify(model=model_file, label_file=label_file, input_height=input_height, input_width=input_width, + classify(model_file=model_file, label_file=label_file, input_height=input_height, input_width=input_width, input_mean=input_mean, input_std=input_std, input_layer=input_layer, output_layer=output_layer) # for i in top_k: diff --git a/Logic/TrashRecognition/__init__.py b/Logic/TrashRecognition/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Logic/TrashRecognition/__pycache__/ImageClassification.cpython-36.pyc b/Logic/TrashRecognition/__pycache__/ImageClassification.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2e8281f01940dfe6ca6f3c42ceb4279404e12509 GIT binary patch literal 3718 zcmaJ@-H+SG5hp21qNs13?(92%(N3ILiO=VczSL-g1U4KPO$^s|lY+Q{;AvMn>L`*~ zQn8PqfTHI-9vt+w$RE%?^baEX*1X(H{{W}O^*77YS$5G#*x8xc56+1FzYd*SbtCZUKM|1O}ounc868%E?SSZ z?G>~>TeVl&n!U#L$(aMiKFiNe*4Y`>WM|p>A*_({25Yf%OY(WX!7i|ir{k9(TTAj~ z$XAx+_aMK&BwuA6_QBGAAF?jHb}FBP9q0M^$pzSblX|-idJ)nm)Y~1eApMzooWIH2yu-V^$5(ituktlEI5gk| z{i!mzengHOsCnDni9>&uaL1cQp-7-InD?z0dtm^+6$vj$oY5>8CeS<@!qxJpgLcsF zp~YW;B+5iRQ06Ln4ZW6>GK9o|_NqTGW!gl~N|W+|a)9vo8UgZK<%#lpB~vGr1Lajm zrPb9;dv_FuYL9YF>1m=!&U2vD# zrW-qqkKCD`*q!2Z&X_hJ?Lg1XX~?+mj69#`WjSEiPRDa~^jAeRaIn|>-reor#azVO zf$t@I;q!RU+rH1^y(Emb?_rPa$NR}{7;N9ZdFz)??T4F>ML6Mm$@UlF*c)y?6K=fw zgb%}U;L#m!Kb*Q_e$RK~*c*96mvlFx{oM3JmlXz{qf2dpD5{|vT0=dnnrdGYq&oT- zE;u>{H!RZ({Mu;5OJDp03{&T2rp+tllT69V2im-v!7r?Ipo-hjmf(*n(<$K&OLHT5 zEJv#teTLDpoKe9HgVhe<70kFHXPB4~$okh7p41p}$40RuG_}kCHSz5l`g&Gl zP4K3i+sMpJ&9t!wO&yvhS}Ut(r7mK6A*) zT;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8bSsqC!}OgpKuNA3mo;r_IGwSuoO~dLX7yJ<`TvjOs^P)Dlbb z^~DHcDJ=?%MeONr(xd6h!cJ)otb@~27`N>9w7-~CXp30`UZLVHiREB6 zjrPT_!P{n0%TOMl%d#PJOr}+l6^rPg<6+~UO^Y|j$y=X^@odV2L_U7;6evEQH(bUX zSR=>s5?=4QDThdj=MT{WCLWOW^uk>tvIHByLZHoj{t4Ys{3nnGLb{>RTNJHiG!>Qp m=DJZWxCJ#YQ7wM!uNkPyNRt!V(Te}Fj&`jedH!$HO!dF&i`G@;8P72p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CUs1_cF`>n&Ma40B zIhiHd`Q^pgnK3S@#n~nK1u@R~DXB35l_eSZc`-%?hL*ump1J`=`B|yiB{4qv>6ytf uAw`MB89}MZ`RRF?C7D2F@$s2JR(!l(LFFwDo80`A(wtN~ke$Uq%m4t^tS`g> literal 0 HcmV?d00001 diff --git a/Logic/TrashRecognition/init.py b/Logic/TrashRecognition/init.py new file mode 100644 index 0000000..e69de29 diff --git a/UI/grid.py b/UI/grid.py index b79039a..dd672b1 100644 --- a/UI/grid.py +++ b/UI/grid.py @@ -3,8 +3,11 @@ import numpy as np import random as rd from os import listdir from os.path import isfile, join +from Logic.TrashRecognition.ImageClassification import classify - +# MODULE LEVEL VARIABLES +trash_files = classify() +######################## class Grid: @@ -91,16 +94,24 @@ class House: self.empty = True self.trash = None self.trash_file = None + def find_trash_file(self, trash): - trash_files_list = [] + # trash_files_list = [] - file_names = [f for f in listdir("Images\\TestImages") if isfile(join("Images\\TestImages", f))] - #filter names - for f in file_names: - if trash[2] in f: - trash_files_list.append(f) + # file_names = [f for f in listdir("Images\\TestImages") if isfile(join("Images\\TestImages", f))] + # #filter names + # for f in file_names: + # if trash[2] in f: + # trash_files_list.append(f) + + trash_files_list = [] + # filter names + for f in trash_files: + if trash[2] in f[1]: + trash_files_list.append(f[0]) + f = rd.randint(0,len(trash_files_list)) return trash_files_list[f-1]