chaosmail/caffejs

Can't load GoogLeNet model

victoriastuart opened this issue · 3 comments

I have the pretrained model,

/mnt/Vancouver/apps/caffejs/docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodel
/mnt/Vancouver/apps/caffejs/docs/assets/models/bvlc_googlenet/deploy.prototxt

and everything appears to be good but I cannot get the model loaded/running ... :-/

(py27) [victoria@victoria caffejs]$ node node_modules/.bin/http-server

Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8080
  http://192.168.1.4:8080
  http://10.1.10.10:8080
Hit CTRL-C to stop the server

[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/webcam.html" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/material.min.css" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/material.min.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/styles/docs.css" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/webcam.min.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/d3.min.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/dist/caffe.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/lodash.min.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/graphlib.core.min.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/dagre.core.min.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/libs/dagre-d3.core.min.js" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:05 GMT-0800 (PST)] "GET /docs/assets/styles/graph.css" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/data/ilsvrc12/synset_words.txt" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/deploy.prototxt" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv1/7x7_s2_filter.bin" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv1/7x7_s2_filter.bin" Error (404): "Not found"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv1/7x7_s2_bias.bin" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_reduce_filter.bin" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_reduce_bias.bin" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_filter.bin" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_bias.bin" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv1/7x7_s2_bias.bin" Error (404): "Not found"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_reduce_filter.bin" Error (404): "Not found"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_reduce_bias.bin" Error (404): "Not found"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_filter.bin" Error (404): "Not found"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelconv2/3x3_bias.bin" Error (404): "Not found"
[Mon Dec 12 2016 18:08:06 GMT-0800 (PST)] "GET /docs/assets/models/bvlc_googlenet/bvlc_googlenet.caffemodelinception_3a/1x1_filter.bin" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
[ ... SNIP! ... ]

.. and I don't see any images in the layers (outputs) ...

selection_816

selection_817

http://localhost:8080/npm-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@4.0.3
3 info using node@v7.2.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle caffejs@0.1.0~prestart: caffejs@0.1.0
6 silly lifecycle caffejs@0.1.0~prestart: no script for prestart, continuing
7 info lifecycle caffejs@0.1.0~start: caffejs@0.1.0
8 verbose lifecycle caffejs@0.1.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle caffejs@0.1.0~start: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/mnt/Vancouver/apps/caffejs/node_modules/.bin:/home/victoria/anaconda3/envs/py27/bin:/mnt/Vancouver/apps/uima/apache-uima//bin/:/mnt/Vancouver/apps/torch7/install/bin:/mnt/Vancouver/apps/tapkee/bin/:/mnt/Vancouver/apps/solr/solr-5.3.0/bin/:/mnt/Vancouver/apps/pdfreflow/bin/:/mnt/Vancouver/apps/optunity/:/mnt/Vancouver/apps/maven/apache-maven-3.3.3/bin/:/mnt/Vancouver/apps/mallet/mallet-2.0.8RC2/bin/:/mnt/Vancouver/apps/lynx/bin/:/usr/bin/:/home/victoria/anaconda3/bin:/mnt/Vancouver/apps/torch7/install/bin:/mnt/Vancouver/apps/torch7/install/bin:/mnt/Vancouver/apps/torch7/install/bin:/mnt/Vancouver/apps/uima/apache-uima//bin/:/mnt/Vancouver/apps/torch7/install/bin:/mnt/Vancouver/apps/tapkee/bin/:/mnt/Vancouver/apps/solr/solr-5.3.0/bin/:/mnt/Vancouver/apps/pdfreflow/bin/:/mnt/Vancouver/apps/optunity/:/mnt/Vancouver/apps/maven/apache-maven-3.3.3/bin/:/mnt/Vancouver/apps/mallet/mallet-2.0.8RC2/bin/:/mnt/Vancouver/apps/lynx/bin/:/usr/bin/:/home/victoria/anaconda3/bin:/usr/lib/jvm/java-6-sun-1.6.0.66/bin:/mnt/Vancouver/apps/uima/apache-uima//bin/:/mnt/Vancouver/apps/torch7/install/bin:/mnt/Vancouver/apps/tapkee/bin/:/mnt/Vancouver/apps/solr/solr-5.3.0/bin/:/mnt/Vancouver/apps/pdfreflow/bin/:/mnt/Vancouver/apps/optunity/:/mnt/Vancouver/apps/maven/apache-maven-3.3.3/bin/:/mnt/Vancouver/apps/mallet/mallet-2.0.8RC2/bin/:/mnt/Vancouver/apps/lynx/bin/:/usr/bin/:/home/victoria/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
10 verbose lifecycle caffejs@0.1.0~start: CWD: /mnt/Vancouver/apps/caffejs
11 silly lifecycle caffejs@0.1.0~start: Args: [ '-c', 'cd docs-pages && http-server' ]
12 silly lifecycle caffejs@0.1.0~start: Returned: code: 1  signal: null
13 info lifecycle caffejs@0.1.0~start: Failed to exec start script
14 verbose stack Error: caffejs@0.1.0 start: `cd docs-pages && http-server`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:885:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid caffejs@0.1.0
16 verbose cwd /mnt/Vancouver/apps/caffejs
17 error Linux 4.8.11-1-ARCH
18 error argv "/usr/bin/node" "/usr/bin/npm" "start"
19 error node v7.2.1
20 error npm  v4.0.3
21 error code ELIFECYCLE
22 error caffejs@0.1.0 start: `cd docs-pages && http-server`
22 error Exit status 1
23 error Failed at the caffejs@0.1.0 start script 'cd docs-pages && http-server'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the caffejs package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     cd docs-pages && http-server
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs caffejs
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls caffejs
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Hi @victoriastuart

