Vignettes

Vignettes

Open in ChatGPT
Ask ChatGPT about this page
Open in Claude
Ask Claude about this page

Environment Setup

Image Recognition Setup

  1. Introduction
  2. Prerequisites
  3. Application of the Fundamentals
  4. Downloading software, installation
  5. Running Model
  6. Training Model
  7. Implementing Model
  8. Conclusion

Introduction

Welcome to this step-by-step kit on Object Detection. As we learned in the Image Recognition Overview, object detection is a powerful technique that enables machines to recognize and locate objects within an image or video. In this kit, you will learn how to download, set up, and run a pre-trained model from an open-source repository in GitHub. This kit will also cover how to train and run your own model using the training code in the open-source repository. We will walk you through the process step-by-step, starting with the basics and working our way up to running a model with a live webcam feed. By the end of this module, you will have the knowledge and skills necessary to implement object detection in your own projects and applications.

Prerequisites

Equipment:

  • Computer with internet access
  • Webcam that is compatible with your computer

Application of the Fundamentals

Downloading Software, Installation, and Setup

  1. Download Anaconda from anaconda.com

anaconda_home.png

anaconda_download.png

  1. Download Cuda if you have an Nvidia GPU, otherwise skip this step

gpu_check.png

nvidia_check.png

  1. Clone the Yolo V5 GitHub repository to the local drive
  • In your command prompt or terminal, type ‘mkdir PythonProjects’ and then ‘cd PythonProjects’
  • Type ‘git clone https://github.com/ultralytics/yolov5.git’ then cd yolov5’
  • Alternatively download as a zip file and follow the steps below.

github_step_one.png

github_step_two.png

  1. Open the Anaconda 3 Prompt as a user and type ‘cd..’ and then press enter. Continue this process until you have returned to your home directory (c:\ on windows)
  2. Type ‘cd yolov5-master’ and press enter.

yolo_master.png

  1. Type ‘conda create -n yolov5demo python=3.8’ and press enter. yolov5demo can be replaced with anything you want to name your environment.

conda_create.png

  1. Type ‘y’ and press enter.

conda_accept.png

  1. Type ‘activate yolov5demo’ which will activate the environment

conda_activate.png

  1. Download Pytorch in the Anaconda 3 prompt by typing the conda or pip command based on your hardware (see pytorch website).

pytorch_home.png

pytorch_install.png

  1. Type ‘y’ and press enter.

pytorch_proceed.png

  1. To verify the previous step in the same prompt session type: python (press enter), then type: import torch (press enter). If your terminal looks like the one below you have successfully downloaded pytorch, otherwise return to step 6 and give your new environment another name. Once you have successfully installed pytorch, then type: exit() or press ctrl+c to return to the normal terminal command line.

verify_install.png

  1. Type ‘pip install -r requirements.txt’ and press enter.

pip_requirements.png

Running Model

  1. Type
  python [detect.py](http://detect.py) —-source o —-conf-thres 0.3 —-weights yolov5s.pt

python_detect.png

  1. Congratulations you are now working with AI! Press ctrl + c to exit

Training Model

Here is a list of items that Yolov5 is pre-trained to recognize.

When training a model to recognize a custom object the two options are to create or download a dataset of your desired custom object. If you find a dataset the following two steps can be skipped.

  1. Create a folder with the images of your desired custom object
  • You will need images to train, validate, and test your model.
    • See useful links for more information on best practices, but essentially the more images you have will result in a more robust trained model.
  1. Register a free account with Roboflow to create a customized dataset based on the images in your folder
  • Roboflow will assist in image labeling. This includes classification and creating the bounding boxes for your custom dataset.
    • At the end of your image labeling, you will be able to export your custom dataset as a zip file or download code to import into a python script.

In the yolov5 GitHub documentation there is a tutorials tab, select the “Train Custom Data”

Implementing Model

  1. Back in the anaconda prompt terminal, type ‘python detect.py — source o —conf-thres o.3 —weights file_location_of_your_trainined_model
  2. Press ctrl+c to exit

Conclusion

You have completed the step-by-step kit on object detection. By now, you should have a solid understanding of what object detection is and how it works, as well a popular open-source framework used in the field. You should also have learned how to set up and manage your coding environment using Anaconda. As mentioned previously, object detection is an essential technology with countless applications in various industries, including healthcare, security, and manufacturing. By mastering the skills covered in this kit, you are now equipped to apply object detection to solve real-world problems, such as detecting defects in manufacturing processes or identifying anomalies in security footage. As with any technical skill, mastering object detection takes practice and dedication. We encourage you to continue learning and exploring this exciting field and to apply what you have learned to make a positive impact.

Last updated 2 days ago
Was this helpful?
Thanks!