bird-crop 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bird_crop-0.1.3/LICENSE.txt +21 -0
- bird_crop-0.1.3/PKG-INFO +165 -0
- bird_crop-0.1.3/README.md +140 -0
- bird_crop-0.1.3/bird_crop.egg-info/PKG-INFO +165 -0
- bird_crop-0.1.3/bird_crop.egg-info/SOURCES.txt +16 -0
- bird_crop-0.1.3/bird_crop.egg-info/dependency_links.txt +1 -0
- bird_crop-0.1.3/bird_crop.egg-info/entry_points.txt +3 -0
- bird_crop-0.1.3/bird_crop.egg-info/requires.txt +4 -0
- bird_crop-0.1.3/bird_crop.egg-info/top_level.txt +1 -0
- bird_crop-0.1.3/birdcrop/__init__.py +32 -0
- bird_crop-0.1.3/birdcrop/__main__.py +9 -0
- bird_crop-0.1.3/birdcrop/cli.py +446 -0
- bird_crop-0.1.3/birdcrop/cropper.py +265 -0
- bird_crop-0.1.3/birdcrop/exceptions.py +26 -0
- bird_crop-0.1.3/birdcrop/upgrade.py +225 -0
- bird_crop-0.1.3/birdcrop/utils.py +206 -0
- bird_crop-0.1.3/pyproject.toml +45 -0
- bird_crop-0.1.3/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Martin Kammerhofer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
bird_crop-0.1.3/PKG-INFO
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bird-crop
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Detect and crop birds and other objects from images with YOLO models.
|
|
5
|
+
Author-email: Martin Kammerhofer <mkamm@gmx.net>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/variance/bird_crop
|
|
8
|
+
Project-URL: Repository, https://github.com/variance/bird_crop
|
|
9
|
+
Project-URL: Issues, https://github.com/variance/bird_crop/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE.txt
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: opencv-python
|
|
22
|
+
Requires-Dist: piexif
|
|
23
|
+
Requires-Dist: ultralytics
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# BirdCrop 🐦✂️
|
|
27
|
+
|
|
28
|
+
**BirdCrop** is a Python command-line utility and library designed to automatically detect objects (like birds, people, etc.) in images using YOLO models and save cropped images of those detections. It offers flexible configuration for targeting specific classes, adding margins, sorting detections, and customizing output filenames and locations using powerful templating.
|
|
29
|
+
|
|
30
|
+
Originally developed to rapidly identify and extract avian subjects from high-speed burst photography, the system has since been expanded to support multiple and diverse object classes beyond birds. It excels in its primary application: processing large volumes of in-flight bird imagery where subjects occupy only a small pixel area within the frame. By automating detection and cropping workflows for burst sequences, the tool eliminates time-intensive manual adjustments like zooming and panning while retaining analytical accuracy, making it ideal for rapid wildlife surveys and high-throughput curation of still-image datasets.
|
|
31
|
+
|
|
32
|
+
## Key Features
|
|
33
|
+
|
|
34
|
+
* **YOLO-Powered Detection:** Uses YOLO26 models by default for faster, more accurate bird detection. You can also provide a YOLOv8 or custom model with `--model`.
|
|
35
|
+
* **Flexible Class Targeting:** Specify which object classes to detect using their names (e.g., `"bird,dog,cat"`) or their model-specific IDs (e.g., `"14,16,15"`). The tool adapts to the classes present in the loaded model.
|
|
36
|
+
* **List Model Classes:** Easily list all classes and their IDs available within a specific YOLO model file using the `--list-classes` option.
|
|
37
|
+
* **Customizable Output Paths:** Define complex output file paths and names using Python's format string syntax via `--output-template`. Access detailed information about the input file, detection, and crop (see Template Variables below).
|
|
38
|
+
* **Cropping Margin:** Add a specified pixel margin around the detected bounding box before cropping using `--margin`.
|
|
39
|
+
* **Detection Sorting:** Sort multiple detections within an image by `confidence` or bounding box `size` (default) using `--sortby`.
|
|
40
|
+
* **Single or Multiple Crops:** Choose to save only the single "best" detection (highest confidence or largest size) per image or save crops for *all* detected objects using `--multiple`.
|
|
41
|
+
* **Per-Category Numbering:** Use the `{pcnr}` template variable for sequential numbering *within* each category for a given input image.
|
|
42
|
+
* **Directory Processing:** Process all supported images within specified directories, optionally searching recursively (`-r`).
|
|
43
|
+
* **Concurrent Processing:** Speed up processing on multi-core systems using parallel worker threads (`-w`).
|
|
44
|
+
* **Overwrite Control:** Prevent accidental data loss by default; use `--force` (`-f`) to allow overwriting existing crop files.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
Install the package and its runtime dependencies from PyPI:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m pip install bird-crop
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For development from a checkout:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/variance/bird_crop.git
|
|
58
|
+
cd bird_crop
|
|
59
|
+
python -m pip install .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This installs the `birdcrop` library and the `birdcrop` and `birdcrop-upgrade`
|
|
63
|
+
command-line commands. The legacy `run_birdcrop.py` and
|
|
64
|
+
`upgrade_birdcrop.py` launchers remain available when running from a checkout.
|
|
65
|
+
|
|
66
|
+
BirdCrop uses `yolo26n.pt` by default. If the selected model is not present,
|
|
67
|
+
the CLI downloads it automatically from the Ultralytics assets release. You
|
|
68
|
+
can select another YOLO26 size with `--model-size` (`nano`, `small`, `medium`,
|
|
69
|
+
`large`, or `xlarge`), or specify an existing YOLOv8/custom model with
|
|
70
|
+
`--model`.
|
|
71
|
+
|
|
72
|
+
### Model Selection
|
|
73
|
+
|
|
74
|
+
The default model is `yolo26n.pt`. Use `--model-size` to choose another YOLO26 model:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# default: yolo26n.pt
|
|
78
|
+
python run_birdcrop.py path/to/images
|
|
79
|
+
|
|
80
|
+
# use the large YOLO26 model
|
|
81
|
+
python run_birdcrop.py --model-size large path/to/images
|
|
82
|
+
|
|
83
|
+
# use a specific model file, including YOLOv8 or a custom model
|
|
84
|
+
python run_birdcrop.py --model path/to/model.pt path/to/images
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
When using `--model-size`, a missing model file is downloaded automatically. A user-specified `--model` must already exist locally.
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
The installed command is `birdcrop`:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
birdcrop [options] [INPUT_PATH ...]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The equivalent checkout command is `python run_birdcrop.py [options] [INPUT_PATH ...]`.
|
|
98
|
+
|
|
99
|
+
## Update Checks
|
|
100
|
+
|
|
101
|
+
BirdCrop can check for upstream updates at startup.
|
|
102
|
+
|
|
103
|
+
- Package versions: https://pypi.org/pypi/ultralytics/json
|
|
104
|
+
- YOLO asset release tags: https://api.github.com/repos/ultralytics/assets/releases/latest
|
|
105
|
+
|
|
106
|
+
CLI flags:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# enabled by default
|
|
110
|
+
python run_birdcrop.py --check-updates [options] [INPUT_PATH ...]
|
|
111
|
+
|
|
112
|
+
# disable all online checks
|
|
113
|
+
python run_birdcrop.py --no-update-check [options] [INPUT_PATH ...]
|
|
114
|
+
|
|
115
|
+
# network timeout per endpoint in seconds
|
|
116
|
+
python run_birdcrop.py --update-check-timeout 2.0 [options] [INPUT_PATH ...]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Upgrading
|
|
120
|
+
|
|
121
|
+
To keep BirdCrop and its YOLO models up to date, use the `birdcrop-upgrade` command:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# upgrade both the ultralytics package and download latest models
|
|
125
|
+
birdcrop-upgrade
|
|
126
|
+
|
|
127
|
+
# upgrade package only
|
|
128
|
+
birdcrop-upgrade --package-only
|
|
129
|
+
|
|
130
|
+
# download latest models only
|
|
131
|
+
birdcrop-upgrade --models-only
|
|
132
|
+
|
|
133
|
+
# download specific YOLO26 models
|
|
134
|
+
birdcrop-upgrade --models yolo26n.pt,yolo26l.pt
|
|
135
|
+
|
|
136
|
+
# download models to a specific directory
|
|
137
|
+
birdcrop-upgrade --output-dir ./models
|
|
138
|
+
|
|
139
|
+
# verbose output
|
|
140
|
+
birdcrop-upgrade --verbose
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
From a checkout, `python upgrade_birdcrop.py` remains an equivalent launcher.
|
|
144
|
+
|
|
145
|
+
The upgrade utility:
|
|
146
|
+
- Updates `ultralytics` package via `pip install --upgrade ultralytics`
|
|
147
|
+
- Downloads the latest YOLO model files from the latest [ultralytics/assets](https://github.com/ultralytics/assets) release
|
|
148
|
+
- Skips models that already exist locally (use `--package-only` or `--models-only` to update just one component)
|
|
149
|
+
|
|
150
|
+
## Building and publishing
|
|
151
|
+
|
|
152
|
+
To build distributable artifacts locally:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
python -m pip install build
|
|
156
|
+
python -m build
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This creates a source distribution and wheel in `dist/`. After configuring
|
|
160
|
+
your PyPI credentials, upload them with:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
python -m pip install twine
|
|
164
|
+
python -m twine upload dist/*
|
|
165
|
+
```
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# BirdCrop 🐦✂️
|
|
2
|
+
|
|
3
|
+
**BirdCrop** is a Python command-line utility and library designed to automatically detect objects (like birds, people, etc.) in images using YOLO models and save cropped images of those detections. It offers flexible configuration for targeting specific classes, adding margins, sorting detections, and customizing output filenames and locations using powerful templating.
|
|
4
|
+
|
|
5
|
+
Originally developed to rapidly identify and extract avian subjects from high-speed burst photography, the system has since been expanded to support multiple and diverse object classes beyond birds. It excels in its primary application: processing large volumes of in-flight bird imagery where subjects occupy only a small pixel area within the frame. By automating detection and cropping workflows for burst sequences, the tool eliminates time-intensive manual adjustments like zooming and panning while retaining analytical accuracy, making it ideal for rapid wildlife surveys and high-throughput curation of still-image datasets.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
* **YOLO-Powered Detection:** Uses YOLO26 models by default for faster, more accurate bird detection. You can also provide a YOLOv8 or custom model with `--model`.
|
|
10
|
+
* **Flexible Class Targeting:** Specify which object classes to detect using their names (e.g., `"bird,dog,cat"`) or their model-specific IDs (e.g., `"14,16,15"`). The tool adapts to the classes present in the loaded model.
|
|
11
|
+
* **List Model Classes:** Easily list all classes and their IDs available within a specific YOLO model file using the `--list-classes` option.
|
|
12
|
+
* **Customizable Output Paths:** Define complex output file paths and names using Python's format string syntax via `--output-template`. Access detailed information about the input file, detection, and crop (see Template Variables below).
|
|
13
|
+
* **Cropping Margin:** Add a specified pixel margin around the detected bounding box before cropping using `--margin`.
|
|
14
|
+
* **Detection Sorting:** Sort multiple detections within an image by `confidence` or bounding box `size` (default) using `--sortby`.
|
|
15
|
+
* **Single or Multiple Crops:** Choose to save only the single "best" detection (highest confidence or largest size) per image or save crops for *all* detected objects using `--multiple`.
|
|
16
|
+
* **Per-Category Numbering:** Use the `{pcnr}` template variable for sequential numbering *within* each category for a given input image.
|
|
17
|
+
* **Directory Processing:** Process all supported images within specified directories, optionally searching recursively (`-r`).
|
|
18
|
+
* **Concurrent Processing:** Speed up processing on multi-core systems using parallel worker threads (`-w`).
|
|
19
|
+
* **Overwrite Control:** Prevent accidental data loss by default; use `--force` (`-f`) to allow overwriting existing crop files.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Install the package and its runtime dependencies from PyPI:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python -m pip install bird-crop
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For development from a checkout:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/variance/bird_crop.git
|
|
33
|
+
cd bird_crop
|
|
34
|
+
python -m pip install .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This installs the `birdcrop` library and the `birdcrop` and `birdcrop-upgrade`
|
|
38
|
+
command-line commands. The legacy `run_birdcrop.py` and
|
|
39
|
+
`upgrade_birdcrop.py` launchers remain available when running from a checkout.
|
|
40
|
+
|
|
41
|
+
BirdCrop uses `yolo26n.pt` by default. If the selected model is not present,
|
|
42
|
+
the CLI downloads it automatically from the Ultralytics assets release. You
|
|
43
|
+
can select another YOLO26 size with `--model-size` (`nano`, `small`, `medium`,
|
|
44
|
+
`large`, or `xlarge`), or specify an existing YOLOv8/custom model with
|
|
45
|
+
`--model`.
|
|
46
|
+
|
|
47
|
+
### Model Selection
|
|
48
|
+
|
|
49
|
+
The default model is `yolo26n.pt`. Use `--model-size` to choose another YOLO26 model:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# default: yolo26n.pt
|
|
53
|
+
python run_birdcrop.py path/to/images
|
|
54
|
+
|
|
55
|
+
# use the large YOLO26 model
|
|
56
|
+
python run_birdcrop.py --model-size large path/to/images
|
|
57
|
+
|
|
58
|
+
# use a specific model file, including YOLOv8 or a custom model
|
|
59
|
+
python run_birdcrop.py --model path/to/model.pt path/to/images
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
When using `--model-size`, a missing model file is downloaded automatically. A user-specified `--model` must already exist locally.
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
The installed command is `birdcrop`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
birdcrop [options] [INPUT_PATH ...]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The equivalent checkout command is `python run_birdcrop.py [options] [INPUT_PATH ...]`.
|
|
73
|
+
|
|
74
|
+
## Update Checks
|
|
75
|
+
|
|
76
|
+
BirdCrop can check for upstream updates at startup.
|
|
77
|
+
|
|
78
|
+
- Package versions: https://pypi.org/pypi/ultralytics/json
|
|
79
|
+
- YOLO asset release tags: https://api.github.com/repos/ultralytics/assets/releases/latest
|
|
80
|
+
|
|
81
|
+
CLI flags:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# enabled by default
|
|
85
|
+
python run_birdcrop.py --check-updates [options] [INPUT_PATH ...]
|
|
86
|
+
|
|
87
|
+
# disable all online checks
|
|
88
|
+
python run_birdcrop.py --no-update-check [options] [INPUT_PATH ...]
|
|
89
|
+
|
|
90
|
+
# network timeout per endpoint in seconds
|
|
91
|
+
python run_birdcrop.py --update-check-timeout 2.0 [options] [INPUT_PATH ...]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Upgrading
|
|
95
|
+
|
|
96
|
+
To keep BirdCrop and its YOLO models up to date, use the `birdcrop-upgrade` command:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# upgrade both the ultralytics package and download latest models
|
|
100
|
+
birdcrop-upgrade
|
|
101
|
+
|
|
102
|
+
# upgrade package only
|
|
103
|
+
birdcrop-upgrade --package-only
|
|
104
|
+
|
|
105
|
+
# download latest models only
|
|
106
|
+
birdcrop-upgrade --models-only
|
|
107
|
+
|
|
108
|
+
# download specific YOLO26 models
|
|
109
|
+
birdcrop-upgrade --models yolo26n.pt,yolo26l.pt
|
|
110
|
+
|
|
111
|
+
# download models to a specific directory
|
|
112
|
+
birdcrop-upgrade --output-dir ./models
|
|
113
|
+
|
|
114
|
+
# verbose output
|
|
115
|
+
birdcrop-upgrade --verbose
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
From a checkout, `python upgrade_birdcrop.py` remains an equivalent launcher.
|
|
119
|
+
|
|
120
|
+
The upgrade utility:
|
|
121
|
+
- Updates `ultralytics` package via `pip install --upgrade ultralytics`
|
|
122
|
+
- Downloads the latest YOLO model files from the latest [ultralytics/assets](https://github.com/ultralytics/assets) release
|
|
123
|
+
- Skips models that already exist locally (use `--package-only` or `--models-only` to update just one component)
|
|
124
|
+
|
|
125
|
+
## Building and publishing
|
|
126
|
+
|
|
127
|
+
To build distributable artifacts locally:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python -m pip install build
|
|
131
|
+
python -m build
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This creates a source distribution and wheel in `dist/`. After configuring
|
|
135
|
+
your PyPI credentials, upload them with:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
python -m pip install twine
|
|
139
|
+
python -m twine upload dist/*
|
|
140
|
+
```
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bird-crop
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Detect and crop birds and other objects from images with YOLO models.
|
|
5
|
+
Author-email: Martin Kammerhofer <mkamm@gmx.net>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/variance/bird_crop
|
|
8
|
+
Project-URL: Repository, https://github.com/variance/bird_crop
|
|
9
|
+
Project-URL: Issues, https://github.com/variance/bird_crop/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE.txt
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: opencv-python
|
|
22
|
+
Requires-Dist: piexif
|
|
23
|
+
Requires-Dist: ultralytics
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# BirdCrop 🐦✂️
|
|
27
|
+
|
|
28
|
+
**BirdCrop** is a Python command-line utility and library designed to automatically detect objects (like birds, people, etc.) in images using YOLO models and save cropped images of those detections. It offers flexible configuration for targeting specific classes, adding margins, sorting detections, and customizing output filenames and locations using powerful templating.
|
|
29
|
+
|
|
30
|
+
Originally developed to rapidly identify and extract avian subjects from high-speed burst photography, the system has since been expanded to support multiple and diverse object classes beyond birds. It excels in its primary application: processing large volumes of in-flight bird imagery where subjects occupy only a small pixel area within the frame. By automating detection and cropping workflows for burst sequences, the tool eliminates time-intensive manual adjustments like zooming and panning while retaining analytical accuracy, making it ideal for rapid wildlife surveys and high-throughput curation of still-image datasets.
|
|
31
|
+
|
|
32
|
+
## Key Features
|
|
33
|
+
|
|
34
|
+
* **YOLO-Powered Detection:** Uses YOLO26 models by default for faster, more accurate bird detection. You can also provide a YOLOv8 or custom model with `--model`.
|
|
35
|
+
* **Flexible Class Targeting:** Specify which object classes to detect using their names (e.g., `"bird,dog,cat"`) or their model-specific IDs (e.g., `"14,16,15"`). The tool adapts to the classes present in the loaded model.
|
|
36
|
+
* **List Model Classes:** Easily list all classes and their IDs available within a specific YOLO model file using the `--list-classes` option.
|
|
37
|
+
* **Customizable Output Paths:** Define complex output file paths and names using Python's format string syntax via `--output-template`. Access detailed information about the input file, detection, and crop (see Template Variables below).
|
|
38
|
+
* **Cropping Margin:** Add a specified pixel margin around the detected bounding box before cropping using `--margin`.
|
|
39
|
+
* **Detection Sorting:** Sort multiple detections within an image by `confidence` or bounding box `size` (default) using `--sortby`.
|
|
40
|
+
* **Single or Multiple Crops:** Choose to save only the single "best" detection (highest confidence or largest size) per image or save crops for *all* detected objects using `--multiple`.
|
|
41
|
+
* **Per-Category Numbering:** Use the `{pcnr}` template variable for sequential numbering *within* each category for a given input image.
|
|
42
|
+
* **Directory Processing:** Process all supported images within specified directories, optionally searching recursively (`-r`).
|
|
43
|
+
* **Concurrent Processing:** Speed up processing on multi-core systems using parallel worker threads (`-w`).
|
|
44
|
+
* **Overwrite Control:** Prevent accidental data loss by default; use `--force` (`-f`) to allow overwriting existing crop files.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
Install the package and its runtime dependencies from PyPI:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m pip install bird-crop
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For development from a checkout:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/variance/bird_crop.git
|
|
58
|
+
cd bird_crop
|
|
59
|
+
python -m pip install .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This installs the `birdcrop` library and the `birdcrop` and `birdcrop-upgrade`
|
|
63
|
+
command-line commands. The legacy `run_birdcrop.py` and
|
|
64
|
+
`upgrade_birdcrop.py` launchers remain available when running from a checkout.
|
|
65
|
+
|
|
66
|
+
BirdCrop uses `yolo26n.pt` by default. If the selected model is not present,
|
|
67
|
+
the CLI downloads it automatically from the Ultralytics assets release. You
|
|
68
|
+
can select another YOLO26 size with `--model-size` (`nano`, `small`, `medium`,
|
|
69
|
+
`large`, or `xlarge`), or specify an existing YOLOv8/custom model with
|
|
70
|
+
`--model`.
|
|
71
|
+
|
|
72
|
+
### Model Selection
|
|
73
|
+
|
|
74
|
+
The default model is `yolo26n.pt`. Use `--model-size` to choose another YOLO26 model:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# default: yolo26n.pt
|
|
78
|
+
python run_birdcrop.py path/to/images
|
|
79
|
+
|
|
80
|
+
# use the large YOLO26 model
|
|
81
|
+
python run_birdcrop.py --model-size large path/to/images
|
|
82
|
+
|
|
83
|
+
# use a specific model file, including YOLOv8 or a custom model
|
|
84
|
+
python run_birdcrop.py --model path/to/model.pt path/to/images
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
When using `--model-size`, a missing model file is downloaded automatically. A user-specified `--model` must already exist locally.
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
The installed command is `birdcrop`:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
birdcrop [options] [INPUT_PATH ...]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The equivalent checkout command is `python run_birdcrop.py [options] [INPUT_PATH ...]`.
|
|
98
|
+
|
|
99
|
+
## Update Checks
|
|
100
|
+
|
|
101
|
+
BirdCrop can check for upstream updates at startup.
|
|
102
|
+
|
|
103
|
+
- Package versions: https://pypi.org/pypi/ultralytics/json
|
|
104
|
+
- YOLO asset release tags: https://api.github.com/repos/ultralytics/assets/releases/latest
|
|
105
|
+
|
|
106
|
+
CLI flags:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# enabled by default
|
|
110
|
+
python run_birdcrop.py --check-updates [options] [INPUT_PATH ...]
|
|
111
|
+
|
|
112
|
+
# disable all online checks
|
|
113
|
+
python run_birdcrop.py --no-update-check [options] [INPUT_PATH ...]
|
|
114
|
+
|
|
115
|
+
# network timeout per endpoint in seconds
|
|
116
|
+
python run_birdcrop.py --update-check-timeout 2.0 [options] [INPUT_PATH ...]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Upgrading
|
|
120
|
+
|
|
121
|
+
To keep BirdCrop and its YOLO models up to date, use the `birdcrop-upgrade` command:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# upgrade both the ultralytics package and download latest models
|
|
125
|
+
birdcrop-upgrade
|
|
126
|
+
|
|
127
|
+
# upgrade package only
|
|
128
|
+
birdcrop-upgrade --package-only
|
|
129
|
+
|
|
130
|
+
# download latest models only
|
|
131
|
+
birdcrop-upgrade --models-only
|
|
132
|
+
|
|
133
|
+
# download specific YOLO26 models
|
|
134
|
+
birdcrop-upgrade --models yolo26n.pt,yolo26l.pt
|
|
135
|
+
|
|
136
|
+
# download models to a specific directory
|
|
137
|
+
birdcrop-upgrade --output-dir ./models
|
|
138
|
+
|
|
139
|
+
# verbose output
|
|
140
|
+
birdcrop-upgrade --verbose
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
From a checkout, `python upgrade_birdcrop.py` remains an equivalent launcher.
|
|
144
|
+
|
|
145
|
+
The upgrade utility:
|
|
146
|
+
- Updates `ultralytics` package via `pip install --upgrade ultralytics`
|
|
147
|
+
- Downloads the latest YOLO model files from the latest [ultralytics/assets](https://github.com/ultralytics/assets) release
|
|
148
|
+
- Skips models that already exist locally (use `--package-only` or `--models-only` to update just one component)
|
|
149
|
+
|
|
150
|
+
## Building and publishing
|
|
151
|
+
|
|
152
|
+
To build distributable artifacts locally:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
python -m pip install build
|
|
156
|
+
python -m build
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This creates a source distribution and wheel in `dist/`. After configuring
|
|
160
|
+
your PyPI credentials, upload them with:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
python -m pip install twine
|
|
164
|
+
python -m twine upload dist/*
|
|
165
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE.txt
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
bird_crop.egg-info/PKG-INFO
|
|
5
|
+
bird_crop.egg-info/SOURCES.txt
|
|
6
|
+
bird_crop.egg-info/dependency_links.txt
|
|
7
|
+
bird_crop.egg-info/entry_points.txt
|
|
8
|
+
bird_crop.egg-info/requires.txt
|
|
9
|
+
bird_crop.egg-info/top_level.txt
|
|
10
|
+
birdcrop/__init__.py
|
|
11
|
+
birdcrop/__main__.py
|
|
12
|
+
birdcrop/cli.py
|
|
13
|
+
birdcrop/cropper.py
|
|
14
|
+
birdcrop/exceptions.py
|
|
15
|
+
birdcrop/upgrade.py
|
|
16
|
+
birdcrop/utils.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
birdcrop
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# birdcrop/__init__.py
|
|
2
|
+
"""
|
|
3
|
+
BirdCrop Library: Detect and crop birds from images using YOLO models.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# Import key components to make them available directly from the package
|
|
7
|
+
from .cropper import BirdCropper
|
|
8
|
+
from .utils import find_image_files
|
|
9
|
+
from .exceptions import (
|
|
10
|
+
BirdCropError,
|
|
11
|
+
DirectoryCreationError,
|
|
12
|
+
FileWriteError,
|
|
13
|
+
ImageProcessingError,
|
|
14
|
+
ModelLoadError,
|
|
15
|
+
PredictionError,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.3"
|
|
19
|
+
__date__ = "2026-09-29"
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
'BirdCropper',
|
|
23
|
+
'find_image_files',
|
|
24
|
+
'BirdCropError',
|
|
25
|
+
'DirectoryCreationError',
|
|
26
|
+
'FileWriteError',
|
|
27
|
+
'ImageProcessingError',
|
|
28
|
+
'ModelLoadError',
|
|
29
|
+
'PredictionError',
|
|
30
|
+
'__version__',
|
|
31
|
+
'__date__',
|
|
32
|
+
]
|