Created
November 10, 2019 13:04
-
-
Save Manikanta-Munnangi/91d476758f94040c32213a2d22ab7d22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/predict', methods=['GET', 'POST']) | |
def upload(): | |
# Get the file from post request | |
if request.method == 'POST': | |
# Save the file to ./uploads | |
f = request.files['image'] | |
# path to save image file | |
basepath = os.path.dirname(__file__) | |
img_path = os.path.join( | |
basepath, 'uploads', secure_filename(f.filename)) | |
f.save(img_path)# save image to uploads folder. | |
# one class clasification model | |
leaf = leaf_predict(img_path) | |
# condition if leaf was pass for predict | |
if leaf == "leaf": | |
# Make prediction | |
preds = model_predict(img_path) | |
rows = info() | |
res = np.asarray(rows[preds]) | |
value = (preds == int(res[0])) | |
if value: | |
ID, Disease, Pathogen, Symptoms, Management = [i for i in res] | |
return render_template('result.html', Pathogen=Pathogen, Symptoms=Symptoms, Management=Management, result=Disease, filee=f.filename) | |
else: | |
return render_template('index.html', Error="ERROR: UPLOADED IMAGE IS NOT A LEAF (OR) MORE LEAVES IN ONE IMAGE") | |
# return result | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment