<jupyter_start><jupyter_text><jupyter_code>import tensorflow as tf
import numpy as np
resnet50 = tf.keras.applications.resnet50.ResNet50(weights='imagenet',include_top=False) # load model without classifier
x = tf.keras.preprocessing.image.load_img('elephant.jpeg',target_size=(224,224)) # load image
x = tf.keras.preprocessing.image.img_to_array(x) # convert img to numpy array
x = np.expand_dims(x, axis=0) # add a dimension
x = tf.keras.applications.resnet50.preprocess_input(x) # preprocess image for input to resnet
features = resnet50.predict(x) # get features
print(features.shape)<jupyter_output>WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
{'fraction_non_alphanumeric': 0.10244988864142539, 'fraction_numerical': 0.024498886414253896, 'mean_word_length': 6.817391304347826, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '121329', 'license': 'MIT', 'n_tokens_mistral': 305, 'n_tokens_neox': 289, 'n_words': 66, 'path': 'Keras_API/Transfer_learning_extract_features.ipynb', 'repo_name': 'shubham3063/tensorflow', 'size': '898'}