In [0]:
from __future__ import print_function
from IPython import display
!git clone https://github.com/tensorflow/tpu
display.clear_output()
# setup path
import sys
sys.path.append('/content/tpu/models/official/efficientnet')
sys.path.append('/content/tpu/models/common')
model_name = 'efficientnet-b0' #@param
In [0]:
!wget https://upload.wikimedia.org/wikipedia/commons/f/fe/Giant_Panda_in_Beijing_Zoo_1.JPG -O panda.jpg
image_file = 'panda.jpg'
display.display(display.Image(image_file))
In [0]:
import eval_ckpt_main as eval_ckpt
import tensorflow.compat.v1 as tf
!wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientnet/ckpts/{model_name}.tar.gz -O {model_name}.tar.gz
!tar xf {model_name}.tar.gz
ckpt_dir = model_name
!wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientnet/eval_data/labels_map.txt -O labels_map.txt
labels_map_file = 'labels_map.txt'
image_files = [image_file]
eval_driver = eval_ckpt.get_eval_driver(model_name)
pred_idx, pred_prob = eval_driver.eval_example_images(
ckpt_dir, image_files, labels_map_file)