How to use a fine-tuned model for further training and testing on new datasets

616 views
Skip to first unread message

Md. Atiqur Rahman

unread,
Dec 24, 2014, 1:44:47 PM12/24/14
to caffe...@googlegroups.com
Hi all,

I am very new to Caffe and so is with fine-tuning. I would like to fine-tune following the flickr_style_fine-tuning example and then want to use that model to extract features of my dataset in matlab. My questions are -

1. What is the output of fine-tuning? Is it model_name.caffemodel? In that case, can I use this model_name.caffemodel to extract features in matlab? if so, how?

2. If not possible in matlab, how can I use the model_name.caffemodel (fine-tuned model) to extract features for my new dataset and also to test on that dataset?

I would highly appreciate if anyone could help me from scratch.

Longsha Zhou

unread,
Jan 12, 2015, 8:32:50 AM1/12/15
to caffe...@googlegroups.com
did you get the way to use a fine-tuned model?

在 2014年12月25日星期四 UTC+8上午2:44:47,Md. Atiqur Rahman写道:

Md. Atiqur Rahman

unread,
Jan 12, 2015, 4:23:32 PM1/12/15
to caffe...@googlegroups.com
Dear Zhou

Thanks a lot for getting back to my query. Now I know how to fine-tune a model. But, I am stuck at another problem. I do not know how to extract features using Caffe. While tried with this python feature extraction script (http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/filter_visualization.ipynb), it shows the following error message.

>>>import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver
  File "../python/caffe/pycaffe.py", line 11, in <module>
    import caffe.io
  File "../python/caffe/io.py", line 6, in <module>
    from caffe.proto import caffe_pb2
  File "../python/caffe/proto/caffe_pb2.py", line 3, in <module>
    from google.protobuf import descriptor
ImportError: No module named google.protobuf

I am using Anaconda on linux machine and have built google protobuf, but still having the same error. May be, I do not know exactly where to build google protobuf, or I am missing some paths somewhere.

1. Could you please advise me how I can solve this problem?
2. Also, is there any other way to extract features from a fine-tuned model using Caffe, any matlab code?

I would highly appreciate your kind response on the above issues.

Md. Atiqur Rahman

unread,
Jan 18, 2015, 7:07:43 PM1/18/15
to caffe...@googlegroups.com
Dear Zhou,

Could you please respond to my below queries.

I just want to know -

1. Now that I have a fine-tuned model on flicr style dataset, how can I directly use this model to find out scores of a test set from flickr style having 20 classes? I mean, where do I need to make changes (e.g. deploy.prototxt usually has the last layer output size 1000, but flickr has 20 classes).

2. I thought calling the matcaffe_batch(list_im, use_gpu) with the model file set to new fine-tuned model and the model definition file set to the default deploy.ptotoxt with the last layer output changed to 20 (instead of the default value of 1000 for ImageNet) would work. But, its giving me a constant score of 0.05 for all the 20 classes.

Pramiti Goel

unread,
Apr 10, 2015, 2:23:45 PM4/10/15
to caffe...@googlegroups.com
Hi Md. Atiqur Rahman 

Did u find out the solution for why the constant score was occuring for all the classes ? How did u set your parameters for fine tuning on your own dataset ? 

Devendra Mandan

unread,
Jul 25, 2015, 5:32:50 PM7/25/15
to Caffe Users, rat.c...@gmail.com
Hi Atiqur,

Did you solve your problem, I also want to test the finetuned model on my dataset, can you please tell me how to do so?

Md. Atiqur Rahman

unread,
Jul 25, 2015, 5:40:27 PM7/25/15
to Caffe Users, devendr...@gmail.com
Dear @Mandan,

I am sorry that you can't recall what I did to get around this problem as it was an issue I face quite a couple of months ago. But, it should work if you follow the finu-tune instructions provided in caffe's tutotial page.

Thanks
Atique
Reply all
Reply to author
Forward
0 new messages