CaffeJS cannot (yet) load the model weights from a *.caffemodel file.

Use the scripts/convert_caffemodel.py to convert the model weights into binary chunks separated per layer. You can check out the googlenet model on the gh-pages branch where I deployed the model weights (the weights directory) (https://github.com/chaosmail/caffejs/tree/gh-pages/models/bvlc_googlenet).

Let me know if this works for you!

Best,
Christoph

[2017-Jan-01]

Hello Christof: Happy New Year; best wishes for a happy and successful 2017!

Thank you for the link, above, to your GoogLeNet weights; much appreciated!

I faced multiple issues, but CaffeJS is now working! :-D

FIRST: the script

.../caffejs/scripts/convert_caffemodel.py

threw an error (my system: Arch Linux x86_64; caffe and pycaffe are installed and otherwise working; Python 2.7 virtual environment):

which python
    /home/victoria/anaconda3/envs/py27/bin/python

python --version
    Python 2.7.12 :: Anaconda custom (64-bit)

pwd
    /mnt/Vancouver/apps/caffejs/scripts

ls -l

    total 4.0K
    -rw-r--r-- 1 victoria victoria 2.6K Jan  1 14:04 convert_caffemodel.py
    -rw-r--r-- 1 victoria victoria    0 Dec 12 16:27 __init__.py

python convert_caffemodel.py

    Traceback (most recent call last):
      File "convert_caffemodel.py", line 33, in <module>
        net = caffe.Net(MODEL_FILE, PRETRAINED, phase)
    AttributeError: 'module' object has no attribute 'Net'

Not a problem however, as you provided the weights! ;-)

https://github.com/chaosmail/caffejs/tree/gh-pages/models/bvlc_googlenet/weights

