Git Product home page Git Product logo

yolo-pet's Introduction

YOLO-Pets

Real-time pet detection and recognition with YOLO

For using or testing

  • Download trained weight file from our release or train it by yourself.

  • Clone YOLO Project

    git clone https://github.com/pjreddie/darknet 
    cd darknet 
    
  • modify yolo source code

    vim examples/yolo.c
    

    Create a new array of labels string.

    char *pet_names[] = {"Abyssinian", "Bengal", "Birman", "Bombay", "British_Shorthair", "Egyptian_Mau", "Maine_Coon", "Persian", "Ragdoll", "Russian_Blue", "Siamese", "Sphynx", "american_bulldog", "american_pit_bull_terrier", "basset_hound", "beagle", "boxer", "chihuahua", "english_cocker_spaniel", "english_setter", "german_shorthaired", "great_pyrenees", "havanese", "japanese_chin", "keeshond", "leonberger", "miniature_pinscher", "newfoundland", "pomeranian", "pug", "saint_bernard", "samoyed", "scottish_terrier", "shiba_inu", "staffordshire_bull_terrier", "wheaten_terrier", "yorkshire_terrier"};
    

    Go to the test_yolo function and modify the input parameter of draw_detections.

    Usedraw_detections(im, dets, l.side*l.side*l.n, thresh, pet_names, alphabet, 37); replace it.

  • Compile and test your yolo.

    Compile and link this project first.

    make clean
    make -j8
    

    Test

    ./darknet detector test cfg/pet.data cfg/yolov3-pet.cfg your-yolo-pet.weights ~/Your-dataset/JPEGImages/havanese_102.jpg 
    

    There will be an image named predictions.png in your darknet root directory.

    Prediction

Train your own yolo

If you want to train yolo by your self or train other dataset, you can refer to this guide.

  • Clone this repo

    git clone https://github.com/ideaRunner/yolo-pet.git
    cd yolo-pet
    
  • Download Pet Dataset

    The Oxford-IIIT Pet Dataset

    You can download the images and annotations by

    wget -c http://www.robots.ox.ac.uk/~vgg/data/pets/data/images.tar.gz
    wget -c http://www.robots.ox.ac.uk/~vgg/data/pets/data/annotations.tar.gz
    

    Unzip

    tar -xvf images.tar.gz
    tar -xvf annotations.tar.gz
    

    Change the directory name to which yolo need.

    mv images JPEGImages
    
  • Clone YOLO Project

    git clone https://github.com/pjreddie/darknet
    cd darknet
    make
    

    Download Pretrained Convolutional Weights of Yolo-v3

    wget https://pjreddie.com/media/files/darknet53.conv.74

Configuration for yolo training

  • Generate label files

    cd ..
    python pet_label generate
    

    Then there will be a Train_List.txt file and Val_List.txt file in the root directory and labels in labels directory. You must Keep labels and JPEGImages in same directory.

  • Edit configure files

    vim darknet/cfg/pet.data
    

    copy, paste and save

    classes= 37
    train  = Your/Own/Path/Train_List.txt
    valid  = Your/Own/Path/Val_List.txt
    names = data/pet.names
    backup = pet_backup
    

    Don't forget to change the path as you generate before.

    vim darknet/data/pet.names
    

    copy, paste and save

    Abyssinian
    Bengal
    Birman
    Bombay
    British_Shorthair
    Egyptian_Mau
    Maine_Coon
    Persian
    Ragdoll
    Russian_Blue
    Siamese
    Sphynx
    american_bulldog
    american_pit_bull_terrier
    basset_hound
    beagle
    boxer
    chihuahua
    english_cocker_spaniel
    english_setter
    german_shorthaired
    great_pyrenees
    havanese
    japanese_chin
    keeshond
    leonberger
    miniature_pinscher
    newfoundland
    pomeranian
    pug
    saint_bernard
    samoyed
    scottish_terrier
    shiba_inu
    staffordshire_bull_terrier
    wheaten_terrier
    yorkshire_terrier
    

    Create yolov3.cfg and Edit the last serveal lines, change fliters to 126 and classes to 37. For yolov3, you need to find and change 3 times. For yolov2, you need to find and change 2 times. You also need to uncomment the train part batch and subdivisions in the first servel lines of this cfg file.

    You can use our .cfg file in this repo if you don't want to change by your self.

    mv darknet/cfg/yolov3-voc.cfg darknet/cfg/yolov3-pet.cfg 
    vim darknet/cfg/yolov3-pet.cfg 
    

    Make a directory for training backup. The name should be same as you defined in pet.data.

    mkdir darknet/pet_backups
    
  • Train yolo

    cd darknet 
    ./darknet detector train cfg/pet.data cfg/yolov3-pet.cfg  darknet53.conv.74 
    

    The train result will be at your backup directory. You can fellow the guide above and test wheather it is good or not.

yolo-pet's People

Contributors

idearunner avatar

Stargazers

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

Watchers

 avatar

yolo-pet's Issues

Given weights for yolov2 but implementation in yolo v3?

Hello, so I'm trying to do the testing directly using the pretrained weights, but I don't get any predictions. I guess its because the weights are given for yolov2 but the implementation was in yolov3? Or can i use them interchangeably??

Also could you please tell me where I can find the image outputs?? thanks!

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.