flyyufelix / densenet-keras Goto Github PK
View Code? Open in Web Editor NEWDenseNet Implementation in Keras with ImageNet Pretrained Models
License: MIT License
DenseNet Implementation in Keras with ImageNet Pretrained Models
License: MIT License
Hi,
At first, thanks for this repo with DenseNet for Keras. As I understand you ported the architecture and weights from Caffe. I've just a question on actual purpose of your custom layer Scale after BatchNormalization in Keras v2 in the sense don't they perform the same work ?
I'm curious, what did you use to actually convert the weights from caffe to keras?
Can you explain why you're using a separate scale function when batch norm scales the output anyway?
do we need to do preprocssing of data like normalization and mean subtraction to fine tune
pretrained densenet models?
Hi, this is a nice work. And I have some questions about how to use the model.
What tool is used convert the caffe model? And what order should be used for testing, RGB or BGR. Thanks.
By leveraging on this denseNet-Keras framework can we undergo face recognition.
if so, what is the accuracy we can achieve ?
Can i get step by step implementation of this code please.
As in flyyufelix/cnn_finetune#5 please consider applying a license (I suggest MIT, which is at that link).
Hi, I notice your project at shahsohil/sunets#8. Have you reproduced the paper<DocUNet: Document Image Unwarping via A Stacked U-Net>? I trained the S-UNet for this paper some times,but it doesn't work. Can you give me some suggestions?
Hi,
Thanks a lot for the repo, but I hit the following error when trying the python test_inference.py
with the densenet169:
Traceback (most recent call last):
File "test_inference.py", line 27, in <module>
model = DenseNet(reduction=0.5, classes=1000, weights_path=weights_path)
File "densenet169.py", line 78, in DenseNet
model.load_weights(weights_path, by_name=True)
File "/home/petteri/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 2498, in load_weights
load_weights_from_hdf5_group_by_name(f, self.layers)
File "/home/petteri/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 2976, in load_weights_from_hdf5_group_by_name
K.batch_set_value(weight_value_tuples)
File "/home/petteri/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2025, in batch_set_value
assign_op = x.assign(assign_placeholder)
AttributeError: 'Tensor' object has no attribute 'assign'
So when printing the types of the variables in the saved weights I got the following:
<tf.Variable 'conv1/kernel:0' shape=(7, 7, 3, 64) dtype=float32_ref>
<tf.Variable 'conv1_bn/gamma:0' shape=(64,) dtype=float32_ref>
<tf.Variable 'conv1_bn/beta:0' shape=(64,) dtype=float32_ref>
<tf.Variable 'conv1_bn/moving_mean:0' shape=(64,) dtype=float32_ref>
<tf.Variable 'conv1_bn/moving_variance:0' shape=(64,) dtype=float32_ref>
Tensor("conv1_scale/Const:0", shape=(64,), dtype=float32)
And the batch_set_value(tuples)
from the backend hit the Tensor problem with "conv1_scale", is there a fix for this to allow the assigning or are the weights somewhat weirdly saved?:
if hasattr(x, '_assign_placeholder'):
assign_placeholder = x._assign_placeholder
assign_op = x._assign_op
else:
assign_placeholder = tf.placeholder(tf_dtype, shape=value.shape)
assign_op = x.assign(assign_placeholder)
x._assign_placeholder = assign_placeholder
x._assign_op = assign_op
assign_ops.append(assign_op)
feed_dict[assign_placeholder] = value
how do I train my own model ?
@flyyufelix, can u plz tell me how to get the bounding box of the detected object class?
What to modify to get the bounding box?
DenseNet-Keras git:(master) ipython
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
Type "copyright", "credits" or "license" for more information.
IPython 5.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import cv2
In [2]: import tensorflow as tf
In [3]: cv2.__version__
Out[3]: '2.4.13.6'
In [4]: tf.__version__
Out[4]: '1.4.0'
In [5]: import keras
Using TensorFlow backend.
In [6]: keras.__version__
Out[6]: '2.2.2'
DenseNet-Keras git:(master) ls -hl imagenet_models
total 33M
drwxrwxr-x 2 epbox epbox 4.0K 8月 30 15:08 .
drwxrwxr-x 5 epbox epbox 4.0K 8月 30 15:09 ..
-rw-r--r-- 1 epbox epbox 32M 8月 30 15:07 densenet121_weights_tf.h5
-rw-rw-r-- 1 epbox epbox 55 8月 30 14:40 README.md
DenseNet-Keras git:(master) python test_inference.py
Using TensorFlow backend.
/home/epbox/Github/DenseNet-Keras/densenet121.py:45: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(64, (7, 7), strides=(2, 2), use_bias=False, name="conv1")`
x = Convolution2D(nb_filter, 7, 7, subsample=(2, 2), name='conv1', bias=False)(x)
2018-09-10 14:25:19.720132: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-09-10 14:25:19.821988: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-09-10 14:25:19.822306: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX TITAN X major: 5 minor: 2 memoryClockRate(GHz): 1.076
pciBusID: 0000:01:00.0
totalMemory: 11.92GiB freeMemory: 11.64GiB
2018-09-10 14:25:19.822322: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX TITAN X, pci bus id: 0000:01:00.0, compute capability: 5.2)
/home/epbox/Github/DenseNet-Keras/densenet121.py:99: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(128, (1, 1), use_bias=False, name="conv2_1_x1")`
x = Convolution2D(inter_channel, 1, 1, name=conv_name_base+'_x1', bias=False)(x)
/home/epbox/Github/DenseNet-Keras/densenet121.py:109: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(32, (3, 3), use_bias=False, name="conv2_1_x2")`
x = Convolution2D(nb_filter, 3, 3, name=conv_name_base+'_x2', bias=False)(x)
Traceback (most recent call last):
File "test_inference.py", line 34, in <module>
model = DenseNet(reduction=0.5, classes=1000, weights_path=weights_path)
File "/home/epbox/Github/DenseNet-Keras/densenet121.py", line 55, in DenseNet
x, nb_filter = dense_block(x, stage, nb_layers[block_idx], nb_filter, growth_rate, dropout_rate=dropout_rate, weight_decay=weight_decay)
File "/home/epbox/Github/DenseNet-Keras/densenet121.py", line 165, in dense_block
concat_feat = merge([concat_feat, x], mode='concat', concat_axis=concat_axis, name='concat_'+str(stage)+'_'+str(branch))
TypeError: 'module' object is not callable
Hi,
Is it possible to get better results by setting 'bias' to false?
Hi, i try to run the test code ,but i meet the above error. Has anyone encountered the same problem?
Hi,
Did you test the pre-train model on tensorflow backend?
I got an error when use it while the theano backend works.
I need a tensorflow pre-train model.
Thanks
Getting error while loading model 'AttributeError: 'Tensor' object has no attribute 'assign'
Hello, thanks for your great work. I need your pretrained model for my own experiment. I'll appreciate it if you can give me the access. My google mail address: [email protected]
AssertionError: AbstractConv shape mismatch: shape of filters does not match given kshp.
Apply node that caused the error: Assert{msg='AbstractConv shape mismatch: shape of filters does not match given kshp.'}(InplaceDimShuffle{3,2,0,1}.0, Elemwise{eq,no_inplace}.0, Elemwise{eq,no_inplace}.0, Elemwise{eq,no_inplace}.0, Elemwise{eq,no_inplace}.0)
Toposort index: 2069
Inputs types: [TensorType(float32, 4D), TensorType(bool, scalar), TensorType(bool, scalar), TensorType(bool, scalar), TensorType(bool, scalar)]
Inputs shapes: [(3L, 64L, 7L, 7L), (), (), (), ()]
Inputs strides: [(196L, 588L, 4L, 28L), (), (), (), ()]
Inputs values: ['not shown', array(False, dtype=bool), array(False, dtype=bool), array(True, dtype=bool), array(True, dtype=bool)]
Outputs clients: [[Subtensor{::, ::, ::int64, ::int64}(Assert{msg='AbstractConv shape mismatch: shape of filters does not match given kshp.'}.0, Constant{-1}, Constant{-1})]]
Hello, thanks for your great work. I am researching some related issues and need your pretrained model for my own experiment. I'll appreciate it if you can give me the access. My google mail address: [email protected]
The iterative updates of nb_filter are never used:
Line 164+: x = conv_block(concat_feat, stage, branch, growth_rate, dropout_rate, weight_decay)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.