Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/enrignagna/CovidNN into main
Browse files Browse the repository at this point in the history
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
enrignagna committed Jan 10, 2021
2 parents 84ccdc1 + efa8131 commit 540388a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/image_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from tensorflow import keras
from keras.models import Model
import matplotlib.pyplot as plt
import os
import random


#funzione che restituisce un immagine nel formato corretto per la prediction.
def get_img_array(img_path, size):
def get_img_array(img_path, size = (200, 200)):
image = keras.preprocessing.image.load_img(img_path, target_size=size)
image = keras.preprocessing.image.img_to_array(image)
# trasformazione in range [0, 1]
Expand All @@ -15,6 +17,10 @@ def get_img_array(img_path, size):
image = np.expand_dims(image, axis=0)
return image

#funzione che restituisce una immagine casuale all'interno di una cartella.
def get_random_image_by_path(path):
return [path + name for name in os.listdir(path)][random.randint(0, len(os.listdir(path)))]


#funzione per la visualizzazione delle immagini in un array e dei rispettivi titoli.
def vis_images(images, titles, n_columns):
Expand Down

0 comments on commit 540388a

Please sign in to comment.