Skip to content

Instantly share code, notes, and snippets.

require 'torch'
require 'nn'
require 'image'
local hdf5 = require 'hdf5'
local cmd = torch.CmdLine()
cmd:option('-image_list', '')
cmd:option('-model', '')
cmd:option('-layer', 30) -- Last ReLU for VGG-16
require 'nn'
print(nn.SpatialReflectionPadding)
local m = nn.SpatialReflectionPadding(2, 2, 2, 2)
print(m)
local x = torch.randn(2, 3, 4, 5)
local y = m:forward(x)
require 'torch'
local utils = require 'utils'
require 'DataLoader'
local cmd = torch.CmdLine()
cmd:option('-train_data_h5', 'data/vg-regions-720.h5', 'path to the h5file containing the preprocessed dataset')
cmd:option('-train_data_json', 'data/vg-regions-720-dicts.json', 'path to the json file containing additional info')
cmd:option('-use_split_indicator', 1)
require 'torch'
local utils = require 'utils'
require 'DataLoader'
local cmd = torch.CmdLine()
cmd:option('-train_data_h5', 'data/vg-regions-720.h5', 'path to the h5file containing the preprocessed dataset')
cmd:option('-train_data_json', 'data/vg-regions-720-dicts.json', 'path to the json file containing additional info')
cmd:option('-use_split_indicator', 1)
import argparse, os, glob, tempfile
import h5py
import numpy as np
import matplotlib.pyplot as plt
from scipy.misc import imread, imresize
# Stupid workaround for some messed up images
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
require 'torch'
require 'nn'
require 'cutorch'
require 'cunn'
require 'cudnn'
require 'optim'
require 'hdf5'
require 'image'
1 0.00348258706468
2 0.00497760079642
3 0.00846613545817
4 0.028898854011
5 0.0827517447657
6 0.17506234414
7 0.318862275449
8 0.478781827259
9 0.627372627373
10 0.752123938031
@jcjohnson
jcjohnson / fc_benchmark.lua
Last active April 20, 2016 11:09
Simple torch benchmarking tool for fully-connected networks
require 'nn'
require 'cutorch'
require 'cunn'
--[[
-- A simple benchmark comparing fully-connected net times on CPU and GPU.
--
-- Note that we don't count time it takes to transfer data to the GPU.
--]]
import argparse, random, os, time, json
from PIL import Image
from io import BytesIO
import base64
from flask import Flask, request
from flask.ext.cors import CORS
from flask_restful import Resource, Api
$(function() {
var SERVER_URL = null;
var video_active = false;
var demo_running = false;
var NUM_TO_SHOW = 20;
var IMAGE_DISPLAY_WIDTH = 800;
var BOX_LINE_WIDTH = 6;