Coder Social home page Coder Social logo

object-detection's Introduction

YOLOv5 / DETR object detection tutorial

YOLOv5

Training (You can refer to YOLOv5 website)

I train YOLOv5 model locally, just follow the steps below (use cmd command line)


git clone https://github.com/ultralytics/yolov5.git
pip install -r requirements.txt
# you can also use "JSON_to_txt.py" if you need to convert json file into txt file
  1. Place your datasets under the folder you want to use
  2. Modify the path setting in the hw1.yaml under the data folder
  3. Go to YOLOv5 website, download the pretrain model (I use the YOLOv5x)
# run main.py to train the model
python3 train.py --img 640 --epochs 200 --batch-size 12 --data hw1.yaml --weights yolov5x.pt # this is the hyperparameter I use, can be modify yourself

Inference

You can follow the steps just like hw1.sh


Draw the bounding boxes on image

Just using the detect.py (you can modify the path and weight)

python3 detect.py --weights ../YOLOv5_checkpoint.pt --source ../yolov5_datasets/test_image

DETR

Training (You can refer to DETR website)

I train DETR model locally, just follow the steps below (use cmd command line)


git clone https://github.com/facebookresearch/detr.git
pip install -r requirements.txt 
  1. Place your datasets under the folder you want to use, and don't forget to modify the path setting in the main.py
  2. Modify the class numbers under the models/detr.py
  3. Go to DETR website, download the pretrain model (I use the DETR-R50)
# Convert the class numbers in pretrain model (you can modify the class numbers you want in "detr_pretrain_convert_class_to_8.py")
python3 detr_pretrain_convert_class_to_8.py

# run main.py to train the model
python3 main.py --coco_path ../detr_datasets/train/ --epochs 150 --batch_size 2 --resume detr-r50_8.pth # this is the hyperparameter i use, can be modify yourself

Inference

You can follow the steps just like hw1.sh


Draw the bounding boxes on image

Just using the DETR_BBOX_img.py (you can modify the path, weight and class numbers)

python3 DETR_BBOX_img.py

The image will look just like this with both method:

object-detection's People

Contributors

willychen0146 avatar

Watchers

Kostas Georgiou avatar  avatar

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.