Git Product home page Git Product logo

densenet-caffe's People

Contributors

lutzroeder avatar shicai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

densenet-caffe's Issues

Is there any tricks for training

Hi @shicai ,
I followed Resnet policy for training Densenet-121 yet get 72% for top1, I'd be appreciated if there is any tricks to share to reach the paper acc.
Btw due to the GPU limit, I could only train with a batchsize 64.
Thx!

Fine-tune Dense 201 problem

Dear Shicai,
I'm trying to fine-tune my dataset using your model. I've already read all the issues and make some modification to .prototxt , but it gives me the following error:
ERROR: Check failed: target_blobs.size() == source_layer.blobs_size() (5 vs. 3) Incompatible number of blobs for layer conv1/bn
would you please help me to find the problem?
here is my proto , I'm using AWS P3 instance and using Digits.


layer {
 name: "train-data"
 type: "Data"
 top: "data"
 top: "label"
 include {
   stage: "train"
 }
 transform_param {
   crop_size: 224
 }
 data_param {
   batch_size: 126
 }
}
layer {
 name: "val-data"
 type: "Data"
 top: "data"
 top: "label"
 include {
   stage: "val"
 }
 transform_param {
   crop_size: 224
 }
 data_param {
   batch_size: 64
 }
}
layer {
 name: "conv1"
 type: "Convolution"
 bottom: "data"
 top: "conv1"
 convolution_param {
   num_output: 64
   bias_term: false
   pad: 3
   kernel_size: 7
   stride: 2
 }
}
layer {
 name: "conv1/bn"
 type: "BatchNorm"
 bottom: "conv1"
 top: "conv1/bn"
 batch_norm_param {
   eps: 1e-5
 }
}
layer {
 name: "conv1/scale"
 type: "Scale"
 bottom: "conv1/bn"
 top: "conv1/bn"
 scale_param {
   bias_term: true
 }
}
layer {
 name: "relu1"
 type: "ReLU"
 bottom: "conv1/bn"
 top: "conv1/bn"
}
.
.
.
.
layer {
 name: "fc6new"
 type: "Convolution"
 bottom: "pool5"
 top: "fc6new"
 convolution_param {
   num_output: 35
   kernel_size: 1
 }
}

layer {
 name: "loss"
 type: "SoftmaxWithLoss"
 bottom: "fc6new"
 bottom: "label"
 top: "loss"
 exclude {
   stage: "deploy"
 }
}
layer {
 name: "accuracy"
 type: "Accuracy"
 bottom: "fc6new"
 bottom: "label"
 top: "accuracy"
 include {
   stage: "val"
 }
}
layer {
 name: "accuracy_train"
 type: "Accuracy"
 bottom: "fc6new"
 bottom: "label"
 top: "accuracy_train"
 include {
   stage: "train"
 }
 accuracy_param {
   top_k: 5
 }
}
layer {
 name: "softmax"
 type: "Softmax"
 bottom: "fc6new"
 top: "softmax"
 include {
   stage: "deploy"
 }
}

the complete error thrown by digits

conv2_1/x2/bn needs backward computation.
conv2_1/x1 needs backward computation.
relu2_1/x1 needs backward computation.
conv2_1/x1/scale needs backward computation.
conv2_1/x1/bn needs backward computation.
pool1_pool1_0_split needs backward computation.
pool1 needs backward computation.
relu1 needs backward computation.
conv1/scale needs backward computation.
conv1/bn needs backward computation.
conv1 needs backward computation.
label_val-data_1_split does not need backward computation.
val-data does not need backward computation.
This network produces output accuracy
This network produces output loss
Network initialization done.
Solver scaffolding done.
Finetuning from /home/ubuntu/models/DenseNet-Caffe/densenet201.caffemodel
Ignoring source layer input
Check failed: target_blobs.size() == source_layer.blobs_size() (5 vs. 3) Incompatible number of blobs for layer conv1/bn

how to use your deploy.prototoxt to 2 classification

In my opinion, in order to 2 classification,I should add the probability which type is softmax to achieve it.but I find that in your DenseNet_121.prototxt file,I could not find the softmax layer.So in order to achieve the 2 classification,what should I do to output the probability,and what should I do to achieve 2 classification

problems about the data preprocessing

When i use the pycaffe to prediction, according to readme subtract mean [103.94,116.78,123.68],but the result is bad.I also suspect that it is a label problem,so i follow the tips for another question,check the fb.resnet.torch/imagenet.lua at master · facebook/fb.resnet.torch have no problems.code as follows:

    transformer=caffe.io.Transformer({'data':net.blobs['data'].data.shape})
    transformer.set_transpose('data',(2,0,1))
    transformer.set_mean('data',np.array([103.94,116.78,123.68]))
    transformer.set_raw_scale('data',225)
    transformer.set_channel_swap('data',(2,1,0))

