Code Monkey home page Code Monkey logo

keras_rmac's People

Contributors

noagarcia 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

Watchers

 avatar

keras_rmac's Issues

Dimension mismatched

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.

image shape

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

Issues related to running the code.

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

What do you mean, b and idx in the code?

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?

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.