mirror of
https://github.com/Estom/notes.git
synced 2026-02-09 13:27:09 +08:00
1.5 KiB
1.5 KiB
Transfer learning with TensorFlow Hub
原文: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
Setup
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
An ImageNet classifier
You'll start by using a pretrained classifer model to take an image and predict what it's an image of - no training required!
Download the classifier
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"