Metadata-Version: 2.4
Name: labelmev2
Version: 2.0.3
Summary: Image Polygonal Annotation with Python - V2 with 45x Faster Performance
Project-URL: Homepage, https://github.com/jakhon37/LabelMeV2
Project-URL: Repository, https://github.com/jakhon37/LabelMeV2
Project-URL: Issues, https://github.com/jakhon37/LabelMeV2/issues
Project-URL: Changelog, https://github.com/jakhon37/LabelMeV2/blob/main/CHANGELOG.md
Project-URL: Original Project, https://github.com/wkentaro/labelme
Author-email: Jakhongir Nodirov <jakhon37@gmail.com>
Maintainer-email: Jakhongir Nodirov <jakhon37@gmail.com>
License: GPL-3.0-only
License-File: LICENSE
Keywords: Computer Vision,Deep Learning,Image Annotation,LabelMe,Labeling Tool,Machine Learning
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: imgviz>=2.0.0
Requires-Dist: loguru
Requires-Dist: matplotlib
Requires-Dist: natsort>=7.1.0
Requires-Dist: numpy
Requires-Dist: osam>=0.3.1
Requires-Dist: pillow>=2.8
Requires-Dist: pyqt5-qt5!=5.15.11,!=5.15.12,!=5.15.13,!=5.15.14,!=5.15.15,!=5.15.16; sys_platform == 'win32'
Requires-Dist: pyqt5-qt5!=5.15.13; sys_platform == 'linux'
Requires-Dist: pyqt5>=5.14.0
Requires-Dist: pyyaml
Requires-Dist: scikit-image
Requires-Dist: shapely>=2.0.0
Description-Content-Type: text/markdown

# LabelMe V2

