Introduction

from PIL import Image
from matplotlib import pyplot as plt
from utils import working_directory, interactive_plot, get_errors_index
with working_directory('..'):
    from polar import load_sample_data, POLAR

kaleido is only required to save Plotly figures as jpeg image, so that they can be displayed in the web documentation.
It is not required when running this notebook.

%pip install -U kaleido
Requirement already satisfied: kaleido in /data/mambaforge/envs/geom/lib/python3.8/site-packages (0.2.1)

views, degradations, R_abs_gt = load_sample_data('outliers')
model = POLAR(**degradations)
model.fit(views.cuda())
:: Initializing model ...
    - Using device: cuda.
Cached SO(3) Lookup Table not found. It will be created on the fly and saved for later use. This will occur extra runtime.
    - Running coarse exhaustive search ...
LOOP 1
:: Running 100 parallel joint optimizations ...
:: Computing restart angles ...
:: Running 400 parallel multistart optimizations ...
Multistart improved 16 objects:
tensor([12, 19, 21, 27, 29, 32, 35, 42, 46, 56, 70, 75, 76, 86, 94, 95])
--------------------------------------------------------------------------------
LOOP 2
:: Running 100 parallel joint optimizations ...
:: Computing restart angles ...
:: Running 400 parallel multistart optimizations ...
Multistart improved 1 objects:
tensor([48])
--------------------------------------------------------------------------------
LOOP 3
:: Running 100 parallel joint optimizations ...
:: Computing restart angles ...
:: Running 400 parallel multistart optimizations ...
Multistart improved 1 objects:
tensor([48])
Multistart improved same objects twice in a row.
Reducing lr to 0.001.
--------------------------------------------------------------------------------
LOOP 4
:: Running 100 parallel joint optimizations ...
:: Computing restart angles ...
:: Running 400 parallel multistart optimizations ...
Multistart improved 1 objects:
tensor([37])
--------------------------------------------------------------------------------
LOOP 5
:: Running 100 parallel joint optimizations ...
:: Computing restart angles ...
:: Running 400 parallel multistart optimizations ...
Multistart converged.
:: Running 100 parallel joint optimizations ...

get_errors_index(model.get_matrix(rotation_only=True), R_abs_gt)
tensor([89])
loss = model.get_mean_losses(multistart=True)
plt.plot(loss); plt.show()
No description has been provided for this image

This is just to display the Plotly figure as an image in the web documentation.
If you are running this notebook, just call interactive_plot(model.template.detach())

fig = interactive_plot(model.template.detach(), return_fig=True)
fig.show()
fig.write_image("template.jpeg")
Image.open('./template.jpeg')
No description has been provided for this image