import numpy as np
from google.colab import files
from tensorflow.keras.preprocessing import image
uploaded = files.upload()
for fn in uploaded.keys() :
path = '/content/' + fn
img = image.load_img(path, target_size=(300,300))
x = image.img_to_array(img) / 255.0
print(x)
print(x.shape)
x = np.expand_dims(x, axis = 0)
print(x.shape)
images = np.vstack( [x] )
classes = model.predict( images, batch_size = 10 )
print(classes)
if classes[0] > 0.5 :
print(fn + " is a human")
else :
print(fn + " is a horse")
'파이썬 > 텐서플로우' 카테고리의 다른 글
이미지 파일을 학습데이터로 바꿔주는 ImageDataGenerator (0) | 2022.12.30 |
---|---|
Tensorflow CNN 이미지분류 모델링하기: (0) | 2022.12.30 |
tf.keras.utils.to_categorical 원핫 인코딩으로 바꾸기 (0) | 2022.12.29 |
Tensorflow : MNIST 손글씨 숫자예측 ANN으로 모델링 하기 (0) | 2022.12.29 |
완성한 인공지능 model , 네트워크 , weight 저장 하는 방법 (0) | 2022.12.29 |