iTranslated by AI
[YOLO: Part 1 - Model] Building an Object Detection App with FastAPI x YOLO
Introduction
As a study of machine learning and FastAPI, I built the content of this article and would like to introduce it!
The object detection model used is provided under the AGPL-3.0 license, so please be careful not to use it for business purposes. [1]
Applications incorporating ultralytics YOLO also need to apply AGPL-3.0.
What license options are available for Ultralytics YOLO?
Ultralytics offers two license options for YOLO.AGPL-3.0 License: This open-source license is ideal for educational and non-commercial use, fostering open collaboration.
Enterprise License: Designed for commercial applications, this allows seamless integration of Ultralytics software into commercial products without the restrictions of the AGPL-3.0 license.
For more details, please visit the license page.
Features
When you send an image to the system as shown below, the machine learning model detects objects in the image and returns the image with bounding boxes.

Running FastAPI server on WSL

Send an image, get the image with detection results
Operating Environment
- WSL (Windows 11)
- Python 3.8+
- uv
- YOLO11m (Ultralytics COCO 80 classes) [3]
Prerequisites and Target Audience
The code for this project is available here:
Building Steps
Open WSL and clone the repository
git clone https://github.com/aToy0m0/fast-api-YOLOv11-BearerAPI
cd fast-api-YOLOv11-BearerAPI
Virtual Environment
uv venv
source .venv/bin/activate
Install Required Packages
uv pip install -r requirements.txt
Pre-download YOLO Model
Download yolo11m.pt from the Ultralytics official site and save it in models/:
- https://github.com/ultralytics/assets/releases
- Example save:
project/models/yolo11m.pt
If using CLI:
mkdir -p models
cd models/
TAG=v8.3.0 # Replace with the latest tag
curl -L -o yolo11m.pt "https://github.com/ultralytics/assets/releases/download/${TAG}/yolo11m.pt"
Configure API Key and Inference Parameters
openssl rand -hex 32
cp .env.example .env
nano .env
$ cat .env
# use command below to generate a secret key
## openssl rand -hex 32
DETECTION_API_KEY="your-secret-key"
Start the Server
uvicorn main:app --reload
If accepting external access to the server
uvicorn main:app --reload --host 0.0.0.0 --port 8000
Verification
This section describes how to test using a GUI tool.
For testing methods using curl and python, please refer to the README[4].
Prepare a sample image
Download the following:
https://ultralytics.com/images/zidane.jpg
project/
├── test/
│ └── zidane.jpg
If using CLI:
mkdir -p test
curl -L https://ultralytics.com/images/zidane.jpg -o test/zidane.jpg
Open the test tool in a browser
project/
├── test/
│ └── tester.html
Set the following two items:
- API URL:http://server-ip:8000/detect
- API Key (Bearer):The key set in "DETECTION_API_KEY" in ".env"
Run object detection!
We will borrow an image from Adobe Stock's Multiracial business people working in office. (You can use any image you like.)
- Upload an image with "Choose File"
- Click "Send Image"
We were able to detect each object as shown below!

Conclusion
We've successfully built an object detection system! This time, we used a pre-trained model restricted to research purposes, but in the future, we plan to train our own models and develop systems using appropriate models.
✍️ If you found this article helpful, please "Like", "Bookmark", and "Follow"!
I also welcome interaction on X!
Discussion