概要
raspberry pi 3 でstretchやってみた。
tensorflowやってみた。
環境
Raspberry Pi 3 model B v1.2 element14
2017-09-07-raspbian-stretch
tensorflow1.3
インストール
設定
sudo nano /etc/dphys-swapfile
conf_swapsize=1024
サンプルコード
from tensorflow.contrib.keras.python.keras.applications.resnet50 import ResNet50
from tensorflow.contrib.keras.python.keras.preprocessing import image
from tensorflow.contrib.keras.python.keras.applications.imagenet_utils import preprocess_input, decode_predictions
import numpy as np
model = ResNet50(weights = 'imagenet')
img_path = 'p1m.jpg'
img = image.load_img(img_path, target_size = (224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis = 0)
x = preprocess_input(x)
preds = model.predict(x)
print ('Predicted:', decode_predictions(preds))
以上。