Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taipingeric/yolo-v4-tf.keras
A simple tf.keras implementation of YOLO v4
https://github.com/taipingeric/yolo-v4-tf.keras
computer-vision keras keras-model object-detection python tensorflow tensorflow2 yolo yolov4
Last synced: 10 days ago
JSON representation
A simple tf.keras implementation of YOLO v4
- Host: GitHub
- URL: https://github.com/taipingeric/yolo-v4-tf.keras
- Owner: taipingeric
- License: mit
- Created: 2020-07-03T09:04:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T03:43:38.000Z (almost 2 years ago)
- Last Synced: 2024-08-01T03:17:00.429Z (3 months ago)
- Topics: computer-vision, keras, keras-model, object-detection, python, tensorflow, tensorflow2, yolo, yolov4
- Language: Python
- Homepage:
- Size: 29.2 MB
- Stars: 141
- Watchers: 3
- Forks: 77
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-tensorflow-2 - A simple tf.keras implementation of YOLO v4
- awesome-yolo-object-detection - taipingeric/yolo-v4-tf.keras - v4-tf.keras?style=social"/> : A simple tf.keras implementation of YOLO v4. (Other Versions of YOLO)
- awesome-yolo-object-detection - taipingeric/yolo-v4-tf.keras - v4-tf.keras?style=social"/> : A simple tf.keras implementation of YOLO v4. (Other Versions of YOLO)
README
# yolo-v4-tf.keras
A simple tf.keras implementation of YOLO v4![asset/pred.png](asset/pred.png)
## TODO
- [X] Cosine annealing scheduler
- [X] mAP
- [ ] Mosaic augmentation
- [ ] DropBlock
- [ ] Self-adversarial training (SAT)
- [ ] Label smoothing
- [X] Mish
- [X] IoU, GIoU, CIoU loss
- [X] multi-GPU training## Quick Start
1. Download official YOLO v4 pre-trained weights from [github/AlexeyAB/darknet](https://drive.google.com/open?id=1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT)
2. Initialize YOLO model and load weights
3. Run predictionExample: [Inference.ipynb](notebook/Inference.ipynb):
```python
from models import Yolov4
model = Yolov4(weight_path='yolov4.weights',
class_name_path='class_names/coco_classes.txt')
model.predict('input.jpg')
```
## Training1. Generate your annotation files (.XML) in VOC format for each images
*HINT:* An easily used annotation tool: [labelImg](https://github.com/tzutalin/labelImg)
Example: A 2 object xml file
```xml
train_img2
yui.jpg
/Users/taipingeric/dataset/train_img2/yui.jpg
Unknown
465
597
3
0
person
Unspecified
1
0
43
41
430
597
person
Unspecified
1
0
60
70
20
207
```2. Convert all XML files to a single .txt file:
Row format: `img_path BOX0 BOX1 BOX2 ...`
BOX format: `xmin,ymin,xmax,ymax,class_id`
Example: [xml_to_txt.py](xml_to_txt.py)
```
img1.jpg 50,60,70,80,0 70,90,100,180,2
img2.jpg 10,60,70,80,0
...
```3. Generate class name file, # of lines == # of classes
Example: [coco_classes.txt](class_names/coco_classes.txt)
```
person
bicycle
car
motorbike
aeroplane
bus
...
```
4. Train with the code below
Example: [train.ipynb](notebook/train.ipynb)
```pythonfrom utils import DataGenerator, read_annotation_lines
from models import Yolov4train_lines, val_lines = read_annotation_lines('../dataset/txt/anno-test.txt',
test_size=0.1)
FOLDER_PATH = '../dataset/img'
class_name_path = '../class_names/bccd_classes.txt'
data_gen_train = DataGenerator(train_lines,
class_name_path,
FOLDER_PATH)
data_gen_val = DataGenerator(val_lines,
class_name_path,
FOLDER_PATH)model = Yolov4(weight_path=None,
class_name_path=class_name_path)model.fit(data_gen_train,
initial_epoch=0,
epochs=10000,
val_data_gen=data_gen_val,
callbacks=[])```
## Acknowledgements* [qqwweee/keras-yolo3](https://github.com/qqwweee/keras-yolo3)
* [AlexeyAB/darknet](https://github.com/AlexeyAB/darknet)
* [hunglc007/tensorflow-yolov4-tflite](https://github.com/hunglc007/tensorflow-yolov4-tflite)
* [Cartucho/mAP](https://github.com/Cartucho/mAP)
* [miemie2013/Keras-YOLOv4](https://github.com/miemie2013/Keras-YOLOv4)
* [david8862/keras-YOLOv3-model-set](https://github.com/david8862/keras-YOLOv3-model-set)
* [Ma-Dan/keras-yolo4](https://github.com/Ma-Dan/keras-yolo4)