This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import numpy as np | |
class Intrinsics(object): | |
def __init__(self, json_file): | |
assert os.path.isfile(json_file), f'{json_file=} not found' | |
with open(json_file, 'r') as f: | |
intrinsics_data = json.load(f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kornia as kn | |
import kornia.geometry | |
import kornia.geometry.quaternion | |
def try_random(): | |
""" | |
- for two sets of poses A and B | |
- find the rotations between them, A->B = d1 | |
- find the standard deviation of the components of d rotation | |
- sample some random quaternions, C | |
- scale the the components according the standard deviation and re-normalize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hack to change model config from keras 2->3 compliant | |
import h5py | |
f = h5py.File(savedModelPath, mode="r+") | |
model_config_string = f.attrs.get("model_config") | |
if model_config_string.find('"groups": 1,') != -1: | |
model_config_string = model_config_string.replace('"groups": 1,', '') | |
f.attrs.modify('model_config', model_config_string) | |
f.flush() | |
model_config_string = f.attrs.get("model_config") | |
assert model_config_string.find('"groups": 1,') == -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pdf_extractor_env | |
channels: | |
- conda-forge | |
- defaults | |
dependencies: | |
- _libgcc_mutex=0.1=main | |
- _openmp_mutex=5.1=1_gnu | |
- blas=1.0=openblas | |
- bottleneck=1.3.5=py39h7deecbd_0 | |
- brotli=1.0.9=he6710b0_2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: instant_ngp_env | |
channels: | |
- nvidia | |
- conda-forge | |
- defaults | |
dependencies: | |
- _libgcc_mutex=0.1=main | |
- _openmp_mutex=4.5=1_gnu | |
- alsa-lib=1.2.3=h516909a_0 | |
- blas=1.0=mkl |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _get_unit_square_intercepts(self, slopes, intercept): | |
""" | |
returns unit square intercepts for given slope (a) and intercepts (b) | |
y = ax + b | |
solves: | |
right: y = a + b | |
x = 1 | |
y = slopes + intercept | |
left: y = b | |
x = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cf from https://arxiv.org/abs/1812.07035 | |
import tensorflow as tf | |
def rotation_matrix_to_label_6d_flat(rotation_matrices): | |
""" | |
takes batch x 3x3 rotation matrix, returns a flat batch x 6 floats for loss | |
:param rotation_matrices: batch x (3x3) rotation matrix | |
:return: flat batch x 6 floats for loss | |
""" | |
return tf.concat([rotation_matrices[:, :, 0], rotation_matrices[:, :, 1]], axis=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import tensorflow as tf | |
from sklearn.manifold import TSNE | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
def explore_embedding_size(number_of_categories, embedding_sizes): | |
fig = plt.figure(figsize=(15, 9)) | |
figure_title = f"Embedding size TSNEs for {number_of_categories} categories" |