Skip to main content

Fit splines to images and videos through differentiable rendering.

Project description

splender

arXiv PyPI

Fit splines to images and videos through differentiable rendering.

splender

Usage

Here is a basic example of trying to fit the number of 5 of the MNIST dataset.

import splender
import jax
from PIL import Image
import numpy as np

image = Image.open('img_5.png')
image = np.array(image, dtype=np.float32) / 255.0

init_splines = splender.knot_init.get_splines_from_frame(image)[0][:, ::-1]
init_splines = jax.numpy.array(init_splines, dtype=jax.numpy.float32)
init_knots = splender.knot_init.downsample_points(init_splines, 6)[None]

key = jax.random.key(42)
image = image[None]
init_knots = init_knots[None] / 28

model = splender.image.SplenderImage(key=key, init_knots=init_knots, res=28, global_scale=0.3)
model, _ = splender.optim.fit(model, image, video=False)
x_spline, y_spline, _ = model.fit_spline(model.loc_params[0, 0] + model.knot_params[0, 0])
s = jax.numpy.linspace(0, 1, 100) 
final_splines = jax.numpy.stack([x_spline(s), y_spline(s)], axis=-1)

resulting in

Some more elavorated example notebooks can be found under examples/

Installation

pip install splender

[!NOTE] If you want it to run on GPU, remember to install it alongside the correct jax version: pip install splender jax[cuda12]

Documentation

PENDING

For a more technical discussion on the model, please check out the paper

Citation

If you use splender in your research and need to reference it, please cite it as follows:

@article{zdyb2025splinerefinementdifferentiablerendering,
  title={Spline refinement with differentiable rendering},
  author={Frans Zdyb and Albert Alonso and Julius B. Kirkegaard},
  year={2025},
  eprint={2503.14525},
  archivePrefix={arXiv},
  primaryClass={eess.IV},
  url={https://arxiv.org/abs/2503.14525},
  journal={arXiv preprint arXiv:2503.14525},
}

License

Splender is licensed under the MIT License. See the LICENSE file for more details.

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

splender-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

splender-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file splender-0.1.0.tar.gz.

File metadata

  • Download URL: splender-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for splender-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aee3be4f5f96bcdbc6a34ac4679e5bc626edd2d245c66d10fb7ac97516723677
MD5 309a9296d6759cc03a8c3d61dd9bbe9b
BLAKE2b-256 b35fd7dd4ef6797af3600f63c15ace983ebd9ecefbde1c4e462d8d6379bc383d

See more details on using hashes here.

Provenance

The following attestation bundles were made for splender-0.1.0.tar.gz:

Publisher: publish.yml on kirkegaardlab/splender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file splender-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: splender-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for splender-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab59e1f44f3e45c20207596976d8a70c618d510d324638bbb065c363e8412bca
MD5 88d5802e84c57252a6f2947f2474ce69
BLAKE2b-256 7ae720e27edc528dcb27c29ca1410c09772f9614d94e660273fab06d6886da05

See more details on using hashes here.

Provenance

The following attestation bundles were made for splender-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kirkegaardlab/splender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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