Created
September 22, 2019 19:50
-
-
Save GiulioCMSanto/cbeab60f5fe981d67738998c2643d9f4 to your computer and use it in GitHub Desktop.
Classifying Flowers With Transfer Learning
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
def process_image(image): | |
''' Scales, crops, and normalizes a PIL image for a PyTorch model, | |
returns an Numpy array | |
''' | |
# TODO: Process a PIL image for use in a PyTorch model | |
#Loading image with PIL (https://pillow.readthedocs.io/en/latest/reference/Image.html) | |
im = Image.open(image) | |
#Notice: te very same transformation applied to the test/validation data will be applied here | |
process = transforms.Compose([transforms.Resize(256), | |
transforms.CenterCrop(224), | |
transforms.ToTensor(), | |
transforms.Normalize([0.485, 0.456, 0.406], | |
[0.229, 0.224, 0.225])]) | |
return process(im) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment