Getting started quickly with YOLOv3: Building a training environment on Windows 10


Preface

In today's rapidly developing field of artificial intelligence, object detection technology plays an important role. YOLOv3, as an advanced real-time object detection system, has attracted much attention due to its efficiency and accuracy. This tutorial aims to provide an introductory guide to help beginners and developers quickly get started with YOLOv3 on the Windows 10 platform.

We will show how to use ultralytics/yolov3, a popular YOLOv3 implementation on GitHub Build a complete training environment. From creating a Python virtual environment to configuring PyCharm, from running detection code to solving common problems, we will guide you through the entire process step by step, ensuring that even beginners with no deep learning background can proceed smoothly.


1. Preparation

Before starting the YOLOv3 project, make sure that our system environment and tools are fully prepared. Below is the infrastructure and resources needed to get this project off the ground.

  • Windows 10: Make sure our computer is running Windows 10 operating system. Windows 10 provides stable support and compatibility, suitable for developing and testing deep learning applications.
  • Anaconda: Use Anaconda to manage our Python environment and dependencies. Anaconda is a popular Python data science platform that allows us to easily create and manage multiple Python environments. This is useful for using different versions of Python and libraries in different projects.
  • PyCharm: Select PyCharm as the integrated development environment (IDE). PyCharm is a popular Python IDE that offers many useful features such as code auto-completion, project management tools, and powerful debugging options. It can greatly improve our development efficiency.
  • Source code download: Visit the GitHub page of ultralytics yolov3:https://github.com/ultralytics/yolov3< a i=3> to download the latest source code. The GitHub page provides detailed documentation, installation guides, and usage instructions to help us better understand and use YOLOv3.
  • Version check: Confirm that we downloaded the latest version of YOLOv3. You can check the latest version information on the project's GitHub page. Currently we are using v9.6.0
    YOLOv3 current version
  • Pre-trained model: We can find it inReleasesyolov3.pt are downloaded to the same directory as the source code for later use.
    Pre-trained model

Making sure to check these requirements before starting can help us avoid unnecessary problems later in the installation and configuration process.

2. Basic environment preparation

In order to start our YOLOv3 project smoothly, we need to first prepare the basic development environment. Here are detailed step-by-step instructions:

1. Create a virtual environment

  • Virtual environment name: Create a virtual environment named ultralytics in Anaconda. This will help isolate our project dependencies and ensure a consistent environment.
  • Python version: Select the default version of Python3.8.18. This version is the currently popular stable version, and all required libraries and frameworks are compatible with it. ultralyticsultralytics environment

2. Open Terminal

  • Access Terminal: After Anaconda prepares the Python environment, click the green arrow icon on the interface to open the Terminal terminal. This will be where we execute subsequent installation commands.
    Open Terminal

3. Download YOLOv3 operating environment

  • Installation command: Enter the commandpip install ultralytics in Terminal to install the YOLOv3 operating environment. This command will install all necessary dependencies and libraries.

  • Use domestic mirrors: In order to speed up the download and installation process, we can use domestic mirror sources. For example, the Tsinghua University open source software mirror station can provide faster download speeds. Here are the steps to add an image:

    Mirror address: Tsinghua University open source software mirror station:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

    The added mirror sources can also include:

    • https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    • https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ Add image
  • Waiting for installation: After the command is executed, wait patiently for all dependencies and libraries to be installed. Wait for installation to complete
    Run completed

By completing these steps, we will establish a stable and efficient development environment suitable for the YOLOv3 project. This not only helps us develop and test the project more smoothly, but also avoids potential troubles caused by environmental issues.

3. PyCharm association

After preparing the environment for Python and YOLOv3, the next step is to associate these configurations with the PyCharm IDE. This ensures convenience and efficiency during the development process.

3.1 Running PyCharm

  • Open PyCharm: First, find the YOLOv3 code we have downloaded. Right-click on the code folder and select Open with PyCharm. This ensures that PyCharm correctly recognizes the project's structure and settings.

    Run PyCharm

3.2 Associate the Anaconda virtual environment

  • Access settings: After opening the project in PyCharm, click Settings on the menu bar to enter the IDE settings.

    Settings

  • Add virtual environment: In the settings interface, select the Python interpreter section of the project and click Add to add a new interpreter.

    Add

  • Select an existing environment: In the window to add an interpreter, select "Conda Environment" and then "Existing environment" to specify the one previously created in AnacondaultralyticsVirtual environment.

    Existing environment

    Manually search for the environment: If PyCharm does not automatically detect our Anaconda environment, you can click the ... button to manually browse and select the corresponding Python interpretation device location.
    Manual selection

With these steps, our PyCharm IDE will now use theultralytics virtual environment in Anaconda, which means that all dependencies and libraries installed in this environment will be available in PyCharm without sewing use. Such a configuration helps keep the development environment clean and consistent.

