This project aims to achieve the identification of fruits using a camera. It will be implemented with Python. The goal is to label and print the name of the fruit shown by the camera. The program will automatically prepare a dataset in YOLOv8 format. After obtaining the required data, the program will separate them into files necessary for training. In the final stage, the training process will commence, and the model will be tested with the camera
![]()
Anaconda
Visual studio code
Yolov8
Python
OpenCv
Ultralytics
It creates the necessary data set to recognize my fruits.
We need to create a separate dataset for each fruit.
We create a folder called Dataset where our dataset creation file is located. We create a folder called DataCollect inside our Dataset folder.
We need to use different IDs for each fruit we will define.
We need to enter the correct address from classNames for the dataset to be created for each fruit.
After collecting the initial data in a single folder, we need to make a separation for training.
It automatically separates the data to be used for training into 'train', 'val' and 'test' folders.
After this separation process, we must ensure that the training takes place according to the IDs we have determined for our inclinations. For this, a data.yml file is automatically created.
We continue by specifying the 'train', 'val' and 'test' folder paths in the data.yml file.
After completing the separation process, we must now start our training.
We continue by specifying the path to the data.yml file created for our training program to access the created test, train and val files.
In this training process, we want the dfl_loss value to be around 0.3-0.4 and the mAP value to be close to 1.
We should do this by increasing the epochs value or creating more datasets.
When I tried the training with 10 different fruits, I observed that very similar fruits were mixed together.
I think this is because the camera cannot fully detect the details.
In my later training, I observed that it gave better results when I tried it with 11 different fruits.
After our training is completed, two files are created for us: best and last.
These files are trained files.
We test our training with our camera by running these files with our main file.
create_a_dataset.py (automatic dataset creation)
splitdata.py (splitting the dataset into test, train and val)
train_offline.py (training)
main.py (application)

