AIWintermuteAI / aXeleRate

Keras-based framework for AI on the Edge
MIT License
176 stars 71 forks source link

Maixpy Load error 2: ERR KMODEL VERSION: only supported kmodel v3/v4 now #11

Closed nicolaivalenti closed 4 years ago

nicolaivalenti commented 4 years ago

Hi, this is the error I get when I try to run my detectors (both the custom detectors and the ones in the Yolo example). The only models that I was able to make work are the Smodels generated by the Maixhub. I tried many versions with the same results, here you can see a screen while I was running the script boot.py with the firmware v0.5.0_31

Cattura

AIWintermuteAI commented 4 years ago

Hi! Well, first thing I can see is that you need to set the outputs of the model, as in this example :) https://github.com/AIWintermuteAI/aXeleRate/blob/bb7f3deda509d7f310b231fa9a39d0b529eb35f5/example_scripts/k210/detector/racoon_detector.py#L14

Let's see if it solves the problem or gives us a better clue

nicolaivalenti commented 4 years ago

a = kpu.set_outputs(task, 0, 7,7,30) #the actual shape needs to match the last layer shape of your model(before Reshape)

Unfortunately, I got the same result sec

nicolaivalenti commented 4 years ago

I tried to modify the final layer shape with mine (0,7,7,125) but it gave me the same result, the program does not even get there, it stops at the model loading

nicolaivalenti commented 4 years ago

Alright, just to give some updates I tried to run my model (created with the notebook) inside the sample script for the 20 classes yolo demo, of course changing the parameters to fit my model and I got the kpu load error 6: memory not enough ehh

AIWintermuteAI commented 4 years ago

You closed the issue? Have you found the solution? If you did, can you describe it here, it will help other people to solve similar problems in the future :)

nicolaivalenti commented 4 years ago

Sure, I was going to do that but I encountered some other issues (running the model it was not detecting any object, despite the Colab testing was working well, do not know why). Anyway, this is the code that worked for me at least to run the script without system errors:

`#refer to http://blog.sipeed.com/p/677.html import sensor,image,lcd,time import KPU as kpu

lcd.init(freq=15000000) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.set_vflip(1) sensor.run(1) clock = time.clock() classes = ["person", "bird", "cat", "cow", "dog", "horse", "sheep", "aeroplane", "bicycle", "boat", "bus", "car", "motorbike", "train","bottle", "chair", "diningtable", "pottedplant", "sofa", "tvmonitor"] task = kpu.load(0x500000) a = kpu.set_outputs(task, 0, 7,7,125) 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.3, 0.3, 5, anchor) while(True): clock.tick() img = sensor.snapshot() code = kpu.run_yolo2(task, img) print(clock.fps()) if code: for i in code: a=img.draw_rectangle(i.rect()) a = lcd.display(img) for i in code: lcd.draw_string(i.x(), i.y(), classes[i.classid()], lcd.RED, lcd.WHITE) lcd.draw_string(i.x(), i.y()+12, '%.3f'%i.value(), lcd.RED, lcd.WHITE) else: a = lcd.display(img) a = kpu.deinit(task)`

If you have my same issue and get the memory error or the Kmodel version error, use a minimum firmware version with the IDE support (5.0_31 worked for me) and remember to press the reset button between one try and the successive one.

AIWintermuteAI commented 4 years ago

What is your model backend? Mobilenet7_5 or Mobilenet 1_0? I can have a look at the colab notebooks, if you're okay with that. You can add me on LinkedIn and share privately if sharing here is not okay.

nicolaivalenti commented 4 years ago

Thank you very much for your help, I really appreciate. I'm using directly your example (detection) with the Pascal Voc dataset, I have not changed anything (I trained for 100 epochs as standard in the notebook). The architecture is Mobilenet 1_0 just to be sure here is the notebook: https://colab.research.google.com/github/AIWintermuteAI/aXeleRate/blob/master/resources/aXeleRate_pascal20_detector.ipynb

I'm able to run with the code you can see in the previous message, but it does not detect anything, also if I open the serial terminal while the code is running it continuously prints numbers from 7 to 9 with 6 decimals. As I said the model seems to work when I test it using the last cell of your notebook in Coolab. Its probably something that I'm forgetting because I'm a newbie. ufff

RicardoCostaCMD commented 3 years ago

Have you reached any conclusion ?? I'm having the same mistakes.