Skip to main content

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

PyTorch Lightning

Ellipse R-CNN

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.

Sample FDDB predictions Sample crater predictions

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: Installs huggingface-hub and safetensors for 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:

Crater Prediction

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ellipse_rcnn-0.2.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ellipse_rcnn-0.2.1-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file ellipse_rcnn-0.2.1.tar.gz.

File metadata

  • Download URL: ellipse_rcnn-0.2.1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.20

File hashes

Hashes for ellipse_rcnn-0.2.1.tar.gz
Algorithm Hash digest
SHA256 47b854520fce148fb0b21fd5e39477162fc1981ef261ff59e76d4148fd90d884
MD5 190aafa00cbc3db7ef1878a63814f845
BLAKE2b-256 e435bdf01fdf14670f7d68d89eb99ed340f0081dc0fffc644cf301c94be4e921

See more details on using hashes here.

File details

Details for the file ellipse_rcnn-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ellipse_rcnn-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8dc473db4779a5ffcc88892259f9b0bb13f31fb67608f5c29d97bd0921261e11
MD5 f4d5c13cd6c77c73f9c29d2d1aa73a3f
BLAKE2b-256 b0bb86e793b12d16177ae1f541a5dac9941b33d1062299e89a99e0b8a7882f6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page