File size: 268 Bytes
9bdc3a8
 
 
 
 
 
d5b9cd0
 
 
 
b9731dc
9bdc3a8
1
2
3
4
5
6
7
8
9
10
11
12
13
import tensorflow as tf
import numpy as np
from PIL import Image


def preprocess_image(image_file):
    img = Image.open(image_file).convert("RGB")
    img = img.resize((256, 256))
    img = np.array(img) / 255.0
    img = np.expand_dims(img, axis=0)
    return img