Skip to content

Commit 491b794

Browse files
committed
removing gfx from getstarted
1 parent f486e98 commit 491b794

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

1_getstarted/getstarted.lua

+19-32
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,9 @@
44
-- This script demonstrates very basic Lua/Torch stuff.
55

66
-- To run this script, simply do:
7-
-- torch getstarted.lua
8-
-- and then press 'y' or 'return' at each step, to keep going, or 'n'
9-
-- to terminate.
10-
11-
require 'gfx.js'
12-
13-
----------------------------------------------------------------------
14-
-- little function to pause execution, and request user input
15-
function next()
16-
local answer = nil
17-
while answer ~= '' and answer ~= 'y' and answer ~= 'Y' and neverstall ~= true do
18-
io.write("continue ([y]/n/!)? ")
19-
io.flush()
20-
answer=io.read()
21-
if answer == '!' then
22-
neverstall = true
23-
end
24-
if answer == 'n' then
25-
print('exiting...')
26-
os.exit()
27-
end
28-
end
29-
print ''
30-
end
7+
-- th getstarted.lua
8+
-- To run the script from itorch, in a notebook do:
9+
-- dofile 'getstarted.lua'
3110

3211
----------------------------------------------------------------------
3312
-- snippet 1
@@ -37,24 +16,32 @@ print(a)
3716
print 'something'
3817
print(type(a))
3918
print(type('something'))
40-
next()
4119

4220
----------------------------------------------------------------------
43-
-- snippet 3
21+
-- snippet 2
4422
require 'image'
4523
i = image.lena()
46-
gfx.image(i)
47-
next()
24+
if itorch then
25+
itorch.image(i)
26+
else
27+
print('skipping visualization because the script is not run from itorch')
28+
end
4829

4930
----------------------------------------------------------------------
5031
-- snippet 4
5132
require 'nn'
5233
n = nn.SpatialConvolution(1,16,12,12)
53-
gfx.image(n.weight, {zoom=2, legend=''})
54-
next()
34+
if itorch then
35+
itorch.image(n.weight)
36+
else
37+
print('skipping visualization because the script is not run from itorch')
38+
end
5539

5640
----------------------------------------------------------------------
5741
-- snippet 5
5842
res = n:forward(image.rgb2y(i))
59-
gfx.image(res, {zoom=0.25, legend='states'})
60-
next()
43+
if itorch then
44+
itorch.image(res)
45+
else
46+
print('skipping visualization because the script is not run from itorch')
47+
end

0 commit comments

Comments
 (0)