<div align="center">
  <img src="labelme/icons/icon-256.png" width="200" height="200">
  
  ### Image Annotation Tool with Advanced Features & Performance Optimizations
  
  [![PyPI](https://img.shields.io/pypi/v/labelmev2.svg)](https://pypi.python.org/pypi/labelmev2)
  [![Python Version](https://img.shields.io/pypi/pyversions/labelmev2.svg)](https://pypi.org/project/labelmev2/)
  [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
  [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](LICENSE)
  [![Tests](https://img.shields.io/badge/tests-38%20passed-brightgreen.svg)]()
  
  **Enhanced fork of [wkentaro/labelme](https://github.com/wkentaro/labelme) with 45x faster loading & productivity features**
</div>

---

## 🎯 What's New in This Fork

This enhanced version adds powerful polygon editing features, **45x faster image loading**, and improved defaults to speed up your annotation workflow:

### ⚡ **Breakthrough Performance: 45x Faster Loading**

The biggest improvement in this fork - **optimized TIFF/JPG/PNG loading** for massive images:

| Image Size | Before | After | Speedup |
|------------|--------|-------|---------|
| 6050×12300 TIFF (71MB) | **10 seconds** | **220ms** | **45x faster** ⚡ |
| Large JPG/PNG | 2-3 seconds | 200-400ms | **10x faster** |
| Cached images | N/A | <200ms | Instant navigation |

**How it works:**
- ✅ Skip slow PIL conversion - load directly with Qt
- ✅ Skip JSON base64 decode - load from file when possible
- ✅ Smart image caching (3-image LRU cache)
- ✅ Automatic downsampling for huge images

**Perfect for:** Industrial inspection, PCB analysis, medical imaging, aerial photography

---

### ✨ New Features

#### 1. **Performance Optimizations** ⚡
Smooth annotation even with massive images and many polygons.

- **Viewport Culling**: 5-10x faster rendering with 100+ polygons
- **Adaptive Downsampling**: 4x less memory for large images (16000×8000)
- **Optimized Loading**: 45x faster for large TIFF files
- Configurable thresholds and quality settings
- Works automatically - no manual intervention

**Example:** Annotate 16000×8000 PCB images with 500 polygons smoothly on 4GB RAM.

#### 2. **Enhanced Zoom (Up to 5000%)**
Maximum zoom increased from 1000% to 5000% (50x magnification) for tiny defect annotation.

- Configurable maximum zoom level
- Adjustable zoom increment for smooth control
- Perfect for PCB defects, microscopy, surface inspection
- Mouse wheel zooms centered on cursor position

**Example:** Annotate hairline cracks or solder bridges with pixel-level precision.

#### 3. **Multiple Point Addition** (`Ctrl+M`)
Quickly refine polygon boundaries by adding multiple evenly-spaced points along edges.

- Hover over any polygon edge in edit mode
- Press `Ctrl+M` and enter number of points (1-100)
- Points are automatically distributed evenly
- Perfect for curved edges or complex boundaries

**Example:** Add 10 points to a curved car windshield edge in one action instead of clicking 10 times.

#### 4. **Polygon Merge** (`Ctrl+Shift+M`)
Merge multiple polygons into one or batch-apply labels to disconnected objects.

- Select 2+ polygons (hold `Ctrl` while clicking)
- Press `Ctrl+Shift+M` to merge
- Smart handling:
  - **Connected/overlapping** → Single merged polygon
  - **Disconnected objects** → Multiple polygons with same label
  - **Mixed** → Intelligent separation based on connectivity

**Example:** Annotate 20 cars by drawing rough boxes, select all, merge once - all labeled "car" instantly.

#### 5. **Dark Mode** (View → Dark Mode)
Eye-friendly dark theme inspired by VS Code.

- Toggle instantly via View menu
- Persistent setting saved in config
- Reduces eye strain during long sessions
- Professional color scheme

#### 6. **Improved Default Settings**
Better defaults for faster annotation workflow:

| Setting | Old Default | New Default | Why? |
|---------|-------------|-------------|------|
| `auto_save` | `false` | `true` | Never lose work |
| `store_data` | `true` | `false` | Smaller JSON files |
| `keep_prev_brightness_contrast` | `false` | `true` | Consistent visuals |
| `dark_mode` | N/A | `true` | Eye comfort |
| `canvas.fill_drawing` | `true` | `false` | See through shapes |
| `canvas.num_backups` | 10 | 20 | More undo history |
| `max_zoom` | 1000% | 5000% | 5x more zoom |

#### 7. **Better Keyboard Shortcuts**
More intuitive shortcuts that don't conflict:

| Action | Old Shortcut | New Shortcut |
|--------|--------------|--------------|
| Create Polygon | `Ctrl+N` | `Ctrl+Shift+C` |
| Create Rectangle | `Ctrl+R` | `Ctrl+Shift+X` |
| Edit Polygon | `Ctrl+J` | `Ctrl+Shift+V` |

---

## 📦 Installation

### From PyPI (Recommended)

```bash
pip install labelmev2
```

### From Source

```bash
# Clone this enhanced version
git clone https://github.com/jakhon37/LabelMeV2.git
cd LabelMeV2

# Install with pip
pip install -e .

# Or use uv (faster)
uv pip install -e .
```

---

## 🚀 Quick Start

```bash
# Launch labelme
labelme

# Enable dark mode (if not already on)
View → Dark Mode

# Try the new features:
# 1. Draw a polygon
# 2. Press Ctrl+Shift+V to enter edit mode
# 3. Hover over an edge and press Ctrl+M
# 4. Enter "5" to add 5 points
# 5. Adjust the points as needed
```

### New Feature Quick Reference

| Feature | Shortcut | Usage |
|---------|----------|-------|
| **High Zoom (5000%)** | Mouse wheel | Scroll on image to zoom up to 50x magnification |
| **Add Multiple Points** | `Ctrl+M` | Edit mode → Hover edge → Ctrl+M → Enter count |
| **Merge Polygons** | `Ctrl+Shift+M` | Select multiple → Ctrl+Shift+M |
| **Dark Mode** | View menu | View → Dark Mode (toggles instantly) |
| **Edit Mode** | `Ctrl+Shift+V` | Enter polygon editing mode |

---

## 📚 Documentation

- **New Features Guide**: [docs/NEW_FEATURES.md](docs/NEW_FEATURES.md)
- **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md)
- **Original Documentation**: See [wkentaro/labelme](https://github.com/wkentaro/labelme) for:
  - Basic usage and examples
  - Export formats (VOC, COCO)
  - AI-assisted annotation
  - Command-line tools
  - Video annotation
  - Classification/segmentation workflows

---

## 🎬 Examples

### Polygon Refinement Workflow
```
1. Draw rough polygon around object
2. Ctrl+Shift+V (edit mode)
3. Hover over curved edge
4. Ctrl+M → Enter "8" → OK
5. Adjust 8 new points to match boundary perfectly
```

### Batch Labeling Workflow
```
1. Draw boxes around 15 cars (quick rough boxes)
2. Ctrl+Click each box to select all
3. Ctrl+Shift+M (merge)
4. Result: 15 separate polygons all labeled "car"
```

---

## 🔧 Configuration

Enhanced defaults in `~/.labelmerc`:

```yaml
# New/modified defaults
auto_save: true
dark_mode: true
store_data: false
keep_prev_brightness_contrast: true

# Zoom settings
zoom_increment: 1.45  # 45% per step (ultra fast for quick navigation)
max_zoom: 5000        # 5000% = 50x magnification

# New features config
default_num_points_to_add: 1

shortcuts:
  add_multiple_points: Ctrl+M
  merge_polygons: Ctrl+Shift+M
  create_polygon: Ctrl+Shift+C
  create_rectangle: Ctrl+Shift+X
  edit_polygon: Ctrl+Shift+V
```

---

## 🤝 Contributing

Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for:
- Development setup
- Code style guidelines
- Testing procedures
- Feature implementation details

---

## 📄 License

GPL-3.0-only - Same as original [wkentaro/labelme](https://github.com/wkentaro/labelme)

---

## 🙏 Acknowledgments & Credits

**This project is based on [wkentaro/labelme](https://github.com/wkentaro/labelme)**

- **Original Author**: [Kentaro Wada](https://github.com/wkentaro)
- **Original Repository**: https://github.com/wkentaro/labelme
- **License**: GPL-3.0 (maintained in this fork)

This enhanced version builds upon the excellent foundation of the original labelme, adding:

**Performance Enhancements by Jakhongir Nodirov:**
- ⚡ 45x faster image loading for large TIFF/JPG/PNG files
- 🖼️ Smart image caching with LRU eviction
- 🎨 Viewport culling for smooth rendering with hundreds of polygons
- 📊 Optimized memory usage for massive images

**New Features:**
- 🔍 Enhanced zoom up to 5000% for tiny defect inspection
- ➕ Multiple point addition (Ctrl+M) for quick polygon refinement
- 🔗 Polygon merge (Ctrl+Shift+M) for batch labeling
- 🌙 Dark mode for comfortable annotation sessions
- ⚙️ Improved default settings for faster workflows

**Maintained by**: [Jakhongir Nodirov](https://github.com/jakhon37) (jakhon37@gmail.com)

For the complete original labelme documentation and features, please visit the [official repository](https://github.com/wkentaro/labelme).

---

## ⭐ Support

If you find these enhancements useful:
- ⭐ Star this repository
- 🐛 Report issues on [GitHub Issues](https://github.com/jakhon37/LabelMeV2/issues)
- 💬 Share feedback and suggestions
- ⭐ Also star the [original labelme](https://github.com/wkentaro/labelme) project!
