<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: abdulrehman ajmal</title>
    <description>The latest articles on DEV Community by abdulrehman ajmal (@pineapple1).</description>
    <link>https://dev.to/pineapple1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F605285%2F3854cab7-eb61-4bde-835c-a571c7b8565d.jpeg</url>
      <title>DEV Community: abdulrehman ajmal</title>
      <link>https://dev.to/pineapple1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pineapple1"/>
    <language>en</language>
    <item>
      <title>How to Train a YOLO-V5 Model on Custom Dataset.</title>
      <dc:creator>abdulrehman ajmal</dc:creator>
      <pubDate>Sun, 30 Jan 2022 18:22:47 +0000</pubDate>
      <link>https://dev.to/pineapple1/how-to-train-a-yolo-v5-model-on-custom-dataset-nn</link>
      <guid>https://dev.to/pineapple1/how-to-train-a-yolo-v5-model-on-custom-dataset-nn</guid>
      <description>&lt;p&gt;Object Detection is a task in computer vision that focuses on detecting objects in images/videos.&lt;/p&gt;

&lt;p&gt;In this article, we are going to use Yolo-V5 to train our custom object detection model. YOLO is one of the most famous object detection models.&lt;/p&gt;

&lt;h2&gt;
  
  
  How We Going to Train Our Model.
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;First we need a data set.&lt;/li&gt;
&lt;li&gt;Second we will tain our model through google colabs.&lt;/li&gt;
&lt;li&gt;Third we will run it on our own machine.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Environment Setup
&lt;/h2&gt;

&lt;p&gt;Here is link to notebook: &lt;a href="https://colab.research.google.com/drive/1gDZ2xcTOgR39tGGs-EZ6i3RTs16wmzZQ#scrollTo=Ie5uLDH4uzAp"&gt;Google Colab&lt;/a&gt;&lt;br&gt;
You need a google account to use Google Colab. You can either use  notebook which is provided and recomended by YOLO to train or you can create your own notebook and follow along.&lt;/p&gt;

&lt;p&gt;If you are planning to use this notebook then make sure to File → save a copy in your drive. Then you will be able to edit the code.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing the YOLOv5 Environment
&lt;/h3&gt;

&lt;p&gt;To run object detection model in your own machine you need to setup YOLO in your own machine following code will clone the code base.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!git clone https://github.com/ultralytics/yolov5  # clone repo
!pip install -U -r yolov5/requirements.txt  # install dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Preparing the Dataset.
&lt;/h2&gt;

&lt;p&gt;First we need to download the data set in your machine and go straight to &lt;a href="https://roboflow.com/"&gt;Roboflow&lt;/a&gt; and create new project. Roboflow is a great tool also recomended by the YOlO readme.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E82P76jZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tapnn6725a7ta9p8kj9t.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E82P76jZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tapnn6725a7ta9p8kj9t.PNG" alt="Create new project" width="496" height="143"&gt;&lt;/a&gt;&lt;br&gt;
After creating new project then we need to upload dataset. Roboflow is very fast and it will upload images and lables. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ie6Wqk9o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y15grlmj3e7u1br9lwq4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ie6Wqk9o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y15grlmj3e7u1br9lwq4.PNG" alt="Roboflow Upload" width="681" height="286"&gt;&lt;/a&gt;&lt;br&gt;
Roboflow will convert data set into Yolo-V5 format and divide dataset in to train validate and test according to your personal requirments. After that you only need to export by download code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UnYoRjIo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zpparwwvp5zi7lukvbfx.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UnYoRjIo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zpparwwvp5zi7lukvbfx.PNG" alt="Download Code" width="494" height="164"&gt;&lt;/a&gt;&lt;br&gt;
Now we have prepared our dataset lets move to next step of training the model.&lt;/p&gt;
&lt;h2&gt;
  
  
  Train the Model
&lt;/h2&gt;

&lt;p&gt;For this part we will now move on to google coloabs notebook after saving a copy of notebook you only need to run all the code cells which are already written please run one cell at a time with sequence after cell is done move to next.&lt;/p&gt;

&lt;p&gt;In the third block provide your snippet of code given by roboflow.&lt;/p&gt;

&lt;p&gt;After that run the rest of the code cells it will take a lot of time training the model but after running the last cell you will have a weights file in your goolge drive.&lt;/p&gt;
&lt;h2&gt;
  
  
  Run it on Your Machine
&lt;/h2&gt;

&lt;p&gt;Now remeber we cloned Yolo-V5 go in that directory. Downolad Best.pt file from google drive and place this file in Yolo-5v directory along with a test image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python detect.py --weights best.pt --source image.jpg 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this command and you done.&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>yolo</category>
    </item>
  </channel>
</rss>
