Skip to content

Instantly share code, notes, and snippets.

View etienne87's full-sized avatar
🐶
Working from home

etienne87

🐶
Working from home
View GitHub Profile
@etienne87
etienne87 / conv_rnn_modules.py
Last active June 14, 2019 15:29
conv_rnn_modules.py
# pylint: disable-all
import torch.nn as nn
from torch.nn import functional as F
import torch
def time_to_batch(x):
t, n = x.size()[:2]
x = x.view(n * t, *x.size()[2:])
return x, n
@etienne87
etienne87 / image_stitching.py
Last active June 23, 2019 10:17
image stitching experiment
from __future__ import print_function
import numpy as np
import imutils
import cv2
"""
Homecooked RANSAC, we will see if we manage to replace cv2.findHomography(..., cv2.RANSAC)
"""
def ransac(data, model, n, k, t, d):
bestfit = None
@etienne87
etienne87 / draw_mickey.py
Created June 29, 2019 20:33
trying to draw mickey using binary cross entropy
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import matplotlib.pyplot as plt
import numpy as np
import random
def bce_loss_with_logits(x, y):
@etienne87
etienne87 / viz_ts.py
Created July 4, 2019 07:52
viz_ts.py
from __future__ import print_function
import time
import numpy as np
import cv2
from prophesee_utils.td_video import ChronoVideo
if __name__ == '__main__':
delay = 1
base_delay = 1
stop = False
@etienne87
etienne87 / world_to_camera_and_back.py
Last active August 1, 2019 09:04
world_to_camera_and_back
#!/usr/bin/python
from __future__ import print_function
"""
* World To Camera & Back (projective equations of pinhole cameras) *
* -------------------- *
* The OpenCV reference frame: *
* (or sometimes called "Camera Reference Frame"): *
* Z points towards the direction of forward motion of the camera *
* X points right wrt Y *
@etienne87
etienne87 / full_plastic_batched.py
Created November 24, 2019 12:45
differentiable_plasticity_uber
# Differentiable plasticity: binary pattern memorization and reconstruction
#
# Copyright (c) 2018 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@etienne87
etienne87 / siren.py
Last active June 24, 2020 17:44
very scruffy script to show case siren networks
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.autograd import Variable
from ranger import Ranger
import numpy as np
import random
import cv2
"""
Local Convolutions in pytorch
"""
import torch
import torch.nn.functional as F
b,c,h,w = 2,3,32,32
d = 3
n = h*w
@etienne87
etienne87 / cuda_binary_dilate_3d.py
Created December 31, 2021 09:11
binary dilation in numba cuda
"""
binary dilation in numba cuda
>> python cuda_binary_dilate_3d.py 512 512 512 1
>>> runtime: 0.001s on a Nvidia TitanXP.
"""
import numba
import numpy as np
import time
from numba import cuda
@etienne87
etienne87 / spatial_transform.py
Last active January 16, 2022 09:37
understanding spatial transform in pytorch (simulate 2 vessels)
import matplotlib.pyplot as plt
plt.switch_backend('tkagg')
import torch as th
import torch.nn.functional as F
import numpy as np
import cv2
from scipy.spatial.transform import Rotation