Skip to content

Instantly share code, notes, and snippets.

Luca Antiga lantiga

Block or report user

Report or block lantiga

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lantiga
lantiga / export_trace.py
Last active May 25, 2020
🤗 Huggingface Bert on RedisAI
View export_trace.py
from transformers import BertForQuestionAnswering
import torch
bert_name = "bert-large-uncased-whole-word-masking-finetuned-squad"
model = BertForQuestionAnswering.from_pretrained(bert_name, torchscript=True)
model.eval()
inputs = [torch.ones(1, 2, dtype=torch.int64),
torch.ones(1, 2, dtype=torch.int64),
@lantiga
lantiga / export_trace.py
Last active May 6, 2020
Ultralytics YOLO v3 on RedisAI
View export_trace.py
# This script saves the ultralytics/yolov3 model to TorchScript
# so that it can be used in RedisAI (or from other C/C++ runtimes)
#
# git clone https://github.com/ultralytics/yolov3.git
# cd yolov3
# conda create -n pytorch python=3.7
# conda install -yc pytorch pytorch torchvision
# conda install -y numpy opencv
#
# Copy this script to the root of the repo (yolov3) and run
@lantiga
lantiga / build_redisai.sh
Last active May 5, 2020
Build RedisAI with PyTorch backend on NVIDIA Jetson
View build_redisai.sh
sudo apt update
sudo apt install -y git build-essential ninja-build cmake python3-pip python3-cffi redis unzip wget
git clone https://github.com/RedisAI/RedisAI.git
cd RedisAI
mkdir build
WITH_PT=0 WITH_TF=0 WITH_TFLITE=0 WITH_ORT=0 bash get_deps.sh
@lantiga
lantiga / cyclegan.py
Last active Feb 6, 2018
CycleGAN pretrained
View cyclegan.py
import torch
import torch.nn as nn
class ResnetBlock(nn.Module):
def __init__(self, dim):
super(ResnetBlock, self).__init__()
self.conv_block = self.build_conv_block(dim)
@lantiga
lantiga / README.md
Created Feb 6, 2018
Indexed convolution
View README.md

Indexed convolutions

A convolution operator over a 1D tensor (BxCxL), where a list of neighbors for each element is provided through a indices tensor (LxK), where K is the size of the convolution kernel. Each row of indices specifies the indices of the K neighbors of the corresponding element in the input. A -1 is handled like for zero padding.

Note that the neighbors specified in indices are not relative, but rather absolute. They have to be specified for each of the elements of the output.

A use case is for convolutions over non-square lattices, such as images on hexagonal lattices coming from Cherenkov telescopes (http://www.isdc.unige.ch/%7Elyard/FirstLight/FirstLight_slowHD.mov).

Example:

@lantiga
lantiga / tracing_blocks.py
Created Sep 11, 2017
PyTorch namespaces tests
View tracing_blocks.py
import torch
import torch.nn as nn
from torch.autograd import Variable
from graphviz import Digraph
def name(node, annotation=None):
kind = node.kind()
@lantiga
lantiga / vmtk.rb
Created Jun 10, 2017
Brew formula for vmtk 1.3.2
View vmtk.rb
class Vmtk < Formula
desc "The Vascular Modeling Toolkit"
homepage "http://www.vmtk.org"
url "https://github.com/vmtk/vmtk/archive/v1.3.2.tar.gz"
version "1.3.2"
sha256 "2632a74341605bd3ddd97971fad70941329e77a112f9363bc5053a1e2ba7c30e"
head "https://github.com/vmtk/vmtk.git"
revision 1
# bottle do
View gist:0e4ec0297a4c54bc0ec1
### Keybase proof
I hereby claim:
* I am lantiga on github.
* I am lantiga (https://keybase.io/lantiga) on keybase.
* I have a public key whose fingerprint is C364 40F7 E6D0 2B02 AF9C FC34 BE4B 71AA 57A8 4B6A
To claim this, I am signing this object:
@lantiga
lantiga / core.clj
Last active Aug 29, 2015
Naive pure rule engine
View core.clj
(ns carla.core
(:require [clojure.math.combinatorics :as combo]))
(defn- fact-matches? [fact match]
(= match (select-keys fact (keys match))))
(defn make-rules [] [])
(defn make-session [] {:facts #{}})
@lantiga
lantiga / state.ki.js
Last active Jul 21, 2019
State management in ki (http://ki-lang.org)
View state.ki.js
ki macro (export $name $val)
(js exports.$name = $val)
ki require core
// Ported from https://github.com/clojure/clojurescript/blob/master/src/cljs/clojure/data.cljs
ki (ns diff
You can’t perform that action at this time.