Skip to content

ildehakale/YOLO-Annotation-Tool

Repository files navigation

YOLO-Annotation-Tool

The YOLO Annotation Tool is a comprehensive solution for creating, editing, and managing object detection datasets in YOLO format. It features an intuitive GUI, automatic detection using YOLO models with SAHI support, and efficient batch processing capabilities.

Python Ultralytics YOLO OpenCV License: MIT

Demo

Demo

Installation & Usage

Step 0: Clone the Repository

git clone https://github.com/ildehakale/YOLO-Annotation-Tool.git
cd YOLO-Annotation-Tool

Step 1: Create a Virtual Environment

Create the Environment

python3 -m venv label_venv --system-site-packages

Activate it

For Windows:

.\label_env\Scripts\activate

For Linux:

source label_env/bin/activate

Step 2: Install Dependencies

  1. Before install the requirements.txt, run the command below to install torch with CUDA supported.
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124
  1. Install requirements.txt
pip install -r requirements.txt

For LinuxOS (Ubuntu)

  1. Install libxcb
sudo apt-get install -y libxcb-xinerama0 libxcb-cursor0 libxkbcommon-x11-0
  1. If you don't use Linux, comment the lines from main.py
    # Linux platform settings 
    os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms"
    os.environ["QT_QPA_PLATFORM"] = "xcb"

Step 3: Prepare Model Directory

  • Place your YOLO model files (.pt) in the models/ folder.

Step 4: Run the Application

python3 main.py

Docker Installation

Run the application through VNC using Docker.

Setup

# Clone the repository
git clone https://github.com/ildehakale/YOLO-Annotation-Tool.git
cd YOLO-Annotation-Tool

# Build the Docker image
docker-compose build

# Start the container
docker-compose up -d

Access the Application

Connect to the VNC interface from your web browser:

http://localhost:6080/vnc.html

VNC Password: yololabel123

Data Management

  • Models: Add your .pt files to the ./models/ folder
  • Dataset: Place your images and label files in the ./data/ folder

Configuration

Edit config/settings.py to customize the application:

Class Configuration

IMPORTANT: By default, this tool is configured for only 2 classes (person=0, car=2).

To add more classes:

  1. Open config/settings.py
  2. Add your class IDs to ALLOWED_CLASSES
  3. Add corresponding class names to class_names dictionary

Example configuration (default):

# Allowed classes for detection (COCO format)
ALLOWED_CLASSES = {0, 2}   # 0=person, 2=car

# Class names mapping
class_names = {
    0: "person",
    2: "car"
}

Note: You must update both ALLOWED_CLASSES and class_names in config/settings.py for new classes to work properly. Refer to COCO class IDs for the complete list.

Controls

Zoom Functionality

Zoom in for precise labeling:

  • Hold Ctrl and scroll up/down to zoom

Mouse Controls

Action Description
Left Click + Drag Draw new bounding box
Right Click Toggle selection of bounding box (multi-select)
Middle Click + Drag Pan the image
Ctrl + Scroll Zoom in/out at cursor position

Keyboard Shortcuts

Key Action
(Right Arrow) Next image
(Left Arrow) Previous image
Delete Delete all selected bounding boxes

File Formats

Supported Image Formats

  • .jpg, .jpeg, .png

YOLO Format

Labels are saved as .txt files with the same name as the image:

class_id,center_x,center_y,width height

Example: labels/image001.txt

0 0.716797 0.395833 0.216406 0.147222
2 0.687500 0.379167 0.255469 0.158333

Model Formats

Supported Models:

  • .pt - PyTorch YOLO models (Ultralytics)

Model Requirements:

  • Must be trained for object detection
  • Output should match YOLO format
  • Compatible with Ultralytics

Example Dataset Folder Structure

my_dataset/
├── images/
│   ├── img_0001.jpg
│   ├── img_0002.jpg
│   └── img_0003.png
└── labels/
    ├── img_0001.txt
    ├── img_0002.txt
    └── img_0003.txt

Troubleshooting

Depending on the models and SAHI used, incorrect or unnecessary detections may occur during object detection. Follow the steps below:

1. Please adjust the parameters on the left side of the application to suit your dataset and model.

2. To delete unnecessary bbox labels, right-click on the bbox and then press the "Delete" key to remove that filter.

Citation

SAHI Paper:

@article{akyon2022sahi,
  title={Slicing Aided Hyper Inference and Fine-tuning for Small Object Detection},
  author={Akyon, Fatih Cagatay and Altinuc, Sinan Onur and Temizel, Alptekin},
  journal={2022 IEEE International Conference on Image Processing (ICIP)},
  doi={10.1109/ICIP46576.2022.9897990},
  pages={966-970},
  year={2022}
}

SAHI Software:

@software{obss2021sahi,
  author       = {Akyon, Fatih Cagatay and Cengiz, Cemil and Altinuc, Sinan Onur and Cavusoglu, Devrim and Sahin, Kadir and Eryuksel, Ogulcan},
  title        = {{SAHI: A lightweight vision library for performing large scale object detection and instance segmentation}},
  month        = nov,
  year         = 2021,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.5718950},
  url          = {https://doi.org/10.5281/zenodo.5718950}
}

SAHI Repository: https://github.com/obss/sahi