in this lesson. we will learn about installing and training yolo.
access the github repository via the official yolo website.
create a conda virtual environment and install yolo within it.
finally. enter the `yolo` command to verify the installation.
this time. we will obtain training data from roboflow and train the yolo model.
first. click on the roboflow universe menu.
click the "explore universe" button to navigate to the dataset exploration page.
now. search for the dataset you want to use for training.
i will use the "fire detection" dataset. which has been downloaded more than 400 times.
download the dataset and extract the files.
now. open and check the `data.yaml` file.
to ensure smooth training. we will set the dataset path to an absolute path.
(set the path according to your environment.)
this path should point to the extracted dataset folder.
next. open a cmd window and activate the `flameguard` virtual environment in anaconda.
now. let's refer to the yolo official documentation and start training.
run the basic training command to train the model.
let's briefly go over the training options.
`epochs` sets the number of training iterations.
`data` specifies the path to the dataset for training.
we have already defined the dataset path in the `data.yaml` file.
`imgsz` sets the image size for training.
the recommended default size is `640`.
now. let's start the training.
normally. training is repeated at least 100 times. but in this example. we will run it only 10 times.
it is recommended to train for at least 100 epochs for better results.
all training results will be saved inside the `train` folder under `detect`. which is located in the `run` directory of the training path.
inside the weights folder. you will find two files.
best stores the best training result.
last stores the most recent training result.
typically. the best model. which has the highest mean average precision (mAP). is used.
let’s refer to the official yolo documentation and test the trained model.
navigate to the directory where the trained model is saved.
enter the provided command to predict fire images.
to do this. find fire images from the internet and save them in the same directory.
next. specify the saved image using the `source` option to run the prediction.
based on the directory where the command is executed.
a `predict` folder will be created inside `runs/detect`. and the prediction results will be stored there.
let’s test a few more fire and non-fire images for prediction.
in the next lesson. we will build a backend server using fastapi and create an api for running predictions.