Back
CCTV Camera by T Junction

Setup Guide 2: Installing YOLO and Running Your First Detection

Computer ready, YOLO next. This is the short one, two steps between you and your first working detection.

This is the second of two setup posts. The first got Python and VS Code installed and your project folder ready. If you haven't done that yet, start there, everything below assumes it's already done.

From here, it's quick: install one library, run one file, done.

What You'll Do in This Post

  • Step 1: Install the Ultralytics library
  • Step 2: Run your first detection

Same as the last post, each step ends with a quick check so you know it worked before moving on.

1Install the Ultralytics Library

This is the library that gives you YOLO itself. In the terminal you opened inside your project folder, type:

pip install ultralytics

This downloads and installs everything needed to load and run a YOLO model. It can take a minute or two the first time, that's normal.

What Is a Virtual Environment?

You may see other tutorials mention "virtual environments" before installing anything. This keeps each project's installed libraries separate from your computer's main Python setup, genuinely useful once you're juggling multiple projects, but not something you need to worry about for this first one. It's worth learning once you're comfortable with the basics above.

Checkpoint

Type pip show ultralytics in the terminal. If it prints details like a version number and file location instead of an error, the install worked and you're ready for Step 2.

2Run Your First Detection

Create a new file in your project folder called detect.py, and paste this in:

from ultralytics import YOLO

model = YOLO("yolo11n.pt")
results = model("https://ultralytics.com/images/bus.jpg")
results[0].show()

This uses a sample image hosted by Ultralytics, so you don't even need your own photo to test with yet. Save the file, then in your terminal, type:

python detect.py

The first run downloads the YOLO model itself, so it'll pause for a moment, that's expected.

Checkpoint

A window should open showing the sample image with boxes drawn around everything YOLO found, buses, people, and more, each labelled with what it is and how confident the model is. If you see that, every step in both posts has worked.

Diagram showing what happens when you run detect.py, from photo to detected objects

You're Ready

That's the whole setup done. From here, the post on running YOLO on your own photos will make a lot more sense, since everything it asks you to do, you've now already done once.

Leave A Reply