Example #1
0
APP_SITE = ""
UPLOAD_FOLDER = 'static/upload/'
ALLOWED_EXTENSIONS = ['jpg']
UPLOAD_ID = 0  # image
AUDIO_ID = 0  # audio

BATCH_SIZE = 64
BUFFER_SIZE = 1000
embedding_dim = 256
units = 512
top_k = 5000
vocab_size = top_k + 1
max_length = 46

tokenizer = jload('./model_weights/tokenizer.pkl')
print("[0.-]. Tokenizer (words analyser) loaded.")

# Build inception-v3 model
image_model = tf.keras.models.load_model("model_weights/image_model_pre.h5")
new_input = image_model.input  # Get the input of the model-return a tensor
hidden_layer = image_model.layers[
    -1].output  # hidden_layer is the output of the last layer of iv3
print("[0.-]. Inception-V3 model loaded.")

image_features_extract_model = tf.keras.Model(inputs=new_input,
                                              outputs=hidden_layer)
""" program function & class """


def load_image(image_path):
Example #2
0
def load(filename):
    from joblib import load as jload
    return jload(filename)
import matplotlib.pyplot as plt

sys.path.append(".")
#'
#' We can then load our predictor, features and outcome and finally
#' some extra information that we will use to interpret the predictor
#' behaviour.
shared_dir = Path("/usr/share/data")
regressor_file = str(shared_dir / "models/regressor.joblib")
features_file_sparse = str(shared_dir / "data/processed/test_set/X.npz")
features_file_dense = str(shared_dir / "data/processed/test_set/X.npy")
outcome_file = str(shared_dir / "data/processed/test_set/y.npy")
feature_info_file = str(shared_dir /
                        "data/processed/test_set/feature_info.pkl")

regressor = jload(regressor_file)

features_path_sparse = Path(features_file_sparse)
if features_path_sparse.exists():
    X = load_npz(features_file_sparse).todense()
else:
    X = np.load(features_file_dense)

y = np.load(outcome_file)

with open(feature_info_file, 'rb') as ifh:
    feature_info = pload(ifh)
#'
#'
#' # Prediction performance
#'