So i tried to comment some preprocesss setting,when i comment thetransformer.set_mean and transformer.set_raw_scale,i found the prediction is very good.
I am very confused,train and test need to be consistent in general ??
I want to ask where the problem might be.
Looking forward to anyone’s reply, thank you!

我在用您的caffemodel做测试的时候遇到了如下的问题,请问一下如何解决

WARNING: Logging before InitGoogleLogging() is written to STDERR
W0805 10:26:38.720525 3101 _caffe.cpp:139] DEPRECATION WARNING - deprecated use of Python interface
W0805 10:26:38.720546 3101 _caffe.cpp:140] Use this instead (with the named "weights" parameter):
W0805 10:26:38.720549 3101 _caffe.cpp:142] Net('/home/xuy/桌面/code/python/caffe/Bag_gender_hair_classification/DenseNet_deploy_161.prototxt', 1, weights='/home/xuy/桌面/code/python/caffe/Bag_gender_hair_classification/model/DenseNet_161.caffemodel')
[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 54:14: Message type "caffe.PoolingParameter" has no field named "ceil_mode".
F0805 10:26:38.740175 3101 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /home/xuy/桌面/code/python/caffe/Bag_gender_hair_classification/DenseNet_deploy_161.prototxt
*** Check failure stack trace: ***

what's your batch size?

Hi, I am training Densenet-121. When the batch size is larger than about 25, out of memory occurs. I'm using a work station with 8 TITANXPascal GPUs, so I can't achieve batch size larger than 200...
What's your batch size when you trained these nets?

About some computing problem

您好,有个问题想请教一下。在每个Dense Block中,每个3332的conv前面都接了11128的conv,这样接比不接11128的计算量还要大,因为channel数目增多了,那为什么要这么做呢?

Model failed to predict the correct class

I saw that you use a convolution layer instead of an innerproduct layer for "fc6". Though it looks weird I am okay with that.

So I added a softmax layer after fc6 to perform classification on my own testing image (it's a cat image). But the model failed to predict the correct class. It might be due to 2 reasons:

  1. For image preprocessing, do you subtract the mean pixel and scaled by 0.017 as below?

im[:,:,0] = (im[:,:,0] - 103.94) / 0.017
im[:,:,1] = (im[:,:,1] - 116.78) / 0.017
im[:,:,2] = (im[:,:,2] - 123.68) / 0.017

  1. Do you use the same classes.txt (class mapping file) as Inception and ResNet? (i.e. this one)

Scope name problem when conventing from LiuZhuang13's code

Hello, Shicai. When generating train_val.prototxt from LiuZhuang13's code, the scope name will be "Convolution1", "BatchNorm13" etc., which is different from yours like "conv1/bn1", "conv3_2/x2/scale". I wonder that the difference will lead a failure to load the pre-train caffemodel. How to deal with the problem? And I will be very appreciated if you provide your make_densenet.py code. Thanks.

DenseNet和Faster R-CNN的结合

  想将该DenseNet121模型作为Faster R-CNN的基础网络去实现,基于您给的DenseNet_121.prototxt文件做了如下修改来生成train.prototxt
  1. 数据输入按照Faster R-CNN的去写
  2. 对于conv layers ,添加1次{ lr_mult: 1 decay_mult: 1}
  3. 对于batchnorm layers,添加3次 {lr_mult: 0 decay_mult: 0}
  4. 对于scale layers,添加2次param {lr_mult: 1 decay_mult: 0}
  5. RPN,ROI Proposal, RCNN,这3部分基本照搬Faster R-CNN中VGG16的去写.做了如下修改:
   1. RPN部分的bottom改为:conv4_blk
   2. R-CNN部分的bottom改为:conv5_blk/bn"
   3. R-CNN部分原来的fc6层改名为fc6_1
  您给的prototxt文件中的"最后的fc6层"和"倒数第2个Pooling层"我直接删除了
  其他的基本没变.现有如何疑问:
  1. 不知道上述那样的修改是否妥当??
  2. 对于Faster R-CNN中的test.prototxt,输入,RPN,ROI Proposal, RCNN这4部分还是按照Faster R-CNN中VGG16的去写.但对于中间的网络部分怎么修改??也要像2,3,4步那样去修改增加对应的param吗??
  3. solver文件怎么写,有没有一些参考??我这里基本是照搬Faster R-CNN中VGG16的.

problem when using your prototxt and model for prediction 。

i use it in caffe( and i ve add the ceil_mode into my code)
./build_release/examples/cpp_classification/classification.bin
models/DenseNet_shicai/DenseNet_201.prototxt
models/DenseNet_shicai/DenseNet_201.caffemodel
data/ilsvrc12/imagenet_mean.binaryproto \ ( i don't know whether it is that?)
data/ilsvrc12/synset_words.txt
imagenet/n02493509/n02493509_10160.JPEG

the result is:
38.6030 - "n06359193 web site, website, internet site, site"
36.7457 - "n02708093 analog clock"
........
........
........

I have tried a few pictures, the result seems to be very strange,.

could you tell me how to do with it ? Thanks.

Hello, I was using caffe once, using a custom version of Microsoft, I do not know how to solve this problem, I hope you can help me.

WARNING: Logging before InitGoogleLogging() is written to STDERR
I0324 10:41:30.693701 10280 common.cpp:36] System entropy source not available, using fallback algorithm to generate seed instead.
W0324 10:41:30.751742 10280 _caffe.cpp:122] DEPRECATION WARNING - deprecated use of Python interface
W0324 10:41:30.751742 10280 _caffe.cpp:123] Use this instead (with the named "weights" parameter):
W0324 10:41:30.751742 10280 _caffe.cpp:125] Net('net.prototxt', 0, weights='exp/mnist/save_iter_100000.caffemodel')
[libprotobuf ERROR ..\src\google\protobuf\text_format.cc:274] Error parsing text-format caffe.NetParameter: 7:13: Message type "caffe.DataParameter" has no field named "seek".
*** Check failure stack trace: ***

