Skip to content

Instantly share code, notes, and snippets.

var torchjs = require('@idn/torchjs');
var script_module = new torchjs.ScriptModule('resnet18.pt');
var tensor = torchjs.ones([1, 3, 224, 224], false);
const { performance } = require('perf_hooks');
// Comment this out if you don't have cuda
script_module.cuda();
let start, end;
start = performance.now();
import torch
import torchvision
# An instance of your model.
model = torchvision.models.resnet18(pretrained=True)
# An example input you would normally provide to your model's forward() method.
example = torch.rand(1, 3, 224, 224)
# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
overlayed_model = OverlayNet(model)
reduced_model = overlayed_model.generate(p=0.5)
const model = new ModelDescriptor({
modelId: 'QmZ9db8JzNCNrKuYyFN4Sv3a4Rn9CgZM99owJXwFjUhCik',
modelPath: 'https://cloudflare-ipfs.com/ipfs/QmZ9db8JzNCNrKuYyFN4Sv3a4Rn9CgZM99owJXwFjUhCik', // resnet18 pytorch model
modelType: 'torchjs/cuda'
});
await node.initModel(model)
node.inferModel(model, inputs).on('response', (outputs, confidences, finish) => {
// Do something with the outputs, confidences
// call finish() to finish the computation if outputs are already highly confidence
});
0x66ed62338f125dfdf84c2d0b4ed69ea37283f2ea
0x33bffb3b5a3c445789e92ff072c9821595df3872
0xF66b365bEeDF4a96A011Bd47205091e783437565
@steerapi
steerapi / siteconf.py
Created March 13, 2015 21:19
pycuda siteconf.py Mac OS X 10.10
BOOST_INC_DIR = []
BOOST_LIB_DIR = []
BOOST_COMPILER = 'gcc43'
USE_SHIPPED_BOOST = True
BOOST_PYTHON_LIBNAME = ['boost_python-py27']
BOOST_THREAD_LIBNAME = ['boost_thread']
CUDA_TRACE = False
CUDA_ROOT = '/usr/local/cuda'
CUDA_ENABLE_GL = False
CUDA_ENABLE_CURAND = True
/*
Usage:
document.addEventListener("swipe", function(ev){
console.log("swipe: "+JSON.stringify(ev));
});
*/
(function() {
var CURRENT_TOUCH, EVENT, FIRST_TOUCH, GESTURE, HOLD_DELAY, TAPS, TOUCH_TIMEOUT, _angle, _capturePinch, _captureRotation, _cleanGesture, _distance, _fingersPosition, _getTouches, _hold, _isSwipe, _listenTouches, _onTouchEnd, _onTouchMove, _onTouchStart, _swipeDirection, _trigger;
TAPS = null;
@steerapi
steerapi / matlab.tex
Created December 6, 2012 01:24 — forked from eyliu/matlab.tex
LaTeX settings for MATLAB code listings
% LaTeX settings for MATLAB code listings
% based on Ted Pavlic's settings in http://links.tedpavlic.com/ascii/homework_new_tex.ascii
\usepackage{listings}
\usepackage[usenames,dvipsnames]{color}
% This is the color used for MATLAB comments below
\definecolor{MyDarkGreen}{rgb}{0.0,0.4,0.0}
% For faster processing, load Matlab syntax for listings
\lstloadlanguages{Matlab}%