# Can I save only some VGG19's layers into a .H5 file?

I am training a deep-learning style transfer model with the pretrained-VGG19 CNN.

My aim is to use it in my Android app for personal purposes with Google Firebase Machine Learning Kit (which would host my .H5 model to make it usable by my Android app). The maximum .H5 model file's size allowed by Machine Learning Kit is: 8MB. However when I save the whole VGG19 model, I end with 80MB... So I can't use it.

Since only some layers of the VGG19 network are used in my style transfer program, is it possible to reduce the .H5's size by saving only those layers' weights, or something like that? Is there any other solution to my problem?

To save my VGG19 network as a .H5 file, I use the following Python command:

model.save('./style_transfer/st.h5', include_optimizer=False) , where model = vgg19.VGG19(input_tensor=input_tensor, weights='imagenet', include_top=False).

As you can see, I already don't include the optimizer in order to reduce the saved .H5's size.

model = Model(vgg19.input, vgg19.layers[8].output)

• Could you please confirm that the 5th layer is block5_conv2 (block5_conv2 is the highest layer I use in my transfer style program)? – JarsOfJam-Scheduler Oct 14 '19 at 10:40
• Well I think I must use the 5th layer (which would correspond to block5_conv2?). Indeed, I use the following layers: 'block5_conv2', 'block1_conv1', 'block2_conv1', 'block3_conv1', 'block4_conv1', 'block5_conv1' . Do you agree with me? :) – JarsOfJam-Scheduler Oct 14 '19 at 10:53