Last active
June 4, 2019 21:07
-
-
Save frogermcs/9651031adcf0cf96483de062cbedb293 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Prepare images for TensorFlow requirements | |
| #Convert to expected type: float | |
| img_laptop_tf = np.array(img_laptop).astype(np.float32) | |
| # Setup expected input shape: [1,224,224,3] | |
| img_laptop_tf = np.expand_dims(img_laptop_tf, axis = 0) | |
| # Convert to expected values ranges: [0, 1] | |
| img_laptop_tf = (1.0/255.0) * img_laptop_tf | |
| print( 'Image shape:', img_laptop_tf.shape) | |
| print( 'First few values: ', img_laptop_tf.flatten()[0:4], 'max value: ', np.amax(img_laptop_tf)) | |
| # >> Image shape: (1, 224, 224, 3) | |
| # >> First few values: [0.8078432 0.78823537 0.7686275 0.7960785 ] max value: 1.0 | |
| # The same for golden retriever img | |
| img_golden_tf = np.array(img_golden).astype(np.float32) | |
| img_golden_tf = np.expand_dims(img_golden_tf, axis = 0) | |
| img_golden_tf = (1.0/255.0) * img_golden_tf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment