Skip to content

Commit

Permalink
Merge pull request #304 from sryu1/master
Browse files Browse the repository at this point in the history
Update keras.md
  • Loading branch information
HalfdanJ authored Oct 27, 2022
2 parents 3c52eb5 + b811a39 commit 090986f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions snippets/markdown/image/tensorflow/keras.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```python
from keras.models import load_model
from PIL import Image, ImageOps
from PIL import Image, ImageOps #Install pillow instead of PIL
import numpy as np

# Disable scientific notation for clarity
Expand All @@ -23,7 +23,7 @@ image = Image.open('<IMAGE_PATH>').convert('RGB')
#resize the image to a 224x224 with the same strategy as in TM2:
#resizing the image to be at least 224x224 and then cropping from the center
size = (224, 224)
image = ImageOps.fit(image, size, Image.ANTIALIAS)
image = ImageOps.fit(image, size, Image.Resampling.LANCZOS)

#turn the image into a numpy array
image_array = np.asarray(image)
Expand All @@ -40,6 +40,6 @@ index = np.argmax(prediction)
class_name = class_names[index]
confidence_score = prediction[0][index]

print('Class: ', class_name, end='')
print('Confidence Score: ', confidence_score)
print('Class:', class_name, end='')
print('Confidence score:', confidence_score)
```

0 comments on commit 090986f

Please sign in to comment.