Skip to content

Instantly share code, notes, and snippets.

View peteflorence's full-sized avatar

Pete Florence peteflorence

View GitHub Profile
@peteflorence
peteflorence / test_fk_urdf_difference.py
Created October 3, 2024 17:48
Flexiv Rizon4 URDF discrepancy of 4 centimeters
import time
import numpy as np
import pybullet as pb
np.random.seed(42)
rest_pose = np.random.randn(7)
def run_forward_kinematics(robot_id):
@peteflorence
peteflorence / gist:6fa27d5030082228bb6ff0162932cca3
Created October 3, 2024 17:47
Flexiv URDF change of 4 centimeters
import time
import numpy as np
import pybullet as pb
np.random.seed(42)
rest_pose = np.random.randn(7)
def run_forward_kinematics(robot_id):
@peteflorence
peteflorence / gist:4b6e15aeb419c727fc0d39ca47eb96fc
Created January 24, 2019 20:04
current spartan build error
[ 60%] Built target python_byte_compile
[ 60%] Building CXX object src/vtk/DRCFilters/CMakeFiles/vtkDRCFilters.dir/vtkFrameWidgetRepresentation.cxx.o
In file included from /home/peteflo/spartan/build/director/src/PointCloudLibraryPlugin/Filters/vtkPCLSACSegmentationCylinder.cxx:31:0:
/home/peteflo/spartan/build/install/include/pcl-1.8/pcl/sample_consensus/model_types.h: In function 'void __static_initialization_and_destruction_0(int, int)':
/home/peteflo/spartan/build/install/include/pcl-1.8/pcl/sample_consensus/model_types.h:99:3: warning: 'pcl::SAC_SAMPLE_SIZE' is deprecated: This map is deprecated and is kept only to prevent breaking existing user code. Starting from PCL 1.8.0 model sample size is a protected member of the SampleConsensusModel class [-Wdeprecated-declarations]
SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel));
^
/home/peteflo/spartan/build/install/include/pcl-1.8/pcl/sample_consensus/model_types.h:99:3: note: declared here
@peteflorence
peteflorence / pixelwise_contrastive_loss.py
Last active August 11, 2022 09:15
Pixelwise Contrastive Loss in PyTorch
import torch
class PixelwiseContrastiveLoss(torch.nn.Module):
def __init__(self):
super(PixelwiseContrastiveLoss, self).__init__()
self.num_non_matches_per_match = 150
def forward(self, image_a_pred, image_b_pred, matches_a, matches_b, non_matches_a, non_matches_b):
loss = 0
@peteflorence
peteflorence / pytorch-finding-correspondences.ipynb
Last active May 23, 2020 20:37
pytorch_finding_correspondences
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@peteflorence
peteflorence / pytorch_bilinear_interpolation.md
Last active June 30, 2024 01:26
Bilinear interpolation in PyTorch, and benchmarking vs. numpy

Here's a simple implementation of bilinear interpolation on tensors using PyTorch.

I wrote this up since I ended up learning a lot about options for interpolation in both the numpy and PyTorch ecosystems. More generally than just interpolation, too, it's also a nice case study in how PyTorch magically can put very numpy-like code on the GPU (and by the way, do autodiff for you too).

For interpolation in PyTorch, this open issue calls for more interpolation features. There is now a nn.functional.grid_sample() feature but at least at first this didn't look like what I needed (but we'll come back to this later).

In particular I wanted to take an image, W x H x C, and sample it many times at different random locations. Note also that this is different than upsampling which exhaustively samples and also doesn't give us fle

startIndex: 0, endIndex: 2
quick 0 8 16 24 32 40 48 56 64
index # # # # # # # #
BEFORE
startWord: 10111100
endWord: 00010101
AFTER
startWord: 10101000
endWord: 00111101
AFTER RE-ADDING STARTSAVE AND ENDSAVE
startIndex: 0, endIndex: 18
quick 0 8 16 24 32 40 48 56 64
index # # # # # # # #
BEFORE
startWord: 0011101011110100101010010001110111111111111111111111111111111111
endWord: 1001000110110110111100001000100000000000000000000000000000000000
AFTER
startWord: 0000000000000000000000000000000000010001000011110110110110001001
endWord: 1111111111111111111111111111111110111000100101010010111101011100
AFTER RE-ADDING STARTSAVE AND ENDSAVE
startIndex: 0, endIndex: 18
BEFORE
startWord: 0011101011110100101010010001110111111111111111111111111111111111
endWord: 1001000110110110111100001000100000000000000000000000000000000000
AFTER
startWord: 0000000000000000000000000000000000010001000011110110110110001001
endWord: 1111111111111111111111111111111110111000100101010010111101011100
AFTER RE-ADDING STARTSAVE AND ENDSAVE
startWord: 0011101011110100101010010001110100000000000000000000000000000000
endWord: 0000000000000000000100001000100000000000000000000000000000000000
BEFORE
startWord: 1111111111110101101010010001110100000000000000000000000000000000
endWord: 0000000000000000000000000000000000000000000000000000000000000000
AFTER
startWord: 0000000000000000000000000000000000000000000000000000000000000000
endWord: 0000000000000000000000000000000010111000100101011010111111111111
BEFORE
startWord: 1111111111110101101010010001110100000000000000000000000000000000
endWord: 1111001100100011100100100000000000000000000000000000000000000000