Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 1.52 KB

044.md

File metadata and controls

38 lines (24 loc) · 1.52 KB

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:

  1. Use models from TensorFlow Hub with tf.keras
  2. Use an image classification model from TensorFlow Hub
  3. 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.

Toggle code
classifier_model ="https://hub.tensorflow.google.cn/google/tf2-preview/mobilenet_v2/classification/4"