Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the model from GoogLenet #2

Closed
ayakubovich opened this issue Jul 26, 2015 · 4 comments
Closed

Changing the model from GoogLenet #2

ayakubovich opened this issue Jul 26, 2015 · 4 comments

Comments

@ayakubovich
Copy link

I'm getting some errors when I try to change the model from the default GoogLenet. I'm probably just not understanding the API correctly.

This works:

>>> BatCountry('/caffe-master/models/bvlc_googlenet')

But this doesn't:

>>> BatCountry('/caffe-master/models/bvlc_alexnet')  
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "batcountry/batcountry.py", line 34, in __init__
    channel_swap=channels)
  File "/caffe-master/distribute/python/caffe/classifier.py", line 26, in __init__
    caffe.Net.__init__(self, model_file, pretrained_file, caffe.TEST)
RuntimeError: Could not open file /caffe-master/models/bvlc_alexnet/bvlc_googlenet.caffemodel

Are there additional arguments that need to be set when changing the model? I couldn't figure this out from the doc. In demo_bulk.py it seems like the only argument we pass is the path to the model.

@jrosebr1
Copy link
Owner

jrosebr1 commented Aug 5, 2015

@ayakubovich Sorry it's taken me so long to reply to this, definitely my fault. Take a look at the __init__ method of BatCountry, specifically the base_path, which is the path to your Caffe model directory, deploy_path which is the .prototxt file, and model_path which is your .caffemodel file. These variables come with initial values that enable GoogLeNet to be used out of the box, but can be overridden to handle other models.

@amsimoes
Copy link

I'm curious about this same way to change the model...
I understand the python code but in pratice I don't know how to change it other than renaming my caffemodel's name to the default google one and the same for the prototxt file... although the base_path can be changed due to your "visualize_layers.py" code requesting it on the "--base-model" parameter...
Isn't it possible to optionally request the user in CLI the parameter to some specific coffemodel and prototxt files, and if nothing gets written then assume it's the googleNet the user wants to work with...
I'm going to research some way of doing this even with my python being very rusty nowadays :)

@jrosebr1
Copy link
Owner

Asking for a user to manually specify a path via command line argument isn't very Python, so I wouldn't recommend doing that. Here is some example code to specify the paths to the base_path, model_path, and deploy_path using the BatCountry constructor:

bc = BatCountry(base_path="/path/to/directory/containing/prototxt_and_caffemodel', deploy_path='filename_of.prototxt', model_path='filename_of.caffemodel')

As long as you specify those parameters, everything should workj ust fine.

@jrosebr1
Copy link
Owner

Going ahead and marking this issue as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants