Repository: shobhitsrivastava-ds/ML-MT-WebApp Branch: master Commit: 15599ff5d353 Files: 61 Total size: 27.0 MB Directory structure: gitextract_zg3azadj/ ├── Canc_form.html ├── Diab_form.html ├── LICENSE ├── Procfile ├── README.md ├── alzh.py ├── app.py ├── cancer.csv ├── cancer.py ├── diabetes.csv ├── diabetes.html ├── diabetes.py ├── first_try.h5 ├── forms.py ├── heart.csv ├── heart.py ├── kidney.py ├── kidney_disease.csv ├── liver.py ├── model ├── model.pkl ├── model.py ├── model1 ├── model111.h5 ├── model2 ├── model22 ├── model3 ├── model4 ├── model_class ├── model_class.py ├── my_model.h5 ├── newmodel.h5 ├── py ├── requirements.txt ├── result ├── result.html ├── static/ │ ├── main.css │ └── model111.h5 ├── template/ │ ├── Alzh.html │ ├── about.html │ ├── cancer.html │ ├── demo.py │ ├── diabetes.html │ ├── finance.py │ ├── heart.html │ ├── home.html │ ├── index.html │ ├── index2.html │ ├── iss.py │ ├── kidney.html │ ├── liver.html │ ├── login.html │ ├── predict.html │ ├── predict1.html │ ├── register.html │ ├── result.1html │ ├── result.html │ ├── result1.html │ └── twitter_app.py ├── untitled.html └── untitled.py ================================================ FILE CONTENTS ================================================ ================================================ FILE: Canc_form.html ================================================ ================================================ FILE: Diab_form.html ================================================
This is one of major project of my undergraduate degree program.
Here, I have developed a disease predicting web app which using the concept of machine learning makes predictions about various diseases like Malaria, Pneumonia, Diabetes etc.
Cancer model = model
Diabetes model = model1
Heart model = model2
Liver model = model4
Kidney model = model3
Malaria model = model111.h5
Pneumonia model = my_model.h5
Kernal for Malaria model :https://www.kaggle.com/shobhit18th/malaria-cell
Kernal for Pneumonia model :https://www.kaggle.com/shobhit18th/keras-nn-x-ray-predict-pneumonia-86-54
Cancer : cancer.csv [In the repository]
Diabetes : diabetes.csv [In the repository]
Heart : heart.csv [In the repository]
Liver : https://www.kaggle.com/uciml/indian-liver-patient-records
Kidney : https://www.kaggle.com/mansoordaku/ckdisease
Malaria : https://www.kaggle.com/iarunava/cell-images-for-detecting-malaria
Pneumonia: https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia
Python ( 3.7 version)
Flask
OpenCV
Pandas
Numpy
HTML
CSS
The whole project is deployed on Heroku Cloud.
Here is the link where you can access the project live : https://myml-mtapp.herokuapp.com/
Thank you!
================================================ FILE: alzh.py ================================================ import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler import random from sklearn.model_selection import ShuffleSplit from sklearn.model_selection import cross_validate from imblearn.over_sampling import SMOTE from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.externals import joblib data=pd.read_csv("indian_liver_patient.csv") data=data.fillna(method="ffill") data.Gender=data.Gender.map({"Female":1,"Male":0}) data["Dataset"]=data["Dataset"].map({1:0,2:1}) np.random.shuffle(data.values) print(data.columns) target=data["Dataset"] source=data.drop(["Dataset"],axis=1) sm=SMOTE() sc=StandardScaler() lr=LogisticRegression() source=sc.fit_transform(source) X_train,X_test,y_train,y_test= train_test_split(source,target,test_size=0.01) X_train, y_train=sm.fit_sample(X_train,y_train) cv=cross_validate(lr,X_train,y_train,cv=10) print(cv) joblib.dump(lr,"model4") ================================================ FILE: app.py ================================================ #Important Modules from flask import Flask,render_template, url_for ,flash , redirect #from forms import RegistrationForm, LoginForm from sklearn.externals import joblib from flask import request import numpy as np import tensorflow #from keras.layers import Conv2D, MaxPooling2D, Dense, Dropout, Input, Flatten, SeparableConv2D #from flask_sqlalchemy import SQLAlchemy #from model_class import DiabetesCheck, CancerCheck #from tensorflow.keras.models import Sequential #from tensorflow.keras.layers import Conv2D, MaxPooling2D, Dense, Dropout, Input, Flatten, SeparableConv2D #from tensorflow.keras.layers import GlobalMaxPooling2D, Activation #from tensorflow.keras.layers.normalization import BatchNormalization #from tensorflow.keras.layers.merge import Concatenate #from tensorflow.keras.models import Model import os from flask import send_from_directory from tensorflow.keras.models import load_model from tensorflow.keras.preprocessing import image import tensorflow as tf #from this import SQLAlchemy app=Flask(__name__,template_folder='template') # RELATED TO THE SQL DATABASE app.config['SECRET_KEY'] = '5791628bb0b13ce0c676dfde280ba245' #app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///site.db" #db=SQLAlchemy(app) #from model import User,Post #////////////////////////////////////////////////////////// dir_path = os.path.dirname(os.path.realpath(__file__)) # UPLOAD_FOLDER = dir_path + '/uploads' # STATIC_FOLDER = dir_path + '/static' UPLOAD_FOLDER = 'uploads' STATIC_FOLDER = 'static' #graph = tf.get_default_graph() #with graph.as_default():; from tensorflow.keras.models import load_model model = load_model('model111.h5') model222=load_model("my_model.h5") #FOR THE FIRST MODEL # call model to predict an image def api(full_path): data = image.load_img(full_path, target_size=(50, 50, 3)) data = np.expand_dims(data, axis=0) data = data * 1.0 / 255 #with graph.as_default(): predicted = model.predict(data) return predicted #FOR THE SECOND MODEL def api1(full_path): data = image.load_img(full_path, target_size=(64, 64, 3)) data = np.expand_dims(data, axis=0) data = data * 1.0 / 255 #with graph.as_default(): predicted = model222.predict(data) return predicted # home page #@app.route('/') #def home(): # return render_template('index.html') # procesing uploaded file and predict it @app.route('/upload', methods=['POST','GET']) def upload_file(): if request.method == 'GET': return render_template('index.html') else: try: file = request.files['image'] full_name = os.path.join(UPLOAD_FOLDER, file.filename) file.save(full_name) indices = {0: 'PARASITIC', 1: 'Uninfected', 2: 'Invasive carcinomar', 3: 'Normal'} result = api(full_name) print(result) predicted_class = np.asscalar(np.argmax(result, axis=1)) accuracy = round(result[0][predicted_class] * 100, 2) label = indices[predicted_class] return render_template('predict.html', image_file_name = file.filename, label = label, accuracy = accuracy) except: flash("Please select the image first !!", "danger") return redirect(url_for("Malaria")) @app.route('/upload11', methods=['POST','GET']) def upload11_file(): if request.method == 'GET': return render_template('index2.html') else: try: file = request.files['image'] full_name = os.path.join(UPLOAD_FOLDER, file.filename) file.save(full_name) indices = {0: 'Normal', 1: 'Pneumonia'} result = api1(full_name) if(result>50): label= indices[1] accuracy= result else: label= indices[0] accuracy= 100-result return render_template('predict1.html', image_file_name = file.filename, label = label, accuracy = accuracy) except: flash("Please select the image first !!", "danger") return redirect(url_for("Pneumonia")) @app.route('/uploads/