Skip to main content

A learned prior over the optical glass manifold for realistic glass selection in lens design.

Project description

AbbeFlow Diagram

AbbeFlow

PyPI version CI PyTorch Python License: MIT Prior: Neural Spline Flow

AbbeFlow is a differentiable, normalizing-flow-based learned prior over the optical glass catalog manifold. Trained on approximately 1,700 real glasses from major manufacturers (including Schott, Ohara, Hoya, and others), AbbeFlow models the distribution of physical glasses in a 4D Buchdahl dispersion coefficient space. It enables continuous, gradient-based lens optimization while ensuring that glass choices remain on or near the realizable manifold.

For details on the mathematical modeling and formulation, see the Theoretical Background documentation.


Installation

Install AbbeFlow via pip:

pip install abbeflow

Core Optimization Paradigms

AbbeFlow supports two main paradigms for continuous glass optimization:

  1. Manifold Penalty Mode: Optimize refractive index $n_d$ and Abbe number $V_d$ directly, adding a regularizing penalty based on the negative log-probability under the learned prior to the optical merit function: $$\mathcal{L} = \mathcal{L}{\text{aberration}} - \lambda{\text{glass}} \log p(n_d, V_d)$$
  2. Latent Space Optimization: Optimize directly in the unconstrained 4D latent space $\mathbf{z} \in \mathbb{R}^4$, mapping back to the physical glass manifold via the decoder $\mathbf{x} = f^{-1}(\mathbf{z})$, which guarantees physically realistic glass parameters.

Quick Start

AbbeFlow provides a pretrained GlassFlow model ready for inference:

from abbeflow import GlassFlow

# Load the pretrained model
gf = GlassFlow.pretrained()

# Compute the log-probability of a glass (manifold prior penalty)
logp = gf.log_prob(nd=1.517, vd=64.2)
print(f"Log probability: {logp.item():.4f}")

# Encode to and decode from the latent space
z = gf.encode(nd=1.517, vd=64.2)
glass = gf.decode(z)
print(f"Decoded glass: nd={glass.nd:.4f}, vd={glass.vd:.2f}")

# Snap to the nearest real catalog glasses
matches = gf.nearest_real(nd=1.517, vd=64.2, k=3)
print("\nNearest catalog glasses:")
for match in matches:
    print(f" - {match.manufacturer} {match.name} (Distance: {match.distance:.4f})")

Examples

The following examples are located in the examples/ directory and demonstrate how to integrate AbbeFlow into various workflows:


API Reference

A detailed overview of all modules, classes, and methods is available in the API Reference documentation.


License

AbbeFlow is released under the MIT License.

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

abbeflow-0.2.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

abbeflow-0.2.0-py3-none-any.whl (293.6 kB view details)

Uploaded Python 3

File details

Details for the file abbeflow-0.2.0.tar.gz.

File metadata

  • Download URL: abbeflow-0.2.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for abbeflow-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f91968072691d3b877f81732de8713ed51f6ba2f910ebcd2b28e02c9535f6aff
MD5 f718bb394de78c2c717df8db1ea0a75b
BLAKE2b-256 b013b405d4d49d216bad4e65597514934fa0bc8c7da3580c17db6beb5e8777fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for abbeflow-0.2.0.tar.gz:

Publisher: publish.yml on HarrisonKramer/AbbeFlow

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

File details

Details for the file abbeflow-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: abbeflow-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 293.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for abbeflow-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce708da2d9dc134c0a962d5f9e80d6e13642bd02a0d8d5f118b60efdd7891318
MD5 bc6512e6b538e0fe9ec8a7f54674e545
BLAKE2b-256 4773386b305e7786573f51dd465cda13b9ba06fe846aa1ef7827cf94ae9f3413

See more details on using hashes here.

Provenance

The following attestation bundles were made for abbeflow-0.2.0-py3-none-any.whl:

Publisher: publish.yml on HarrisonKramer/AbbeFlow

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