revise deploy.prototxt

Hi, shicai, can i directly revise deploy.prototxt to get trainval.prototxt and what is the need to pay attention to detail?

Not achieving your reported performance!

Hi, thanks for your work!
I follow your instruction and run DenseNet121 but only get 0.715681 top-1 accuracy and 0.904023 top-5 accuracy.
I guess it may be caused by the dataset. I use val_lmdb(ressize to 256x256) and crop to 224x224 in the train.prototxt for testing. But for you, it's here:
The top-1/5 accuracy rates by using single center crop (crop size: 224x224, image size: 256xN).
Do you use the original val images for testing? I really don't know what to do to produce 256xN image size.
I find your another reply about image_size here: http://www.caffecn.cn/?/question/428
I get more confused about 10 crops. Can you take a minute to explain it to me?

The shapes in netscope are wrong?

In pool1, the input spatial shape is 112 and ceil_mode = false.
So the output shape will be floor((112-3+2)/2+1) = 56
Does this equal to "padding = 'SAME'" in tensorflow? Which output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides[i])

when i train my own dataset,the loss is not decrease and it is always about 6.97

the following is my solver.prototxt:
net: "examples/re_identification/DenseNet_201.prototxt"
test_iter: 5000
test_interval: 1000
base_lr: 0.01
lr_policy: "step"
gamma: 0.1
stepsize: 1000
display: 20
max_iter: 10000
momentum: 0.9
weight_decay: 0.0005
snapshot: 1000
snapshot_prefix: "examples/re_identification/caffenet_train"
solver_mode: GPU

