Upload files to ''
This commit is contained in:
parent
67b1aac125
commit
39ff697ec7
33
neurons.py
33
neurons.py
@ -11,13 +11,13 @@ class Neurons:
|
|||||||
output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]
|
output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]
|
||||||
return output_layers
|
return output_layers
|
||||||
def whatIsIt(self, path):
|
def whatIsIt(self, path):
|
||||||
"""image = cv2.imread(path)
|
image = cv2.imread(path)
|
||||||
scale = 0.00392
|
scale = 0.00392
|
||||||
classes = None
|
classes = None
|
||||||
with open("yolov3.txt", 'r') as f:
|
with open("yolov3.txt", 'r') as f:
|
||||||
classes = [line.strip() for line in f.readlines()]
|
classes = [line.strip() for line in f.readlines()]
|
||||||
net = cv2.dnn.readNet("yolov3.weights", "yolov3.cfg")
|
net = cv2.dnn.readNet("yolov3.weights", "yolov3.cfg")
|
||||||
blob = cv2.dnn.blobFromImage(image, scale, (416, 416), (0, 0, 0), True, crop=False)
|
blob = cv2.dnn.blobFromImage(image, scale, (608, 608), (0, 0, 0), True, crop=False)
|
||||||
net.setInput(blob)
|
net.setInput(blob)
|
||||||
outs = net.forward(self.get_output_layers(net))
|
outs = net.forward(self.get_output_layers(net))
|
||||||
class_ids = []
|
class_ids = []
|
||||||
@ -26,19 +26,30 @@ class Neurons:
|
|||||||
scores = detection[5:]
|
scores = detection[5:]
|
||||||
class_id = np.argmax(scores)
|
class_id = np.argmax(scores)
|
||||||
confidence = scores[class_id]
|
confidence = scores[class_id]
|
||||||
if confidence > 0.5:
|
if confidence > 0.2:
|
||||||
class_ids.append(class_id)
|
class_ids.append(class_id)
|
||||||
print([classes[ids] for ids in class_ids])"""
|
y = [classes[ids] for ids in class_ids]
|
||||||
x = [1, 0, 0, 0, 0]
|
print(y)
|
||||||
numpy.random.shuffle(x)
|
x = [0, 0, 0, 0, 0]
|
||||||
|
if "kruche" in y:
|
||||||
|
x[1]=1
|
||||||
|
elif "niebezpieczne" in y:
|
||||||
|
x[4]=1
|
||||||
|
elif "biohazard" in y:
|
||||||
|
x[4]=1
|
||||||
|
elif "radioaktywne" in y:
|
||||||
|
x[3]=1
|
||||||
|
elif "latwopalne" in y:
|
||||||
|
x[2]=1
|
||||||
|
print(x)
|
||||||
if x[0]==1:
|
if x[0]==1:
|
||||||
print("Zwykła")
|
print("Zwykła")
|
||||||
elif x[1]==1:
|
if x[1]==1:
|
||||||
print("Kruchy")
|
print("Kruchy")
|
||||||
elif x[2]==1:
|
if x[2]==1:
|
||||||
print("Łatwopalny")
|
print("Łatwopalny")
|
||||||
elif x[3]==1:
|
if x[3]==1:
|
||||||
print("Radioaktywny")
|
print("Radioaktywny")
|
||||||
elif x[4]==1:
|
if x[4]==1:
|
||||||
print("Niebezpieczny")
|
print("Niebezpieczny")
|
||||||
return [list(x)]
|
return [list(x)]
|
||||||
|
Loading…
Reference in New Issue
Block a user