Skip to content

Commit c8e7cc5

Browse files
add copilot instructions
1 parent ed85e9e commit c8e7cc5

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

AGENTS.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Project Overview
2+
3+
DeepForest is a Python library for object detection in aerial images, primarily trees, but also supporting models for livestock and other objects of interest. It uses pytorch throughout and the Lightning framework for model training, prediction and evaluation.
4+
5+
Imagery is of a relatively high resolution and is generally not satellite data.
6+
7+
## Setup and usage
8+
9+
- We use `uv` for package management
10+
- NEVER edit dependencies in pyproject.toml directly, ALWAYS use `uv add`
11+
- To set up, use `uv sync --all-extras --dev`. You can reference the CI workflow in .github
12+
- Use the `deepforest` command line interface with Hydra overrides for simple tests
13+
- When you've finished, run `uv run pre-commit` with appropriate arguments to run formatting and linters on your work.
14+
15+
## Folder Structure
16+
17+
- `/src`: Contains the source code for the DeepForest library
18+
- `/src/conf`: Contains configuration files in OmegaConf/Hydra format, and the schema.py
19+
- `/src/scripts`: Contains CLI interface(s) to DeepForest
20+
- `/tests`: Contains the unit tests; we use pytest
21+
- `/docs`: Contains documentation for the project, build using Sphinx and hosted on readthedocs.
22+
23+
## Libraries
24+
25+
- torch, torchvision, torchmetrics, transformers, pandas, numpy, scipy
26+
- pytorch lightning
27+
- visualization using matplotlib and supervision
28+
29+
## Data formats
30+
31+
- Annotations are usually provided in CSV with Pascal VOC convention for bounding box coordinates. For example:
32+
33+
```
34+
image_path,xmin,ymin,xmax,ymax,label
35+
OSBS_029.tif,203,67,227,90,Tree
36+
OSBS_029.tif,256,99,288,140,Tree
37+
OSBS_029.tif,166,253,225,304,Tree
38+
```
39+
40+
- Other input types are possible using utilities.read_file
41+
- Example CSV and shapefile inputs are in `/src/data`
42+
43+
## Configuration
44+
45+
- Use the configuration system to specify user-facing parameters instead of hardcoding/magic numbers in code
46+
- Make sure the schema is up to date with the config files
47+
48+
## Coding standards
49+
50+
- Simple and maintainable
51+
- Write docstrings and use type annotation
52+
- Limited comments, highlighting important details
53+
- Keep documentation in sync with code changes
54+
- We use ruff for linting with options set in pyproject.toml
55+
- Enforced by .pre-commit.yaml
56+
- Take advantage of implicit vectorization using pandas, numpy, etc. Avoid explicit loops if you can.

tests/AGENTS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Testing
2+
3+
- Tests will be run via pytest
4+
- Keep tests short and focused, with a clear contract
5+
- You can find data for testing in src/deepforest/data. Prefer to use existing files with utilities.get_data over generating data at test time.
6+
- Do not use print statements in tests, document failure with assertions
7+
- Use fixtures for repeated code sections, with appropriate scoping
8+
- Run models instead of mocking them. Use existing fixtures if suitable and set config options to be more efficient if necessary (such as fast_dev_run, low numbers of epochs)
9+
- Tests should check for behaviour, not duplicate logic from the library
10+
- Avoid excessive testing for initialization
11+
12+
## Running tests
13+
14+
- From the root folder, `uv run pytest tests`
15+
- Useful flags include `-s` to show output, `-x` to fail on first error and `--ff` to run failed tests first.

0 commit comments

Comments
 (0)