GithubHelp home page GithubHelp logo

ozzie00 / itorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookarchive/itorch

0.0 3.0 0.0 7.44 MB

IPython kernel for Torch with visualization and plotting

License: Other

Lua 96.25% CSS 0.89% JavaScript 1.56% Shell 1.30%

itorch's Introduction

iTorch

iTorch is an IPython Kernel for Torch, with plotting (using Bokeh.js plots) and visualization of images, video and audio

Features

iTorch in notebook mode works like any other IPython notebook.
It provides useful inline auto-complete. Whenever you need auto-complete, use the TAB key.
screenshot

It also provides inline help using the ? symbol. For example, ?torch.cmul screenshot

In addition, we introduce visualization functions for images, video, audio, html and plots.

itorch.image(img) - You can pass in a 3-D tensor (for a single image), or a table of 3D tensors (image collages).

  itorch.image({image.lena(), image.lena(), image.lena()})

screenshot

itorch.audio(path) - You can pass in a filename of an audio file. Formats supported are mp3, ogg, aac

itorch.audio('example.mp3')

screenshot

itorch.video(path) - You can pass in a filename of a video file. Formats supported are mp4, ogv, mpeg

itorch.video('example.mp4')

screenshot

[window-id] = itorch.html(htmlstring, [window-id]) - Raw HTML string that is passed is rendered. A window handle is returned, that can be reused to replace the HTML with something else.

itorch.html('<p><b>Hi there!</b> this is arbitrary HTML</p>')
window_id = itorch.html('<p>This text will be replaced in 2 seconds</p>')
os.execute('sleep 2')
itorch.html('<p>magic!</p>', window_id)

screenshot

###Plotting iTorch can plot to screen in notebook mode, or save the plot to disk as a html file.

A Plot object is introduced, that can plot different kinds of plots such as scatter, line, segment, quiver plots.

Plot = require 'itorch.Plot'

The plotting can be extended to more kinds of plots, as it uses Bokeh.js as its backend.

x1 = torch.randn(40):mul(100)
y1 = torch.randn(40):mul(100)
x2 = torch.randn(40):mul(100)
y2 = torch.randn(40):mul(100)
x3 = torch.randn(40):mul(200)
y3 = torch.randn(40):mul(200)


-- scatter plots
plot = Plot():circle(x1, y1, 'red', 'hi'):circle(x2, y2, 'blue', 'bye'):draw()
plot:circle(x3,y3,'green', 'yolo'):redraw()
plot:title('Scatter Plot Demo'):redraw()
plot:xaxis('length'):yaxis('width'):redraw()
plot:legend(true)
plot:redraw()
-- print(plot:toHTML())
plot:save('out.html')

screenshot

-- line plots
plot = Plot():line(x1, y1,'red','example'):legend(true):title('Line Plot Demo'):draw()
-- segment plots
plot = Plot():segment(x1, y1, x1+10,y1+10, 'red','demo'):title('Segment Plot Demo'):draw()
-- quiver plots
U = torch.randn(3,3):mul(100)
V = torch.randn(3,3):mul(100)
plot = Plot():quiver(U,V,'red',''):title('Quiver Plot Demo'):draw()

screenshot

Requirements

iTorch requires or works with

  • Mac OS X or Linux (tested in Ubuntu 14.04)
  • Torch-7
  • IPython version 2.2 or above (you can check your version of ipython using ipython --version)
  • ZeroMQ
# OSX
brew install zeromq

# Ubuntu
sudo apt-get install libzmq3-dev

Installing iTorch

git clone https://github.com/facebook/iTorch.git
cd iTorch
luarocks make 

If you have to use sudo for some reason (if you globally installed torch on Linux for example), use these commands:

sudo env "PATH=$PATH" luarocks make
sudo chown -R $USER $(dirname $(ipython locate profile))

How iTorch works

Start iTorch at command-line using the following command:

itorch notebook  # notebook mode
OR  
itorch  # console mode
OR  
itorch qtconsole  # Qt mode

Examples

Demo iTorch notebook: http://nbviewer.ipython.org/github/facebook/iTorch/blob/master/iTorch_Demo.ipynb

Join the Torch community

See the CONTRIBUTING file for how to help out.

License

iTorch is BSD-licensed. We also provide an additional patent grant.

itorch's People

Contributors

ajtulloch avatar bdurette avatar carreau avatar soumith avatar szagoruyko avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.