arunpatala / captcha.irctc Goto Github PK
View Code? Open in Web Editor NEWReading irctc captchas with 98% accuracy using deep learning
Reading irctc captchas with 98% accuracy using deep learning
When i run main.lua it gives following error
parsing file: data/ans.txt
parsing done
/Users/jithin/torch/install/bin/luajit: /Users/jithin/.luarocks/share/lua/5.1/torch/Tensor.lua:238: attempt to index a nil value
stack traceback:
/Users/jithin/.luarocks/share/lua/5.1/torch/Tensor.lua:238: in function 'type'
/Users/jithin/.luarocks/share/lua/5.1/nn/utils.lua:52: in function 'recursiveType'
/Users/jithin/.luarocks/share/lua/5.1/nn/Module.lua:126: in function 'cuda'
main.lua:8: in main chunk
[C]: in function 'dofile'
...thin/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x0107385bd0
hi,
I would like to know if the way of calculate accuracy need to change as I change the dataset. For example, I have 9 classes for my captcha (the length of captcha is 9 instead of 5). so in the accuracy calculation.
function train.accuracy(Xv,Yv,net,batch)
net:evaluate()
local batch = batch or 64
local Nv = Xv:size(1)
local lloss = 0
for i =1,Nv,batch do
local j = math.min(i+batch-1,Nv)
local Xb = Xv[{{i,j}}]:cuda()
local Yb = Yv[{{i,j}}]:cuda()
local out = net:forward(Xb) -- NkC
local tmp,YYb = out:max(3)
lloss = lloss + YYb:eq(Yb):sum()
end
return (100lloss/(5Nv))
end
is this line
return (100lloss/(5Nv)) need to change to return (100lloss/(9Nv))? also, what is the out:max(3) means is it a parameter need to change to adapt the dataset?.
also, is train.accuracyK calculate the accuracy if all characters are predicted correctly?
if anyone have some idea of this issue, I would be really appreciate it. thanks.
Hi,
I have no idea about how to use the trained model to predict new captcha.
Hope someone can help me get started and point me in the right direction.
Many thanks in advance.
getPixelMapFromId = function(img) {
var canvas;
if(!canvas) {
canvas = document.createElement('canvas');
canvas.width = 170;
canvas.height = 50;
canvas.getContext('2d').drawImage(img, 0, 0, 170, 50);
}
var pixelMap = [];
for (var i = 0; i < 50; i++) {
var temp = [];
for (var k = 0; k < 170; k++) {
temp.push(Boolean(canvas.getContext('2d').getImageData(k, i, 1, 1).data[3]) ? 1 : 0);
};
pixelMap.push(temp);
};
return pixelMap;
};
would it be possible to release docker container where everything is setup?
that would be much more easier to pickup and understand your work
I have installed torch, as well as cutorch
, csvigo
. Then I opened terminal to execute th ./main.lua
but encountered the following error:
<csv> parsing file: data/ans.txt
<csv> parsing done
/home/cwang/torch/install/bin/luajit: /home/cwang/torch/install/share/lua/5.1/torch/Tensor.lua:238: attempt to index a nil value
stack traceback:
/home/cwang/torch/install/share/lua/5.1/torch/Tensor.lua:238: in function 'type'
/home/cwang/torch/install/share/lua/5.1/nn/utils.lua:52: in function 'recursiveType'
/home/cwang/torch/install/share/lua/5.1/nn/Module.lua:126: in function 'cuda'
./main.lua:8: in main chunk
[C]: in function 'dofile'
...wang/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00406670
I am using Ubuntu 14.04.
Could anyone give any hint about where the error is?
Hi i am using UBUNTU 14.04 LTS
Memory 8 GB
Processor Intel® Core™ i3
No GPU
i have got following error:
parsing file: data/ans.txt
parsing done
parameters size ..
17961588
[torch.LongStorage of size 1]
1 950
321 950
641 950
loss..212.63523946483
./train.lua:17: invalid arguments: LongTensor DoubleTensor
expected arguments: [ByteTensor] LongTensor long | LongTensor LongTensor long | [ByteTensor] LongTensor LongTensor | LongTensor LongTensor LongTensor
stack traceback:
[C]: in function 'eq'
./train.lua:17: in function 'accuracy'
./train.lua:70: in function 'f'
[string "local f = function() return train.sgd(net,ct,..."]:1: in main chunk
[C]: in function 'xpcall'
/home/alina/torch/install/share/lua/5.1/itorch/main.lua:209: in function </home/alina/torch/install/share/lua/5.1/itorch/main.lua:173>
/home/alina/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll'
...e/alina/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
...e/alina/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
...e/alina/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
/home/alina/torch/install/share/lua/5.1/itorch/main.lua:381: in main chunk
[C]: in function 'require'
(command line):1: in main chunk
[C]: at 0x00406670
I run main.lua after removing cuda calls in main.lua and train.lua, but failed.
Could you take a look at this?
Here is the log:
~/captcha.irctc$ th main.lua
parsing file: data/ans.txt
parsing done
parameters size ..
17961588
[torch.LongStorage of size 1]
1 50
loss..14.563473590949
/home/azureuser/torch/install/bin/luajit: ./train.lua:17: invalid arguments: LongTensor DoubleTensor
expected arguments: [ByteTensor] LongTensor long | LongTensor LongTensor long | [ByteTensor] LongTensor LongTensor | LongTensor LongTensor LongTensor
stack traceback:
[C]: in function 'eq'
./train.lua:17: in function 'accuracy'
./train.lua:70: in function 'sgd'
main.lua:16: in main chunk
[C]: in function 'dofile'
...user/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00406670
Thanks
What is MultiCrossEntropyCriterion in terms of other libraries?
Also this loss assumes that number of chars is constant across all samples?
I get this error now.
My configuration is
MacBook Pro (Retina, 15-inch, Mid 2014)
NVIDIA GeForce GT 750M 2048 MB
2.5 GHz Intel Core i7
16 GB 1600 MHz DDR3
Do I need a better GPU?
Or is it some other error?
➜ captcha.irctc git:(master) ✗ th mainr.lua
<csv> parsing file: data/ans.txt
<csv> parsing done
=> Creating model from file: models/resnet.lua
| ResNet-34 IRCTC
parameters size ..
1499124
[torch.LongStorage of size 1]
1 50
THCudaCheck FAIL file=/tmp/luarocks_cutorch-scm-1-4568/cutorch/lib/THC/generic/THCStorage.cu line=41 error=2 : out of memory
/Users/bob/torch/install/bin/luajit: /Users/bob/torch/install/share/lua/5.1/nn/Container.lua:67:
In 5 module of nn.Sequential:
In 2 module of nn.Sequential:
In 1 module of nn.Sequential:
In 1 module of nn.ConcatTable:
In 5 module of nn.Sequential:
...ed/torch/install/share/lua/5.1/nn/BatchNormalization.lua:134: cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-4568/cutorch/lib/THC/generic/THCStorage.cu:41
stack traceback:
[C]: in function 'resizeAs'
...ed/torch/install/share/lua/5.1/nn/BatchNormalization.lua:134: in function <...ed/torch/install/share/lua/5.1/nn/BatchNormalization.lua:125>
[C]: in function 'xpcall'
/Users/bob/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
/Users/bob/torch/install/share/lua/5.1/nn/Sequential.lua:84: in function </Users/bob/torch/install/share/lua/5.1/nn/Sequential.lua:78>
[C]: in function 'xpcall'
/Users/bob/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
...rs/bob/torch/install/share/lua/5.1/nn/ConcatTable.lua:66: in function <...rs/bob/torch/install/share/lua/5.1/nn/ConcatTable.lua:30>
[C]: in function 'xpcall'
/Users/bob/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
...
/Users/bob/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
/Users/bob/torch/install/share/lua/5.1/nn/Sequential.lua:84: in function </Users/bob/torch/install/share/lua/5.1/nn/Sequential.lua:78>
[C]: in function 'xpcall'
/Users/bob/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
/Users/bob/torch/install/share/lua/5.1/nn/Sequential.lua:84: in function 'backward'
./train.lua:60: in function 'sgd'
mainr.lua:16: in main chunk
[C]: in function 'dofile'
...hmed/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x010e612bd0
WARNING: If you see a stack trace below, it doesn't point to the place where this error occured. Please use only the one above.
stack traceback:
[C]: in function 'error'
/Users/bob/torch/install/share/lua/5.1/nn/Container.lua:67: in function 'rethrowErrors'
/Users/bob/torch/install/share/lua/5.1/nn/Sequential.lua:84: in function 'backward'
./train.lua:60: in function 'sgd'
mainr.lua:16: in main chunk
[C]: in function 'dofile'
...hmed/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x010e612bd0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.