farrajota / fastrcnn-example-torch

Example code on how to use the fastrcnn package for torch7
MIT License
3 stars 1 forks source link

The fastrcnn package train #2

Closed geekvc closed 7 years ago

geekvc commented 7 years ago

I follow the fastrcnn package installation and dataset setup, when I try to train the network, error occured as follows

$ th train.lua
==> (1/5) Load options
==> (2/5) Load dataset data loader
==> (3/5) Load roi proposals data
==> (4/5) Setup model:
==> (5/5) Train Fast-RCNN model
/home/wangty/torch/install/bin/luajit: /mnt/geekvc/fastrcnn-example-torch/data.lua:13: attempt to index local 'dbc' (a boolean value)
stack traceback:
        /mnt/geekvc/fastrcnn-example-torch/data.lua:13: in function 'get_db_loader'
        /mnt/geekvc/fastrcnn-example-torch/data.lua:34: in function 'fetch_loader_dataset'
        /mnt/geekvc/fastrcnn-example-torch/data.lua:298: in function 'data_gen'
        /home/wangty/torch/install/share/lua/5.1/fastrcnn/train.lua:47: in function 'train'
        train.lua:66: in main chunk
        [C]: in function 'dofile'
        ...ngty/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
        [C]: at 0x00406620

I tested in the torch TREPL about this command

th> dbc = require 'dbcollection.manager'
                                                                      [0.0000s]
th> dbc
true
th> dbc = require 'dbcollection'
th> dbc.load{name='pascal_voc_2007',task='detection_d'}
...gty/torch/install/share/lua/5.1/dbcollection/manager.lua:141: attempt to index global 'manager' (a nil value)
stack traceback:
        ...gty/torch/install/share/lua/5.1/dbcollection/manager.lua:141: in function 'load'
        [string "_RESULT={dbc.load{name='pascal_voc_2007',task..."]:1: in main chunk
        [C]: in function 'xpcall'
        /home/wangty/torch/install/share/lua/5.1/trepl/init.lua:661: in function 'repl'
        ...ngty/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:204: in main chunk
        [C]: at 0x00406620
farrajota commented 7 years ago

I've commit a fix for this issue. It turns out I've forgot to commit the new changes to the data loading file to GitHub.

It should be working now.

PS: You'll have to re-install the Lua/Torch7 API because the error was in there.

geekvc commented 7 years ago
$ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 3), reused 5 (delta 3), pack-reused 0
Unpacking objects: 100% (5/5), done.
From https://github.com/farrajota/dbcollection
   ce05565..e2f8bd6  master     -> origin/master
Updating ce05565..e2f8bd6
Fast-forward
 APIs/lua/manager.lua | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

$ git pull
remote: Counting objects: 4, done.
remote: Total 4 (delta 3), reused 4 (delta 3), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/farrajota/dbcollection
   e2f8bd6..6ee029c  master     -> origin/master
Updating e2f8bd6..6ee029c
Fast-forward
 dbcollection/cache.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
$ luarocks remove dbcollection

and re-install the dbcollection in the folder APIs/lua, the error still occured:

$ th train.lua
==> (1/5) Load options
==> (2/5) Load dataset data loader
==> (3/5) Load roi proposals data
==> (4/5) Setup model:
==> (5/5) Train Fast-RCNN model
/home/wangty/torch/install/bin/luajit: /mnt/geekvc/fastrcnn-example-torch/data.lua:13: attempt to index local 'dbc' (a boolean value)
stack traceback:
        /mnt/geekvc/fastrcnn-example-torch/data.lua:13: in function 'get_db_loader'
        /mnt/geekvc/fastrcnn-example-torch/data.lua:34: in function 'fetch_loader_dataset'
        /mnt/geekvc/fastrcnn-example-torch/data.lua:298: in function 'data_gen'
        /home/wangty/torch/install/share/lua/5.1/fastrcnn/train.lua:47: in function 'train'
        train.lua:66: in main chunk
        [C]: in function 'dofile'
        ...ngty/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
        [C]: at 0x00406620

the dbc is a boolean value, and the test is true:

th> dbc = require 'dbcollection.manager'
                                                                      [0.2005s]
th> dbc
true

the get_db_loader() function dbc.load{} cause the error.

local function get_db_loader(name)
    local dbc = require 'dbcollection.manager'
    local dbloader
    local str = string.lower(name)
    if str == 'pascal_voc_2007' then
        dbloader = dbc.load{name='pascal_voc_2007', task='detection_d'}
    elseif str == 'pascal_voc_2012' then
        dbloader = dbc.load{name='pascal_voc_2012', task='detection_d'}
    elseif str == 'coco' then
        dbloader = dbc.load{name='coco', task='detection_2015_d'}
    else
        error(('Undefined dataset: %s. Available options: pascal_voc_2007 or coco.'):format(name))
    end
    return dbloader
end
farrajota commented 7 years ago

I've commit a fix earlier for this issue, so just do a git pull on this repo to fetch the fix for get_db_loader() method that is wrongly requiring the dbcollection package.

geekvc commented 7 years ago

I pulled this repo, there is still an error.

$ th train.lua
==> (1/5) Load options
==> (2/5) Load dataset data loader
==> (3/5) Load roi proposals data
==> (4/5) Setup model:
==> (5/5) Train Fast-RCNN model
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/dbcollection/manager.py", line 46, in download
    cache_manager = CacheManager(is_test)
  File "/usr/local/lib/python2.7/dist-packages/dbcollection/utils/cache.py", line 26, in __init__
    self.setup_paths(is_test)
  File "/usr/local/lib/python2.7/dist-packages/dbcollection/utils/cache.py", line 60, in setup_paths
    home_dir = os.path.expanduser("~")
AttributeError: 'module' object has no attribute 'path'
/home/wangty/torch/install/bin/luajit: ...gty/torch/install/share/lua/5.1/dbcollection/manager.lua:60: attempt to index a nil value
stack traceback:
        ...gty/torch/install/share/lua/5.1/dbcollection/manager.lua:60: in function 'exists_task'
        ...gty/torch/install/share/lua/5.1/dbcollection/manager.lua:147: in function 'load'
        /mnt/geekvc/fastrcnn-example-torch/data.lua:13: in function 'get_db_loader'
        /mnt/geekvc/fastrcnn-example-torch/data.lua:34: in function 'fetch_loader_dataset'
        /mnt/geekvc/fastrcnn-example-torch/data.lua:298: in function 'data_gen'
        /home/wangty/torch/install/share/lua/5.1/fastrcnn/train.lua:47: in function 'train'
        train.lua:66: in main chunk
        [C]: in function 'dofile'
        ...ngty/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
        [C]: at 0x00406620
farrajota commented 7 years ago

I need to take a closer look at this. I'm guessing the python version is at fault here (I use python 3.5). I'll report to you in a few minutes

geekvc commented 7 years ago

Ok, thank you for your attention!

geekvc commented 7 years ago

It is quit the problem of my python version. I used the python pyenv to install the anaconda3-4.1.0 and with the python 3.5 version, it works well, and the command conda install -c farrajota dbcollection also goes well. Thank you very much for your help! You can close this issue.

farrajota commented 7 years ago

Glad to see your problem getting solved. Nevertheless tyvm for the input as it seems there's some issues with python 2. I'll continue to investigate and push a fix as soon as possible.

Anything else you might need feel free to ping me

geekvc commented 7 years ago

Ok, I'm very appreciate for your help!