This project contains python examples for Kneron Computer Lab Book
This is a brief introduction. For more detailed documents, please visit http://doc.kneron.com/pythondocs.
General:
- Python 3.8
- opencv-python (Install using
pip install opencv-python
)
Linux:
- libusb (Ubuntu install using
apt install libusb-1.0-0-dev
)
Windows:
- WinUSB (Install after plugging in the dongle and run Zadig)
Mac OS:
- Mac OS should be later than 10.15.6.
- libusb (Install with Homebrew using
brew install libusb
)
Simply run the following command but replace the item within <>
.
pip install pkgs/kdp_host_api-<version>_<os_version>_-py3-none-any.whl
os_version
should be win
, mac
orlinux
.
Please check the pkgs
folder for the version
available.
If the the .whl
can not be installed and reporting error File is not a zip file
, please use git-lfs pull
to fetch the pacakge.
- Please make sure you have installed the packages mentioned in the previous section.
- Plug in the dongle.
- Using command line tool and enter the
python
folder. - Run
python main.py -h
If all of the packages are installed correctly, you would get a message with available examples like the following:
Run Python examples by calling the Python APIs
optional arguments:
-h, --help show this help message and exit
-t TASK_NAME, --task_name TASK_NAME
cam_dme_ssd_fd
cam_yolo
cam_isi_ssd_fd
cam_isi_yolo
cam_isi_parallel_yolo
dme_keras
update_app
update_fw
There are two kinds of examples, need update_app
and don't need extra steps.
If this is the first time you are using a dongle, please run update_app
to update the firmware.
Just follow the steps below to update tiny_yolo_v3
into the dongle and update the firmware.
- Copy the binary files (
*.bin
) underapp_binaries/tiny_yolo_v3
intoota/ready_to_load
. - Enter
python
directory. - Run
python main.py -t update_app
(This step may take some time).
If you have errors related to adding device failure, please check your permission. If on Linux, please try using
sudo
.
Most examples need extra steps to upload the model file into the dongle. You can find the model files under app_binaries
. Here is a table of the relationship between models and examples:
Example | Model |
---|---|
cam_dme_ssd_fd | ssd_fd |
cam_isi_ssd_fd | ssd_fd |
cam_yolo | tiny_yolo_v3 |
cam_isi_yolo | tiny_yolo_v3 |
cam_isi_parallel_yolo | tiny_yolo_v3 |
Here are the steps you need to update the dongle and run the example. Let's take cam_isi_yolo
as the example.
- From the chart, we know we need to use model
tiny_yolo_v3
. - Copy the binary files (
*.bin
) underapp_binaries/tiny_yolo_v3
intoota/ready_to_load
. - Enter
python
directory. - Run
python main.py -t update_app
(This step may take some time). - Run
python main.py -t cam_isi_yolo
.
Now, you can get a window pop up and running your test. Congratulations!
To stop the test and quit, just press q
when focusing on the command line.
Let's try the example do not need extra steps: dme_keras
.
You just need to run the command python main.py -t dme_keras
with your dongle plugged in. Then, you can get the output without any error message.
$ python main.py -t dme_keras
adding devices....
start kdp host lib....
Task: dme_keras
loading models to Kneron Device:
starting DME mode ...
DME mode succeeded...
Model loading successful
starting DME configure ...
DME configure model [1000] succeeded...
./data/images/cat.jpg
281 0.513678242399822
285 0.23041174139774295
282 0.15431613018623724
./data/images/fox.jpg
277 0.8318471411560402
278 0.06568296365719047
272 0.057467412876039244
de init kdp host lib....