Working trash node generation image based

This commit is contained in:
nlitkowski 2019-06-09 23:18:35 +02:00
parent 991398e162
commit d80eb6db6c
6 changed files with 23 additions and 12 deletions

View File

@ -72,13 +72,13 @@ def load_labels(label_file):
label.append(l.rstrip()) label.append(l.rstrip())
return label return label
def classify(model="Model/graph.pb", def classify(model_file="Model/graph.pb",
label_file="Model/retrained_labels.txt", label_file="Model/graph_labels.txt",
input_height=299, input_height=299,
input_width=299, input_width=299,
input_mean=128, input_mean=128,
input_std=128, input_std=128,
input_layer="input", #"input", input_layer="Mul", #"input",
output_layer="final_result"): # "InceptionV3/Predictions/Reshape_1"): output_layer="final_result"): # "InceptionV3/Predictions/Reshape_1"):
"""Returns list of tuples consisting of name of file, category and certainity (0 - 1)""" """Returns list of tuples consisting of name of file, category and certainity (0 - 1)"""
graph = load_graph(model_file) graph = load_graph(model_file)
@ -112,7 +112,7 @@ def classify(model="Model/graph.pb",
if __name__ == "__main__": if __name__ == "__main__":
model_file = "Model/graph.pb" model_file = "Model/graph.pb"
label_file = "Model/retrained_labels.txt" label_file = "Model/graph_labels.txt"
input_height = 299 input_height = 299
input_width = 299 input_width = 299
input_mean = 128 input_mean = 128
@ -165,7 +165,7 @@ if __name__ == "__main__":
if args.output_layer: if args.output_layer:
output_layer = 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) input_mean=input_mean, input_std=input_std, input_layer=input_layer, output_layer=output_layer)
# for i in top_k: # for i in top_k:

View File

View File

View File

@ -3,8 +3,11 @@ import numpy as np
import random as rd import random as rd
from os import listdir from os import listdir
from os.path import isfile, join from os.path import isfile, join
from Logic.TrashRecognition.ImageClassification import classify
# MODULE LEVEL VARIABLES
trash_files = classify()
########################
class Grid: class Grid:
@ -92,14 +95,22 @@ class House:
self.trash = None self.trash = None
self.trash_file = None self.trash_file = None
def find_trash_file(self, trash): def find_trash_file(self, trash):
# 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)
trash_files_list = [] trash_files_list = []
file_names = [f for f in listdir("Images\\TestImages") if isfile(join("Images\\TestImages", f))] # filter names
#filter names for f in trash_files:
for f in file_names: if trash[2] in f[1]:
if trash[2] in f: trash_files_list.append(f[0])
trash_files_list.append(f)
f = rd.randint(0,len(trash_files_list)) f = rd.randint(0,len(trash_files_list))
return trash_files_list[f-1] return trash_files_list[f-1]