add files and code
1667
.ipynb_checkpoints/openmv clasification training-checkpoint.ipynb
Normal file
56
Openmv Code/boot.py
Normal file
@ -0,0 +1,56 @@
|
||||
import sensor
|
||||
import time
|
||||
import ml
|
||||
import display
|
||||
|
||||
sensor.reset() # Reset and initialize the sensor.
|
||||
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
|
||||
sensor.set_framesize(sensor.QQVGA2) # Special 128x160 framesize for LCD Shield.
|
||||
|
||||
sensor.skip_frames(time=2000) # Let the camera adjust.
|
||||
|
||||
|
||||
|
||||
model = ml.Model("model_quant.tflite", load_to_fb=True)
|
||||
|
||||
labels = [line.rstrip("\n") for line in open("labels.txt")]
|
||||
|
||||
clock = time.clock()
|
||||
lcd = display.SPIDisplay()
|
||||
|
||||
|
||||
while True:
|
||||
clock.tick()
|
||||
|
||||
img = sensor.snapshot()
|
||||
|
||||
|
||||
# This combines the labels and confidence values into a list of tuples
|
||||
# and then sorts that list by the confidence values.
|
||||
sorted_list = sorted(
|
||||
zip(labels, model.predict([img])[0].flatten().tolist()), key=lambda x: x[1], reverse=True
|
||||
)
|
||||
|
||||
x = []
|
||||
for i in range(len(sorted_list)):
|
||||
x.append(sorted_list[i][1])
|
||||
|
||||
x_max = max(x)
|
||||
x_min = min(x)
|
||||
|
||||
for i in range(len(x)):
|
||||
x[i] = (x[i]-x_min)/(x_max-x_min)
|
||||
|
||||
|
||||
x_max = max(x)
|
||||
print(x_max)
|
||||
|
||||
for i in range(len(x)):
|
||||
if x[i] == x_max:
|
||||
img.draw_rectangle(0,0,128,10,(0,0,0),fill=True)
|
||||
img.draw_string(2,0,"%s = %s" % (sorted_list[i][0], str(round(sorted_list[i][1],2))), (255,255,255))
|
||||
print("%s = %s" % (sorted_list[i][0], str(round(sorted_list[i][1],2))))
|
||||
|
||||
|
||||
lcd.write(img)
|
||||
print(clock.fps(), "fps")
|
5
Openmv Code/labels.txt
Normal file
@ -0,0 +1,5 @@
|
||||
ace
|
||||
card random
|
||||
jack
|
||||
king
|
||||
queen
|
BIN
Openmv Code/model_quant.tflite
Normal file
BIN
images/ace/00000.jpg
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
images/ace/00001.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/ace/00002.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/ace/00003.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/ace/00004.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/ace/00005.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/ace/00006.jpg
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
images/ace/00007.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/ace/00008.jpg
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
images/ace/00009.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/ace/00010.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/ace/00011.jpg
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
images/ace/00012.jpg
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
images/ace/00013.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/ace/00014.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/ace/00015.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/ace/00016.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/ace/00017.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/ace/00018.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/ace/00019.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/card random/00000.jpg
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
images/card random/00001.jpg
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
images/card random/00002.jpg
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
images/card random/00003.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/card random/00004.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/card random/00005.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/card random/00006.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/card random/00007.jpg
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/card random/00008.jpg
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
images/card random/00009.jpg
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
images/card random/00010.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
images/card random/00011.jpg
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
images/card random/00012.jpg
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
images/card random/00013.jpg
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
images/card random/00014.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
images/card random/00015.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
images/card random/00016.jpg
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
images/card random/00017.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/card random/00018.jpg
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/card random/00019.jpg
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
images/jack/00000.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/jack/00001.jpg
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
images/jack/00002.jpg
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
images/jack/00003.jpg
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
images/jack/00004.jpg
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
images/jack/00005.jpg
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/jack/00006.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/jack/00007.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/jack/00008.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/jack/00009.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/jack/00010.jpg
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
images/jack/00011.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/jack/00012.jpg
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
images/jack/00013.jpg
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
images/jack/00014.jpg
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
images/jack/00015.jpg
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
images/jack/00016.jpg
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/jack/00017.jpg
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/jack/00018.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/jack/00019.jpg
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
images/king/00000.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/king/00001.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/king/00002.jpg
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/king/00003.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/king/00004.jpg
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
images/king/00005.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/king/00006.jpg
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
images/king/00007.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/king/00008.jpg
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
images/king/00009.jpg
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
images/king/00010.jpg
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
images/king/00011.jpg
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/king/00012.jpg
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
images/king/00013.jpg
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/king/00014.jpg
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/king/00015.jpg
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/king/00016.jpg
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
images/king/00017.jpg
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/king/00018.jpg
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
images/king/00019.jpg
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
images/queen/00000.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/queen/00001.jpg
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/queen/00002.jpg
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/queen/00003.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/queen/00004.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/queen/00005.jpg
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
images/queen/00006.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/queen/01.jpg
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
images/queen/010.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/queen/02.jpg
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
images/queen/03.jpg
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
images/queen/04.jpg
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
images/queen/05.jpg
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
images/queen/06.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/queen/07.jpg
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/queen/08.jpg
Normal file
After Width: | Height: | Size: 3.3 KiB |