# Using image features¶

It is possible to handle images using DSS deep learning. To do so, you must store your images in a managed folder (See Managed folders).

Then, you need to indicate in the dataset that will be used for running the analysis the location of your images. Create a new column containing the relative path of each image inside the managed folder. Then, in the “Features handling” tab of the analysis, select “Image” as type for this column.

You need to precise the managed folder where the images are stored in Image location, and to do a Custom preprocessing that looks like:

from keras.preprocessing.image import img_to_array, load_img

# Custom image preprocessing function.
# Must return a numpy ndarray representing the image.
#  - image_file is a file like object
def preprocess_image(image_file):
array = img_to_array(img)
array = array / 255
return array


where we see that the output for an image has a (197, 197, 3) shape. Then, this outptut is sent to a image_path_preprocessed input (if the name of the original column was image_path), so the corresponding input in the model should look like:

input_img = Input(shape=(197, 197, 3), name="image_path_preprocessed")


See Deep learning for image classification for a step-by-step example of this in practice.

## Scoring images¶

When using a saved model that has image feature(s) for scoring, you can provide in the corresponding column(s):

• the relative path to the image, which must be stored in the same managed folder that was used for training
• a string that is the Base64 representation of the image file.