原文:https://tensorflow.google.cn/tutorials/images/transfer_learning_with_hub
TensorFlow Hub is a repository of pre-trained TensorFlow models.
This tutorial demonstrates how to:
- Use models from TensorFlow Hub with
tf.keras
- Use an image classification model from TensorFlow Hub
- Do simple transfer learning to fine-tune a model for your own image classes
import numpy as np
import time
import PIL.Image as Image
import matplotlib.pylab as plt
import tensorflow as tf
import tensorflow_hub as hub
You'll start by using a pretrained classifer model to take an image and predict what it's an image of - no training required!
Use hub.KerasLayer
to load a MobileNetV2 model from TensorFlow Hub. Any compatible image classifier model from hub.tensorflow.google.cn will work here.
classifier_model ="https://hub.tensorflow.google.cn/google/tf2-preview/mobilenet_v2/classification/4"