Example #1
0
def load_model(file_path):
    """ Load a pysster.Model object.

    Parameters
    ----------
    file_path : str
       A file containing a pickled pysster.Model object (file_path.h5 must also exist, see save_model()).

    Returns
    -------
    model : pysster.Model
        A Model object.
    """
    from pysster.Model import Model
    from keras.models import load_model as load_keras
    if not os.path.exists(file_path):
        raise RuntimeError("Path not found.")
    if not os.path.exists("{}.h5".format(file_path)):
        raise RuntimeError("HDF5 file not found.")
    with gzip.open(file_path, "rb") as handle:
        params = pickle.load(handle)
    model = Model(params, None)
    model.model = load_keras("{}.h5".format(file_path))
    return model
Example #2
0
from keras.models import load_keras
from scikit-image import transform
import numpy as np
from keras.preprocessing.image import load_img
from flask import Flask, request, render_template , jsonify

app = Flask(__name__)

covid =  load_keras('Covid19.h5')
def Load_Images(img):
  pred_img = np.array(img).astype('float32')/255
  pred_img = transform.resize(pred_img,(200,200,3))
  pred_img = np.expand_dims(pred_img,axis=0)
  return pred_img

@app.route('/')
def index():
    print('Working')
    


@app.route('/CovidRequest', methods=['POST'])
def post():
   imagefile = request.files.get('imagefile', '')
   Image_to_pred = load_img(imagefile)
   Image_to_pred = Load_Images(Image_to_pred)
   prediction = np.argmax(covid.predict(Image_to_pred))
   if (prediction == 0):
       return jsonify({'prediction':'Non Informative Data'})
   elif (prediction == 1):
       return jsonify({'prediction':'Negative'})