Tutorial: Yolov3 in Keras
Last updated
Was this helpful?
Last updated
Was this helpful?
Github:
Lets create a virtual environment for YOLOv3.
The requirements are
python=3.7.10
cudatoolkit=10.0
cudnn-7.6.5-cuda10.0_0
tensorflow-gpu=1.15.0
keras=2.3.1
pillow=8.2.0
matplotlib=3.3.4
opencv=3.4.2
If you have problems when installing opencv packages, use the following commands pip install opencv-python
Install the following:
After the installation, activate the virtual environment. We will clone the reference repository to download Yolov3 codes.
Download zip file from the github and unzip.
After the download, place the weight model file in the same directory of Yolov3.
You can also download it from the conda Prompt as
YOLOv3-tiny weights
>> code .
You can also run the below codes in the Conda Promt
In VS code, select the virtual environment: F1--> Python Interpreter --> Select Environ.
In the terminal of VS code or in Conda Prompt, type:
Copy the test video file in the same directory (Yolov3 directory)
If the video file name is 'test_Video.avi'
After downloading yolov3-tiny.weights, Convert it to Keras model and save it as 'yolo-tiny.h5'
Run Yolo-tiny with the Test video
Use --help to see usage of yolo_video.py:
For this tutorial, we will use KITTI dataset
Class file:
Copy the 'kitti_classes.txt' in the folder of `\model_data` folder
Open 'train.py' file in VS Code\
Go to LIne 16 : def main():. Change the ''annotation' and 'classes-path' to your setting.
Go to LIne 32: Change the name of the pre-trained weight file.
We will use COCO trained weight file as we used above(yolo.h5). Create a copy and name it asyolo_weights.h5
Start training by running the following in the terminal
Use your trained weights or checkpoint weights with command line option --model model_file
when using yolo_video.py Remember to modify the class path or anchor path.
Error message of
_, ignore_mask = K.control_flow_ops.while_loop(lambda b,*args: b<m, loop_body, [0, ignore_mask])
Modify model.py
(line 394)
_, ignore_mask = K.control_flow_ops.while_loop(lambda b,*args: b<m, loop_body, [0, ignore_mask])
should be changed to
_, ignore_mask = tf.while_loop(lambda b,*args: b<m, loop_body, [0, ignore_mask])
git
YOLOv3 weights
wget
``
Image file:
Label file:
Object Detection annotation Convert to Yolo Darknet Format: