Commit e5a70592 authored by Chamodi Mandakini's avatar Chamodi Mandakini

Routes

parent d6c34c3c
from flask import render_template, request
from app import app
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import os
import cv2
from pathlib import Path
import pickle
import tensorflow as tf
import sklearn
@app.route('/skincancer')
def skincancer():
return render_template('skincancer.html')
def predict2(img):
model = tf.keras.models.load_model('modelNew.h5')
pic = []
img = cv2.resize(img, (100, 100))
if img.shape[2] == 1:
img = np.dstack([img, img, img])
img = np.array(img)
img = img/255
# label = to_categorical(0, num_classes=2)
pic.append(img)
# pic_labels.append(pneu)
pic1 = np.array(pic)
a = model.predict(pic1)
print(a.argmax())
predicts = a.argmax()
predicts
if predicts == 0:
return "Melanocytic nevi"
elif predicts == 1:
return "Melanoma"
elif predicts == 2:
return "Benign keratosis-like lesions"
elif predicts == 3:
return "Basal cell carcinoma"
elif predicts == 4:
return "Actinic keratoses"
elif predicts == 5:
return "Vascular lesions"
else:
return "Dermatofibroma"
@app.route('/process_image_skin', methods=['POST'])
def process_image_skin():
if request.method == 'POST':
file = request.files['file']
img_bytes = file.read() # Read image data as bytes
# Convert bytes to OpenCV image
img = cv2.imdecode(np.frombuffer(img_bytes, np.uint8), -1)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # Convert BGR to RGB
prediction = predict2(img) # Make prediction using img
return render_template('results.html', result=prediction)
return 'File uploaded successfully!'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment