yakhyo / yolov1-pytorch

πŸ” | YOLOv1 (Real-Time Object Detection) implementation using PyTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YOLO v1 using PyTorch

Dataset:

  1. Download voc2012train dataset
  2. Download voc2007train dataset
  3. Download voc2007test dataset
  4. Put all images in JPEGImages folder in voc2012train and voc2007train to Images folder as following:
β”œβ”€β”€ Dataset 
    β”œβ”€β”€ IMAGES
        β”œβ”€β”€ 0001.jpg
        β”œβ”€β”€ 0002.jpg
    β”œβ”€β”€ LABELS
        β”œβ”€β”€ 0001.txt
        β”œβ”€β”€ 0002.txt
    β”œβ”€β”€ train.txt
    β”œβ”€β”€ test.txt

Each label consists of class and bounding box information. e.g 0001.txt :

1 255 247 425 468
0 470 105 680 468
1 152 356 658 754

How to convert .xml files to .txt format?

  • Download this repo and modify config.py to convert VOC format to YOLO format labels

Implementation of YOLOv1 using PyTorch

Train:

Note: I trained the backbone on IMAGENET, around ~ 10 epochs, not sure how many it was but less then 20

python main.py --base_dir ../../Datasets/VOC/ --log_dir ./weights 
usage: main.py [-h] --base_dir BASE_DIR --log_dir LOG_DIR [--init_lr INIT_LR] [--base_lr BASE_LR] [--momentum MOMENTUM] [--weight_decay WEIGHT_DECAY] [--num_epochs NUM_EPOCHS]
               [--batch_size BATCH_SIZE] [--seed SEED]

Evaluation:

  • python eval.py

  • In evaluation.py, im_show=False change to True to see the results.

Evaluate the detection result...
aeroplane                 0.57
bicycle                   0.46
bird                      0.38
boat                      0.25
bottle                    0.14
bus                       0.53
car                       0.48
cat                       0.61
chair                     0.18
cow                       0.34
diningtable               0.44
dog                       0.52
horse                     0.52
motorbike                 0.49
person                    0.49
pottedplant               0.21
sheep                     0.43
sofa                      0.38
train                     0.69
tvmonitor                 0.40
mAP 0.426056536787907

Detection

  • To detect objects on an image run the detect.py

About

πŸ” | YOLOv1 (Real-Time Object Detection) implementation using PyTorch

License:MIT License


Languages

Language:Python 100.0%