noagarcia / keras_rmac Goto Github PK
View Code? Open in Web Editor NEWRMAC implementation in Keras
RMAC implementation in Keras
Hi,This model Spend too much time,How to solve?
when i load weight vgg16 , it happend issue "Dimension 0 in both shapes must be equal, but are 344064 and 25088"
When I load the pre-trained model, I got dimension mismatched error, when I resized images to (224, 224), it was solved. Does it affect the model? I mean r-mac model.
x = image.img_to_array(img) #把图像转换为数组类形numpy.ndarray
x = np.expand_dims(x, axis=0)
x = utils.preprocess_image(x)
The x output shape here is (1, 683, 1024, 3)
but x = utils.preprocess_image(x)
x[:, 0, :, :] -= 103.939
x[:, 1, :, :] -= 116.779
x[:, 2, :, :] -= 123.68
The second dimension is the number of channels, but the last dimension of the shape of x is the number of channels
I have tried that loading VGG16 weight only at the beginning of program, and every time after executing ,I'll delete the loading image. But it still memory leak, how can I release my memory? (not GPU Ram)
Hi,
can you please tell me which is the dataset used to generate the PCA?
I am using theano as backend. Is there a way to use GPU instead of the CPU for processing..
And plus is there a way to run multiple processes as there is a lock while execution.
The region array calculated by rmac_regions seems to be [x, y, w, h], but actually, it is used as [x, y, h, w] in RoiPooling...
I ran your code in my local system and I got the following error,
Traceback (most recent call last): File "rmac.py", line 92, in <module> model = rmac((x.shape[1], x.shape[2], x.shape[3]), len(regions)) File "rmac.py", line 34, in rmac vgg16_model = VGG16(utils.DATA_DIR + utils.WEIGHTS_FILE, input_shape) File "/home/randheer/keras_rmac/vgg16.py", line 61, in VGG16 model.load_weights(weights_path) File "/home/randheer/anaconda3/lib/python3.6/site-packages/keras/engine/network.py", line 1166, in load_weights f, self.layers, reshape=reshape) File "/home/randheer/anaconda3/lib/python3.6/site-packages/keras/engine/saving.py", line 1058, in load_weights_from_hdf5_group K.batch_set_value(weight_value_tuples) File "/home/randheer/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2465, in batch_set_value assign_op = x.assign(assign_placeholder) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 1762, in assign name=name) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 223, in assign validate_shape=validate_shape) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 64, in assign use_locking=use_locking, name=name) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1823, in __init__ control_input_ops) File "/home/randheer/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1662, in _create_c_op raise ValueError(str(e))
ValueError: Dimension 0 in both shapes must be equal, but are 344064 and 25088. Shapes are [344064,4096] and [25088,4096]. for 'Assign_26' (op: 'Assign') with input shapes: [344064,4096], [25088,4096].
My directory looks like this:
->data
---->vgg_weights.h5
---->sample.jpg
->RoiPooling.py
->rmac.py
->vgg16.py
->get_regions.py
->utils.py
Can you address this problem?
Waiting for a reply
def rmac_regions(W, H, L):#这里L使用的是3
#w=32,h=21
ovr = 0.4 # desired overlap of neighboring regions
steps = np.array([2, 3, 4, 5, 6, 7], dtype=np.float) # possible regions for the long dimension
w = min(W,H)
b = (max(H,W) - w)/(steps-1)
idx = np.argmin(abs(((w ** 2 - w*b)/w ** 2)-ovr)) # steps(idx) regions for long dimension
# region overplus per dimension
Wd, Hd = 0, 0
if H < W:
Wd = idx + 1
elif H > W:
Hd = idx + 1
What do you mean,step, b and idx,Wd,Hd in the code?
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.