-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (22 loc) · 798 Bytes
/
test.py
File metadata and controls
28 lines (22 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import tensorflow as tf
import numpy as np
# physical_devices = tf.config.list_physical_devices('GPU')
# for device in physical_devices:
# tf.config.experimental.set_memory_growth(device, True)
IMG_SIZE = (160, 160)
model = tf.keras.models.load_model('./models/vgg/')
# filename = 'temp.jpg'
# image = tf.keras.preprocessing.image.load_img(
# filename, target_size=IMG_SIZE,interpolation='nearest',
# )
# input_arr = tf.keras.preprocessing.image.img_to_array(image)
# # input_arr = tf.keras.applications.vgg16.preprocess_input(input_arr)
# print(input_arr)
# input_arr = np.array([input_arr])
images_ds = tf.keras.preprocessing.image_dataset_from_directory(
'./server/imgs/',
seed=123,
image_size=IMG_SIZE,
batch_size=1)
predictions = model.predict(images_ds)
print(predictions)