Skip to content

Instantly share code, notes, and snippets.

@anoken
Last active January 8, 2020 09:41
Show Gist options
  • Save anoken/29533264543b6fd19485e86032f73996 to your computer and use it in GitHub Desktop.
Save anoken/29533264543b6fd19485e86032f73996 to your computer and use it in GitHub Desktop.
MaixPy_KPU_MobileNet_V1_a=0.75 vs a=0.5
## Copyright (c) 2019 aNoken
import image, lcd, sensor,gc
import KPU as kpu
lcd.init()
lcd.rotation(2)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((224, 224))
sensor.run(1)
clock = time.clock()
print(kpu.memtest())
task1 = kpu.load(0x200000)
print(kpu.memtest())
task2 = kpu.load(0x400000)
print(kpu.memtest())
kpu.set_layers(task1,29)
kpu.set_layers(task2,29)
img = sensor.snapshot()
start = time.ticks_us()
fmap1 = kpu.forward(task1, img)
task1_time = time.ticks_us()
fmap2 = kpu.forward(task2, img)
task2_time = time.ticks_us()
print(start)
print(task1_time)
print(task2_time)
task1_time_ms = time.ticks_diff(task1_time,start )/1000.0
task2_time_ms = time.ticks_diff(task2_time,task1_time )/1000.0
print("MicroPython v0.5.0-12-g284ce83d6-dirty ")
print("MobileNet(input_shape=(224, 224, 3), alpha = 0.5)")
print("model_size()",task1.model_size()/1024,"KB")
print("Time: " + str(task1_time_ms) + " ms")
print("MobileNet(input_shape=(224, 224, 3), alpha = 0.75)")
print("model_size()",task2.model_size()/1024,"KB")
print("Time: " + str(task2_time_ms) + " ms")
MicroPython v0.5.0-12-g284ce83d6-dirty
MobileNet(input_shape=(224, 224, 3), alpha = 0.5)
model_size() 902.9453 KB
Time: 18.758 ms
MobileNet(input_shape=(224, 224, 3), alpha = 0.75)
model_size() 1918.195 KB
Time: 36.074 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment