This repository contains a YOLOv5, YOLOv8n model trained on a dataset that includes 5 classes: Person, Bus, Car, Motorbike, and Bicycle. YOLO (You Only Look Once) is a popular object detection model capable of real-time object detection. The "Medium" variant of YOLOv5 refers to the specific architecture and model size used in this implementation.
Input: image or camera
Ouput: processed image or frame
- Model Size: Medium
- Classes: 5 (Person, Bus, Car, Motorbike, Bicycle)
- Framework: PyTorch
- Input Image Size: 448x448
- Hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
pip install requirements.txt
To use this YOLOv5 model for transportation detection, follow these steps:
- Clone this repository:
git clone https://github.com/hotonbao/YOLOV5.git
cd YOLOV5
-
Dowload Weight File:
Weight YoloV5: https://drive.google.com/file/d/1zw0rR7iSfobJ9CwPXe2-YqvjrSmjzt_T/view?usp=sharing
Weight YoloV8: https://drive.google.com/file/d/1OSU5g3yz-IliqMFQhfbmVp0UA6e5nKcT/view?usp=sharing
Notice: Replace PATH_MODEL in the configs.py(for YoloV5) file with the pre-trained model file.
-
Run the inference script to perform object detection on an image with FastAPI or Streamlit(YoloV5):
FastAPI:
python api.py
Type "/docs" after link http://127.0.0.1:8000 to test with any image
Streamlit:
Notice: Run FastAPI before run Streamlit and open new command line and run:
streamlit run app.py --server.fileWatcherType=none
It will open:
cd yolo-v8 python app.py
It will open a window:
It have 3 functions:
- Load Image
- Start Camera
- Stop Camera
-
-Ouput shape after inference:
-
1: is number of batch
-
12348: number of bounding boxes in image.
-
10=(4+1+5):
- x_max, y_max, x_min, y_min (4)
- confidence score is an object (1)
- confidence correspond to each class(5).
-Output postprocess Run test.ipynb file to see output.
Example:
It is an object that has 6 arguments equivalent to
[ xmin, ymin, xmax, ymax, confidence of class, classname ']
Description:
Confidence score: Prediction score of class.
Class name: has been encoded : 0: "bicycle", 1: "bus", 2: "car", 3: "motorbike", 4: "person"
-
Dataset: https://www.kaggle.com/datasets/yusufberksardoan/traffic-detection-project/
Load the dataset link in and enter yolov5-training.ipynb run all cells then download the best m.onnx file.
https://github.com/ultralytics/yolov5/tree/master/models
Visit the link if you want to train the model with many different architectural sizes
Ho Ton Bao
Phone number : +84949800149
Email: [email protected]