and i add some code in your DenseNet.prototxt
at the beginning:
name: "DENSENET_201"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
crop_size: 224
mean_value: 90
mean_value: 102
mean_value: 100
mirror: true
}
data_param {
source: "/home/zhou/caffe/examples/re_identification/img_train_lmdb"
batch_size: 1
backend: LMDB
}
}
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
crop_size: 224
mean_value: 90
mean_value: 102
mean_value: 100
mirror: false
}
data_param {
source: "/home/zhou/caffe/examples/re_identification/img_test_lmdb"
batch_size: 1
backend: LMDB
}
}
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
convolution_param {
num_output: 64
bias_term: false
pad: 3
kernel_size: 7
stride: 2
}
...
...
...
at the end i add:
layer {
name: "fc6"
type: "Convolution"
bottom: "pool5"
top: "fc6"
convolution_param {
num_output: 1000
kernel_size: 1
}
}
layer {
name: "accuracy"
type: "Accuracy"
bottom: "fc6"
bottom: "label"
top: "accuracy"
include {
phase: TEST
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "fc6"
bottom: "label"
top: "loss"
}
and the label of my dataset is 0 to 999
i do not know why my loss is not decrease and keep the value about 6.9

fine-tuning

Thanks for sharing!
I want to fine-tuning the model. Is there train-val.prototxt and solver.prototxt survive? Thank you.

{ lr_mult: 1 decay_mult: 1}的含义

对于卷积层:
 当设置param{ lr_mult: X}时,相当于该层的学习率为solver中的base_lr乘以这个系数X
 当设置param{ lr_mult: 0}时,相当于固定该层的权重,不用学习
 当没有设置param{ lr_mult:}时,相当于该层的学习率为solver中的base_lr
可以这么理解吗??发现很多prototxt中并没有这个参数param.

No field named "ceil_mode" when loading caffe model

Error parsing text-format caffe.NetParameter: 54:14: Message type "caffe.PoolingParameter" has no field named "ceil_mode".
It seem that you have modified caffe source code which have no ceil_mode.
How can I fix it?
Thanks

cuDNN does not allow an eps value less than 1e-5

When loading this model with Chainer and attempting to evaluate a batch of images it complains that the eps param in batch-norm is < 1e-5

sym = caffe.CaffeFunction("DenseNet_121.caffemodel")
Is it possible to truncate it at 1e-5 without affecting the accuracy?

RuntimeError Traceback (most recent call last)
in ()
1 dta = fake_input_data_cf[:8]
----> 2 pred = sym(inputs={'data':dta}, outputs=['fc6'])

/anaconda/envs/py35/lib/python3.5/site-packages/chainer/links/caffe/caffe_function.py in call(self, inputs, outputs, disable, **kwargs)
218 func = self.forwards[func_name]
219 input_vars = tuple(variables[blob] for blob in bottom)
--> 220 output_vars = func(*input_vars)
221 if not isinstance(output_vars, collections.Iterable):
222 output_vars = output_vars,

/anaconda/envs/py35/lib/python3.5/site-packages/chainer/links/caffe/caffe_function.py in call(self, x)
567
568 def call(self, x):
--> 569 return self.func(x, *self.args, **self.kwargs)
570
571

/anaconda/envs/py35/lib/python3.5/site-packages/chainer/links/caffe/caffe_function.py in call(self, *xs, **kwargs)
606
607 def call(self, *xs, **kwargs):
--> 608 return self.caffe_func[self.name](*xs, **kwargs)
609
610

/anaconda/envs/py35/lib/python3.5/site-packages/chainer/links/normalization/batch_normalization.py in call(self, x, **kwargs)
142 ret = functions.batch_normalization(
143 x, gamma, beta, eps=self.eps, running_mean=self.avg_mean,
--> 144 running_var=self.avg_var, decay=decay)
145 else:
146 # Use running average statistics or fine-tuned statistics.

/anaconda/envs/py35/lib/python3.5/site-packages/chainer/functions/normalization/batch_normalization.py in batch_normalization(x, gamma, beta, **kwargs)
527 ('running_var', None), ('decay', 0.9))
528
--> 529 return BatchNormalization(eps, running_mean, running_var, decay).apply(
530 (x, gamma, beta))[0]
531

/anaconda/envs/py35/lib/python3.5/site-packages/chainer/functions/normalization/batch_normalization.py in init(self, eps, mean, var, decay)
30 if eps < 1e-5:
31 msg = 'cuDNN does not allow an eps value less than 1e-5.'
---> 32 raise RuntimeError(msg)
33 self.decay = decay
34

RuntimeError: cuDNN does not allow an eps value less than 1e-5.

Thankyou!

The DenseNet prototxts are wonderful. Thanks so much!

Question about scale=0.017

First of all, thanks for sharing these models. I am not quite understand what this scale ratio means. Do I have to implement this on the input data or what?
Thanks

DenseNet161 deploy prototxt (ceil_mode and round_mode) error

Loading .caffemodel and deploy.ptototxt in caffe for TEST phase returns the following error:

[libprotobuf ERROR google/protobuf/text_format.cc:288] Error parsing text-format caffe.NetParameter: 54:14: Message type "caffe.PoolingParameter" has no field named "ceil_mode".
F0430 20:48:24.400027 24399 upgrade_proto.cpp:90] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: MODELS/DenseNet161/ImageNet/deploy.prototxt
*** Check failure stack trace: ***
Aborted (core dumped

ur Baidu link (https://pan.baidu.com/s/1gfjD8cF) seems to be broken too! Do u have updated version of that link?

关于densenet训练阶段BN层的设置

您好,在densenet训练阶段,train.prototxt中是否要设置BN层在TRAIN和TEST两种phase下的参数use_global_stats的状态,例如这样:
layer {
bottom: "conv6"
top: "conv6"
name: "bn_conv6"
type: "BatchNorm"
batch_norm_param {
use_global_stats: false
}
include {
phase: TRAIN
}
}
layer {
bottom: "conv6"
top: "conv6"
name: "bn_conv6"
type: "BatchNorm"
batch_norm_param {
use_global_stats: true
}
include{
phase: TEST
}
}
还是说只需要设置一种状态,然后在deploy.prototxt中,设置use_global_stats=true就行了

about some details

Thanks for your job! I use your pretrain model and SSD algorithm to train a model.
for conv layer, I add param { lr_mult: 1 decay_mult: 1}
for bn layer , I add param { lr_mult: 0 decay_mult: 0} for 3 times to fix.
I don't konw the scale layer need add lr_mult and decay_mult?scale 层需要添加学习率这些参数吗
And for conv layer, need I add weight_filler and bias_filler? 我既然有了预训练模型,那还需要对卷积层参数初始化吗?
谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.