CorgiDude บอร์ดกับการทำ Cat Face Detection โดยใช้ Yolo2







PreviousCorgiDude บอร์ด ตรวจจับใบหน้าด้วย Yolo Face DetectionNextการทำ Dataset แบบ Object Detection ชนิด VOC ที่สามารถเอาไปใช้ตอนเทรนใน Yolo2 ได้เลย
Last updated







Last updated
import sensor,image,lcd,time
import KPU as kpu
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((224, 224))
sensor.set_vflip(1)
sensor.run(1)
lcd.init(type=2, freq=20000000, color=lcd.BLACK)
lcd.rotation(2)
clock = time.clock()
classes = ['face','eye']
task = kpu.load(0x400000)
a = kpu.set_outputs(task, 0, 7,7,35)
anchor = (0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828)
a = kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
while(True):
img = sensor.snapshot()
#a= img.resize(224,224)
a = img.pix_to_ai()
code = kpu.run_yolo2(task, img)
if code:
for i in code:
a=img.draw_rectangle(i.rect(),color = (0, 255, 0),thickness=4)
a = lcd.display(img)
a = kpu.deinit(task)