Skip to content

Instantly share code, notes, and snippets.

@ura14h
Created April 24, 2018 00:46
Show Gist options
  • Save ura14h/c91f1dafd30cc029f58cf0bb5e74386c to your computer and use it in GitHub Desktop.
Save ura14h/c91f1dafd30cc029f58cf0bb5e74386c to your computer and use it in GitHub Desktop.
How to install TensorFlow and Keras on Windows 10
See also: http://starpentagon.net/analytics/tensorflow_cpu_mode_windows_install/
How to install TensorFlow and Keras on Windows 10
* Install... https://repo.anaconda.com/archive/Anaconda3-5.1.0-Windows-x86_64.exe
* Open... 'Anaconda3' > 'Anaconda Prompt'
* Type commands...
---
(base) > conda create -n tensorflow pip python=3.6
(base) > conda activate tensorflow
(tensorflow) > python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, world')
>>> sess = tf.Session()
>>> print(sess.run(hello))
>>> quit()
(tensorflow) > python -m pip install --upgrade pip
(tensorflow) > pip install keras
(tensorflow) > conda install notebook ipykernel
(tensorflow) > ipython kernel install --user --name tensorflow
(tensorflow) > pip install h5py pillow
---
* Prepare Image...
* Open Jupyter notebook...
* Open 'New' > 'tensorflow'
* Type a script...
---
from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
model = ResNet50(weights='imagenet')
img_path = 'C:/free/profile.png'
img = image.load_img(img_path, target_size=(224, 224))
img
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, top=3)[0])
---
* Run the script...
Thanks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment