awentzonline / image-analogies

Generate image analogies using neural matching and blending.
MIT License
3.52k stars 282 forks source link

Fix for issue #39. #48

Open zkneupper opened 6 years ago

zkneupper commented 6 years ago

This pull request is intended to fix issue #39 (ValueError: Layer weight shape (3, 3, 3, 64) not compatible with provided weight shape (64, 3, 3, 3) ) and to make the image-analogies package compatible with keras versions 2.0.0 and above.

I only made changes to the vgg16.py file.

The newly added code does the following:

  1. It checks if your version of keras is version '2.0.0' or above;

  2. If your version of keras is version '2.0.0' or above, then it (1) converts each element x of the list 'weights' into a numpy array, (2) transposes each of those arrays, and (3) saves the list of transposed arrays back to the 'weights' list.

        weights_T = [np.array(x).T for x in weights]
        weights = weights_T            
  3. If your version of keras is version not '2.0.0' or above, the 'weights' list is left unchanged; the elements of 'weights' are left untransposed.

Transposing the weights is necessary for compatibility with keras is version '2.0.0' or above.

The code should still be compatible with earlier versions of keras before version '2.0.0'.

rharriso commented 6 years ago

Thanks! curled this into my installed package and started working just fine!

mike-truk commented 6 years ago

This worked for me as well -- many thanks!

ljslj commented 5 years ago

图片 why i run the make_image_analoy.py,the result is that, i don't know how to solve it? thanks. 图片