4. Operating environment inspection

Before starting programming, an important step is to ensure that all required packages and dependencies are installed and up to date. This will ensure that the code runs seamlessly in the intended environment.

1. 检查requirements.txtMessage

  • Open file: First, open the requirements.txt file in the project. This file lists all the Python packages required to run the project.

  • Check dependencies: Lookrequirements.txt in the file and note if there are any unmet package requirements. For example, we may see a yellow warning like “Package requirement ‘gitpython>=3.1.30’ is not satisfied”.

    requirements.txt

2. Install dependencies

  • Open Terminal: In PyCharm, open the Terminal tab at the bottom, click the symbol, and select < /span>Command Prompt. Here, we can directly run commands to install and manage Python packages.
    Command Prompt

  • Execute the installation command: Enter the command in Terminalpip install -r requirements.txt. This command will automatically install or update package versions based on the ones listed in the requirements.txtfile.
    pip install -r requirements.txt

  • Wait for installation to complete: The installation process may take several minutes, depending on network speed and computer performance. Monitor progress and ensure no errors occur.
    Waiting for installation requirements

  • Installation completed: When all packages are installed, we will see the installation completion message. This means that the Python environment is now ready to run the YOLOv3 project.

The installation is complete

By completing these steps, we can ensure that the project's Python environment is configured correctly, which is crucial for subsequent development and testing work.

5. Run the code

After completing the preparation and configuration of the environment, the next step is to run the YOLOv3 code for object detection and model training.
We check again yolov3.pt whether it has been saved to the root directory of the source code.
Insert image description here

5.1 Run detection code

  • Start the detection script: In PyCharm, in the project, find the detect.py file.
  • Modify weight file: Modify the weight file toyolov3.pt.
  • Execute script: Run this script, which will use the YOLOv3 model to perform object detection on the default image.
  • View results: After the script runs, view the output. We should see the results of object detection.

Modify the run detection code
Run detection code

Detect code execution results
Test results

5.2 Run the training code

  • Location training script: In the project, find the filetrain.py. This file contains the code used to train the YOLOv3 model.
  • Modify the weight file: Here we take yolov3-tiny.pt as an example. The download link is: https:// github.com/ultralytics/yolov3/releases/download/v9.6.0/yolov3-tiny.pt.
  • Start training process: Runtrain.py script to start the training process. The training process may take some time, depending on our dataset size and the performance of your computer.
  • Monitor training progress: During the training process, monitor the output log information to understand the progress and effect of the training.

Positioning training script

Download dataset
Start running the training code

After completing these steps, our running environment is basically complete. Efficient object detection and model training is now possible using YOLOv3. These steps provide practical experience and give us a better understanding of how to use deep learning models in real projects.

6. Frequently Asked Questions

When using YOLOv3 for project development, we may encounter some common problems. Here is a brief overview of these issues and a guide on how to resolve them.

6.1 ImportError: cannot import name ‘notf’ from ‘tensorboard.compat’

  • Problem description: When trying to run YOLOv3 code, you may encounter an error indicating that it cannot be imported from. tensorboard.compatnotf
  • Possible reasons: This problem usually occurs when TensorFlow has been installed in the environment, but is incompatible with some dependencies of YOLOv3.
  • Solution plan:
    • Uninstall TensorBoard: Use the commandpip uninstall tensorboard to uninstall TensorBoard. This usually resolves compatibility issues.
    • Looking for compatibility solutions: If we need to use TensorBoard, we need to find a TensorBoard version that is compatible with YOLOv3.

6.2 OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.

  • Problem Description: When installing or running YOLOv3, an error about libiomp5md.dll may occur.
  • Possible reasons: This error may occur when the dependencies required by YOLOv3 are not installed in the correct order.
  • Solution plan:
    • Install dependencies in order: In order to avoid this problem, it is recommended to first execute the commandpip install ultralytics to install the basic operating environment of YOLOv3, and then use < /span>pip install -r requirements.txt to install other dependencies. This ensures the correct installation order of dependencies and reduces compatibility issues.

By understanding these common problems and their solutions, we can develop and run the YOLOv3 project more smoothly. These solutions can help us overcome technical obstacles we may encounter and ensure the smooth progress of the project.


Summarize

Through the guidance of this tutorial, we should now be able to successfully set up and run the YOLOv3 training environment on the Windows 10 operating system. From creating an appropriate Python virtual environment, configuring PyCharm, to running detection and training scripts, and handling some common issues, we've covered every aspect of the entire setup and usage process. I hope these guidance can help us start the YOLOv3 project smoothly and achieve remarkable results in the field of object detection.
Remember, practice is the key to learning, so experimenting, adjusting, and optimizing are important steps toward success.

Guess you like

Origin blog.csdn.net/qq_31463571/article/details/134786919