A comprehensive Keras implementation of YOLO (You Only Look Once) object detection models with PyTorch weight conversion utilities. This repository provides easy-to-use tools for converting YOLO models from PyTorch to Keras/TensorFlow format while maintaining full compatibility and performance.
- YoloV5
- YoloV8
- Clone the repository:
git clone https://github.com/IMvision12/yolo-keras.git
cd yolo-keras- Create and activate a virtual environment:
# On Windows
python -m venv env
.\env\Scripts\activate
# On Linux/Mac
python -m venv env
source env/bin/activate- Install the required packages:
pip install -r requirements.txtfrom convert_weight import transfer_torch_to_keras_weights
from yolov8_model import YoloV8m
from ultralytics import YOLO
from yolo_post_processor import YoloPostProcessor
from yolo_pre_processor import YoloPreProcessor
from utils import visualize_yolo_detections
import keras
keras_model = YoloV8m(input_shape=(None, None, 3), nc=80)
torch_model = YOLO("yolov8m.pt")
transfer_torch_to_keras_weights(torch_model, keras_model, show_progress=True)
keras_model.load_weights("yolov8m.weights.h5")
pre_processor = YoloPreProcessor()
image = keras.utils.load_img("bird.png")
image_array = keras.utils.img_to_array(image)
result = pre_processor(image_array)
keras_raw_output = keras_model(result)
post_processor = YoloPostProcessor()
output = post_processor(keras_raw_output)
visualize_yolo_detections(result["images"].numpy().squeeze()[:, :, ::-1], output)- The code in this repository is licensed under the Apache License 2.0. See LICENSE for details.
- The official YOLO weights are licensed under the AGPL-3.0 license. Converting and using these weights makes your project subject to AGPL-3.0 license requirements.
