Skip to Content
Mastering Computer Vision with TensorFlow 2.x
book

Mastering Computer Vision with TensorFlow 2.x

by Krishnendu Kar
May 2020
Beginner to intermediate
430 pages
10h 39m
English
Packt Publishing
Content preview from Mastering Computer Vision with TensorFlow 2.x

Visual search code and explanation

In this section, we will explain the TensorFlow code for visual search and its functions:

  1. First, we will specify a folder for the uploaded image (there are three folders, which we switch for each image type). Note the images shown here are just examples; your images might be different:
#img_path = '/home/…/visual_search/ test/bed/bed1.jpg'#img_path ='/home/…/visual_search/test/chair/chair1.jpg'#img_path ='/home/…/visual_search/test/sofa/sofa1.jpg'
  1. Then, we will upload the image, convert the image to an array, and preprocess the image similarly to what we did before:
img = image.load_img(img_path, target_size=(224, 224))img_data = image.img_to_array(img)img_data = np.expand_dims(img_data, axis=0)img_data ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Computer Vision with TensorFlow 2

Hands-On Computer Vision with TensorFlow 2

Benjamin Planche, Eliot Andres

Publisher Resources

ISBN: 9781838827069Supplemental Content