An implementation of the Ellipse R-CNN object detection model in PyTorch, based on 'Ellipse R-CNN: Learning to Infer Elliptical Object from Clustering and Occlusion' by Dong et al.
Project description
A PyTorch (Lightning) implementation of Ellipse R-CNN. Extracted from another project. The methodology is based on Ellipse R-CNN: Learning to Infer Elliptical Object from Clustering and Occlusion, albeit with slight changes. Primarily this implementation was made to enable Crater detection from Moon orbiter sensors, but works with the Face Detection Dataset & Benchmark (FDDB) dataset as well.
Installation
pip install ellipse-rcnn
Optional extras
Enable a feature with the ellipse-rcnn[<FEATURE>, ...] pattern.
train: Installs all dependencies necessary to train this model.hf: Installshuggingface-hubandsafetensorsfor easy weights saving & loading through the Huggingface platform.
Quickstart
- Install with all extras through
pip install "ellipse-rcnn[hf,train]" - Select the weights you need from my Huggingface profile.
Run the following:
import torch
from ellipse_rcnn.hf import EllipseRCNN # This is the model with HF functionality included through PyTorchModelHubMixin
from PIL import Image
from torchvision.transforms.functional import to_tensor
from ellipse_rcnn.utils.viz import plot_single_pred
model = EllipseRCNN.from_pretrained("wdoppenberg/crater-rcnn") # For the crater detection model
model.eval()
png = Image.open("docs/example_craters.png").convert("L")
img = to_tensor(png)
with torch.no_grad():
pred = model([img])
plot_single_pred(img, pred)
This should output the following:
Training Setup
Make sure you have uv installed. This library's dependencies have mostly
been made optional to make it easy to import the base EllipseRCNN model. For training,
more dependencies, most importantly pytorch-lightning, are under the train group.
For a training setup, run the following from the project root:
uv sync --extra train
This sets up a new virtual environment and installs all packages into it.
Get info on either the training or sample (prediction) script using:
uv run scripts/train.py --help
# or
uv run scripts/sample.py --help
If you want to do experiment tracking, use tensorboard:
uvx tensorboard --logdir=lightning_logs
Data
Currently the training script only supports training with FDDB. See the required steps for getting & structuring the data below. More datasets can be supported if needed. If you want to download a dataset directly, use the following script:
uv run scripts/download.py <DATASET_NAME> [Optional: --root <ROOT_FOLDER>]
FDDB Data
The Face Detection Dataset & Benchmark (FDDB) module contains the Dataset subclass that does all the data loading and
transformations. It will download and unpack the necessary files to ./data/FDDB. Simply running the training
script will download the necessary files.
Craters Data
Unfortunately, the dataset used to create a Crater Detector is not releasable. To generate it, check out this module, and ensure you have a license to run SurRender.
Citations
If you use this code in your work, please consider citing the original paper and this repository. For this repository, you can use the following BibTex entry:
@misc{EllipseRCNNPyTorch2025,
author = {Doppenberg, Wouter},
title = {Ellipse {R-CNN}: {PyTorch} {Implementation}},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/wdoppenberg/ellipse_rcnn}},
note = {An implementation of the Ellipse R-CNN object detection model in PyTorch, based on "Ellipse R-CNN: Learning to Infer Elliptical Object from Clustering and Occlusion" by Dong et al.}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ellipse_rcnn-0.2.2.tar.gz.
File metadata
- Download URL: ellipse_rcnn-0.2.2.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6734f9bb1fcbcbba14292db3eb39b499f82ff8d8a1d1849eb2cc39839525351c
|
|
| MD5 |
5881cf07a828f867f152d266267d2c34
|
|
| BLAKE2b-256 |
59411df31419cf83b2f147ed6e36f92b07c99551e4e68ba55df0a9e834089a11
|
File details
Details for the file ellipse_rcnn-0.2.2-py3-none-any.whl.
File metadata
- Download URL: ellipse_rcnn-0.2.2-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa645c494ff212a0005f54a63ee0e1d19aafca9cc2b01bb2a287ac4b3e5c1b6d
|
|
| MD5 |
462fb242caf56ebe008a9e820e3f07f5
|
|
| BLAKE2b-256 |
ac835574bbc93cb2f0a2543b20ec526735a8e2d844f0d2f2d4832601f53bb68e
|