Giter Club home page Giter Club logo

k210-yolo3's Introduction

K210-yolo3

license

Introduction

A Tensorflow implementation of keras-YOLOv3. Now I am ported to k210 ~

This code lacks scalability and good measurements during training, so I rewrote a K210 Yolo v3 framework.


Quick Start

Set Environment

See requirements.txt

Prepare Dataset

  1. download dataset:

    wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
    wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
    wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
    tar xf VOCtrainval_11-May-2012.tar
    tar xf VOCtrainval_06-Nov-2007.tar
    tar xf VOCtest_06-Nov-2007.tar
  2. Generate annotation file and class names file.

    One row for one image;
    Row format: image_file_path box1 box2 ... boxN;
    Box format: x_min,y_min,x_max,y_max,class_id (no space).
    For VOC dataset, try

    python3 voc_annotation.py your-path/VOCdevkit/
    cat 2007_*.txt 2012_*.txt > train.txt

    Here is an example:

    path/to/img1.jpg 50,100,150,200,0 30,50,200,120,3
    path/to/img2.jpg 120,300,250,600,2
    ...
    

Train Mobilenet

usage: train.py [-h] [--alpha {0.5,0.75,1.0}]
                [--annotation_path ANNOTATION_PATH]
                [--weights_path WEIGHTS_PATH] [--learning_rate LEARNING_RATE]
                [--classes_path CLASSES_PATH] [--anchors_path ANCHORS_PATH]
                [--epochs EPOCHS] [--augment {True,False}]
  1. train mobilenet yolo3 alpha = xx

    python3 train.py --alpha xx
  2. load pre-train model

    python3 train.py --weights_path logs/xxxx-xxxx/yolo_model_body.h5

NOTE: Default training 10 epochs,data augment = True

Test

python3 yolo_video.py --model logs/xxxxxxxx/yolo_model_body.h5 --anchors model_data/tiny_yolo_anchors.txt --classes model_data/voc_classes.txt --image

Then type the image path.

You can try with the model which I trained the 20 epochs mobilenet 0.75 model:

python3 ./yolo_video.py --model model_data/yolo_model_body_75.h5  --anchors model_data/tiny_yolo_anchors.txt --classes model_data/voc_classes.txt --image

Then type model_data/people.jpg:

Freeze

toco --output_file yolo_model.tflite --keras_model_file logs/xxxxxxxx/yolo_model_body.h5

Convert

Please use latest nncase

ncc -i tflite -o k210model --channelwise-output --dataset ./images mobile_yolo.tflite ./yolo.kmodel

Demo

Use Kflash.py download kpu_yolov3_test/kfpkg/kpu_yolov3.kfpkg to KD233 board:

kflash kpu_yolov3_test/kfpkg/kpu_yolov3.kfpkg -B kd233 -p /dev/ttyUSB0 -b 2000000 -t

NOTE: I've just shown the most basic example to prove the validity of the model if you need to use at least the non-maximum suppression between multiple layers of output in your code.

Issue

If you have any issue, contact me by QQ:597323109 or email:[email protected]

Some issues to know

  1. Default anchors are used. If you use your own anchors, probably some changes are needed.

  2. The inference result is not totally the same as Darknet but the difference is small.

  3. The speed is slower than Darknet. Replacing PIL with opencv may help a little.

  4. Always load pretrained weights in the first stage of training. Or try Darknet training. It's OK if there is a mismatch warning.

  5. The training strategy is for reference only. Adjust it according to your dataset and your goal. And add further strategy if needed.

  6. For speeding up the training process with frozen layers train_bottleneck.py can be used. It will compute the bottleneck features of the frozen model first and then only trains the last layers. This makes training on CPU possible in a reasonable time. See this for more information on bottleneck features.

k210-yolo3's People

Contributors

b02902131 avatar dleam avatar jiaowoboshao avatar philtrade avatar qqwweee avatar stefanbo92 avatar tanakataiki avatar zhen8838 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

k210-yolo3's Issues

AttributeError: module 'tensorflow' has no attribute 'python'

I've run python3 voc_annotation.py ./VOCdevkit but get a following error.

Traceback (most recent call last):
  File "voc_annotation.py", line 2, in <module>
    import tensorflow.python as tf
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation_wrapper.py", line 106, in __getattr__
    attr = getattr(self._dw_wrapped_module, name)
AttributeError: module 'tensorflow' has no attribute 'python'

After modified line 2 to import tensorflow as tf, It's good for running.

I think that the idea is not to import tensorflow.python directly. Those classes, objects, and submodules of python that are intended to be used by applications are made available simply by import tensorflow.

Using pretrained model

Hello,
New to AI world (but want to try K210 board)
I have a pretrained model with tiny-yolo v3 . Can i directly convert and use it ?
Or I have to train it again.

if yes, if I have images in yolo format - Can the same format be used for training with your code.

Clarification

In your main.c under Yolo V3 for K210 and also in several codes you are disabling this interrupt

dvp_config_interrupt(DVP_CFG_START_INT_ENABLE | DVP_CFG_FINISH_INT_ENABLE, 0);

in the method
static int dvp_irq(void *ctx)

What is the purpose of disabling it, in your code you have commented out the enable interrupt for this.

Can you please explain for my understanding, what does this interrupt do

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.