SECOND: (noting also that I'm new to caffe, but also Flask | template inheritance), it appears that the HTML templates are not rendering. For example (I have npm and node installed and otherwise working; http-server globally-installed),

npm install

    > caffejs@0.1.0 postinstall /mnt/Vancouver/apps/caffejs
    > typings install

    sh: typings: command not found

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    npm WARN caffejs@0.1.0 No repository field.
    npm WARN You are using a pre-release version of node and things may not work as expected
    npm ERR! Linux 4.8.13-1-ARCH
    npm ERR! argv "/usr/local/bin/node" "/usr/bin/npm" "install"
    npm ERR! node v8.0.0-pre
    npm ERR! npm  v4.0.5
    npm ERR! file sh
    npm ERR! code ELIFECYCLE
    npm ERR! errno ENOENT
    npm ERR! syscall spawn
    npm ERR! caffejs@0.1.0 postinstall: `typings install`
    npm ERR! spawn ENOENT
    npm ERR!
    npm ERR! Failed at the caffejs@0.1.0 postinstall script 'typings install'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the caffejs package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     typings install
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR!     npm bugs caffejs
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR!     npm owner ls caffejs
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR!     /mnt/Vancouver/apps/caffejs/npm-debug.log

npm start

    > caffejs@0.1.0 start /mnt/Vancouver/apps/caffejs
    > cd docs-pages && http-server

    Starting up http-server, serving ./
    Available on:
      http://127.0.0.1:8080
      http://192.168.1.4:8080
    Hit CTRL-C to stop the server
    ^C
    http-server stopped.

Note the "docs-pages" part, above; there is no such directory. Noting again that I am completely new to (Flask), HTML template inheritance, ... to me it appears that "gulpfile.js" is encountering errors, and failing to properly compile the webcam.html file (.../caffejs/docs/assets/webcam.html << docs, not docs-pages!).

THIRD: I needed to modify that webcam.html script,

...
function loadModel() {

    model = new Net.CaffeModel(
        //'models/bvlc_googlenet/bvlc_googlenet.prototxt',
        'models/bvlc_googlenet/deploy.prototxt',
        //'models/bvlc_googlenet/bvlc_googlenet.caffemodel'
        'models/bvlc_googlenet/weights'
    );
...

per your live example (my original lines commented out in the JavaScript code, above).

FOURTH/LASTLY: That html file STILL failed to load the weights. HOWEVER, if I replace my webcam.html code with yours, start http-server in .../caffejs/docs/assets/, open http://127.0.0.1:8080/ in my browser (Firefox 50.1.0) and click webcam.html, then I can classify my objects!! :-D

To get it to work, however, I ALSO, additionally needed to create the following symlinks:

ls -l

    total 44K
    -rw-r--r--  1 victoria victoria 3.4K Dec 12 12:39 base.html
    drwxr-xr-x  5 victoria victoria 4.0K Dec 10 11:47 data
    lrwxrwxrwx  1 victoria victoria   32 Jan  1 16:48 dist -> /mnt/Vancouver/apps/caffejs/dist
    drwxr-xr-x  2 victoria victoria 4.0K Dec 10 11:47 libs
    drwxr-xr-x 11 victoria victoria 4.0K Dec 12 21:40 models
    -rw-r--r--  1 victoria victoria 6.7K Dec 12 12:50 models.html
    lrwxrwxrwx  1 victoria victoria   39 Jan  1 16:49 Net -> /mnt/Vancouver/apps/caffejs/modules/Net
    drwxr-xr-x  2 victoria victoria 4.0K Dec 10 11:47 scripts
    drwxr-xr-x  2 victoria victoria 4.0K Dec 10 11:47 styles
    lrwxrwxrwx  1 victoria victoria   42 Jan  1 16:48 templates -> /mnt/Vancouver/apps/caffejs/docs/templates
    -rw-r--r--  1 victoria victoria 9.1K Jan  1 16:38 webcam.html

Again, I presume that this is an issue arising from the buggy/non-working/failed npm installation.

Q.E.D. [ Whew! ]

This (CaffeJS) is really great - very nicely implemented - thank you so much for sharing!!

Best,
Victoria :-)

caffejs 1
caffejs 2