Code Monkey home page Code Monkey logo

Comments (5)

clennan avatar clennan commented on May 19, 2024 3

Hey, in src/evaluater/predict.py you can see how the NIMA model class is being used to load the pre-trained weights from models/MobileNet

For example, to load the aesthetic weights you could run (ensure that your working directory is src)

from handlers.model_builder import Nima

nima = Nima('MobileNet', weights=None)
nima.build()
nima.nima_model.load_weights('../models/MobileNet/weights_mobilenet_aesthetic_0.07.hdf5')
nima.nima_model.summary()

Hope this helps

from image-quality-assessment.

clennan avatar clennan commented on May 19, 2024

The model input dimensions are [batch size, 224, 224, 3], i.e. the images are resized to 224x224

from image-quality-assessment.

thisisashukla avatar thisisashukla commented on May 19, 2024

Thanks for the response. I am getting the following error from the command mentioned:
base = mobilenet.MobileNet(input_shape=(224, 224, 3), include_top=True, weights='weights_mobilenet_aesthetic_0.07.hdf5')

Error Trail

<ipython-input-5-635740cf9285> in <module>()
----> 1 base = mobilenet.MobileNet(input_shape=(224, 224, 3), include_top=True, weights='weights_mobilenet_aesthetic_0.07.hdf5')

path-to-keras\keras_applications\mobilenet.py in MobileNet(input_shape, alpha, depth_multiplier, dropout, include_top, weights, input_tensor, pooling, classes)
    322         model.load_weights(weights_path)
    323     elif weights is not None:
--> 324         model.load_weights(weights)
    325 
    326     if old_data_format:

path-to-keras\keras\engine\network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)
   1159             else:
   1160                 saving.load_weights_from_hdf5_group(
-> 1161                     f, self.layers, reshape=reshape)
   1162 
   1163     def _updated_config(self):

path-to-keras\keras\engine\saving.py in load_weights_from_hdf5_group(f, layers, reshape)
    913                                                        original_keras_version,
    914                                                        original_backend,
--> 915                                                        reshape=reshape)
    916         if len(weight_values) != len(symbolic_weights):
    917             raise ValueError('Layer #' + str(k) +

path-to-keras\keras\engine\saving.py in preprocess_weights_for_loading(layer, weights, original_keras_version, original_backend, reshape)
    672             weights[0] = np.reshape(weights[0], layer_weights_shape)
    673         elif layer_weights_shape != weights[0].shape:
--> 674             weights[0] = np.transpose(weights[0], (3, 2, 0, 1))
    675             if layer.__class__.__name__ == 'ConvLSTM2D':
    676                 weights[1] = np.transpose(weights[1], (3, 2, 0, 1))

path-to-numpy\numpy\core\fromnumeric.py in transpose(a, axes)
    596 
    597     """
--> 598     return _wrapfunc(a, 'transpose', axes)
    599 
    600 

path-to-numpy\numpy\core\fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
     49 def _wrapfunc(obj, method, *args, **kwds):
     50     try:
---> 51         return getattr(obj, method)(*args, **kwds)
     52 
     53     # An AttributeError occurs if the object does not have

ValueError: axes don't match array

Any help would be appreciated

from image-quality-assessment.

clennan avatar clennan commented on May 19, 2024

You are trying to initialize the original MobileNet architecture with weights from MobileNet Aesthetic. The architecture for MobileNet Aesthetic differs from the original one, hence you won’t be able to use these weights.

Use the NIMA model class in src/handlers/model_builder.py to manually load the aesthetic weights.

from image-quality-assessment.

thisisashukla avatar thisisashukla commented on May 19, 2024

thanks for your response. However I am not able to figure out how to get a pretrained model from this repository. Can you provide the steps. It will be very helpful. Thanks.

from image-quality-assessment.

Related Issues (20)

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.