A modern annotation tool for annotating visual relationships in COCO format.
# Install dependencies
pip install -r requirements.txt
# Run
python main_coco_pyqt.py --output name_of_output_file.json# Run tkinter version
python main_coco.py --output name_of_output_file.json- 📝 COCO Format Support: Load existing COCO JSON annotations
- 🔗 Relationship Annotation: Create subject-predicate-object relationships
- 🎯 Object Selection: Click or list-based object selection
- 💾 Multiple Export Formats: COCO, JSON, and TXT outputs
- ⌨️ Keyboard Shortcuts: Efficient workflow navigation
- 🌙 Modern Dark Theme: Nord color scheme
- 🎨 Custom Styled Components: Professional UI elements
- 🖼️ Advanced Canvas: Smooth image rendering with bounding boxes
- 📱 Responsive Layout: Splitter-based resizable panels
- 🎮 Enhanced Dialogs: Modern predicate selection
- 🔄 Fallback Compatibility: Works without PyQt6
- 📋 Dialog System: Custom dialog components
- 🖱️ Advanced Selection: Shift+click unselection support
- 📏 4K Display Support: Adaptive dialog sizing
- Python 3.7+
- PIL/Pillow for image processing
pip install -r requirements.txt- It is recommended to annotate the bounding boxes with an external tool such as https://roboflow.com/. Roboflow is more practical for bounding box annotations and will save time with big datasets. You can also annotate bounding boxes with SGG-Annotate but it will be less efficient.
- Once you have created your dataset, export bounding box annotations in COCO format (json file).
- Click "Load COCO JSON" and select your COCO annotations file
- Select the folder containing your images
- Click "Load Relationships" and select a text file with relationship types
- File should contain one relationship per line (e.g., "on", "under", "next to")
- Click "Create Relationship" to enter annotation mode
- Select subject object (highlighted in blue)
- Select object object (highlighted in green)
- Choose predicate from the dialog
- Click "Save Relations" to export in multiple formats
- Files saved to
output_coco_relations/directory
| Key | Action |
|---|---|
Ctrl+O |
Load COCO JSON |
Ctrl+R |
Load Relationships |
Ctrl+S |
Save Relationships |
Ctrl+T |
Toggle Relation Mode |
Escape |
Cancel Operation |
Left/Right |
Navigate Images |
Space |
Save Current |
Enhanced COCO JSON with rel_annotations and rel_categories fields:
{
"rel_annotations": [
{
"id": 0,
"subject_id": 123,
"predicate_id": 1,
"object_id": 456,
"image_id": 789
}
],
"rel_categories": [
{"id": 0, "name": "on"},
{"id": 1, "name": "under"}
]
}This format of annotations can be use with the SGG-Benchmark codebase to train SOTA SGG models.
# Modern modular approach
from pyqt6_ui.main_window import COCORelationAnnotatorPyQt
from pyqt6_ui.components import ModernButton, ModernLabel
from pyqt6_ui.canvas import ImageCanvas
from pyqt6_ui.dialogs import PredicateSelectionDialog# Falls back to tkinter version
python main_coco.py- Ensure PIL/Pillow is installed:
pip install Pillow - Check image file formats (JPG, PNG supported)
- Tool automatically scales images for display
- Original coordinates preserved for annotations
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
