├── .gitignore ├── Alcohol-Quality-Checker ├── Alcohol-Quality.ipynb ├── Procfile ├── README-Resources │ ├── AlcoholQuality.gif │ ├── AlcoholQuality.jpg │ ├── Screenshot (105).png │ └── Screenshot (106).png ├── README.md ├── alcohol-quality-data.csv ├── app1.py ├── model.pkl ├── model.py ├── request.py ├── requirements.txt ├── static │ └── css │ │ └── formc.css └── templates │ └── form.html ├── Cloths-AccessoryClassification using DL ├── Cloths_Predictions │ ├── __pycache__ │ │ └── predictions.cpython-36.pyc │ └── predictions.py ├── README.md ├── Readme_Images │ ├── Fashion-Model.png │ ├── VGG-models.png │ ├── cloth-classification.gif │ └── vgg16-neural-network.jpg ├── app.py ├── requirements.txt ├── static │ ├── css │ │ └── main.css │ └── js │ │ └── main.js ├── templates │ ├── base.html │ └── index.html └── uploads │ └── jacket1.jpg ├── Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master ├── CLTP Analysis Output │ ├── ACT.png │ ├── Dep.png │ ├── Details of Variables.png │ ├── Employed_FeMale_People vs Policy_type.png │ ├── Employed_Male_People vs Policy_type.png │ ├── Employed_People vs Policy_type.png │ ├── EmploymentStatus vs Policy_type.png │ ├── GNU license.jpg │ ├── Gender vs Policy_type.png │ ├── MIT license.jpg │ ├── Marital_status vs Policy_type.png │ ├── Married_FeMale_People vs Policy_type.png │ ├── Married_Male_People vs Policy_type.png │ ├── Married_People vs Policy_type.png │ ├── OLS Rgression Results.png │ ├── Response variable Distribution.png │ ├── Screenshot (111).png │ ├── UnEmployed_FeMale_People vs Policy_type.png │ ├── UnEmployed_Male_People vs Policy_type.png │ ├── UnEmployed_People vs Policy_type.png │ ├── UnMarried_People vs Policy_type.png │ ├── bar1 total cliam vs education.png │ ├── bar2 total cliam vs Gender.png │ ├── bar3 total cliam vs empstatus.png │ ├── clt vs tca scatterplot empstatus.png │ ├── clt vs tca scatterplot maritalstatus.png │ ├── clt vs tca scatterplot.png │ ├── clv.jpg │ ├── clvout.png │ ├── fit.png │ ├── hist 1.png │ ├── hist 2.png │ ├── hist 3.png │ └── res.png ├── Customer LifeTime Value.ipynb ├── Customer Lifetime Value (Exploratory Data Analysis).py ├── Feature Engineering and Model Building.py ├── LICENSE ├── Procfile ├── Procfile.txt ├── README.md ├── RF_KModel.pkl ├── app.py ├── requirements.txt ├── static │ └── cover.jpg └── templates │ ├── css.html │ ├── img_girl.jpg │ └── index.html ├── Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master ├── Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master │ ├── LICENSE │ ├── Procfile │ ├── README.md │ ├── app.py │ ├── random_forest_hr_model.sav │ ├── requirements.txt │ ├── static │ │ ├── ATTT.png │ │ ├── At.png │ │ └── attta.png │ └── templates │ │ ├── gg5.jpg │ │ ├── home.html │ │ ├── logo.jpg │ │ ├── output_103_1.png │ │ ├── output_110_1.png │ │ ├── output_17_1.png │ │ ├── output_25_1.png │ │ ├── output_30_1.png │ │ ├── output_34_1.png │ │ ├── output_36_1.png │ │ ├── output_38_1.png │ │ ├── output_40_1.png │ │ ├── output_43_1.png │ │ ├── output_46_1.png │ │ ├── output_48_1.png │ │ ├── output_50_1.png │ │ ├── output_52_1.png │ │ ├── output_55_1.png │ │ ├── output_57_1.png │ │ ├── output_60_1.png │ │ ├── output_63_0.png │ │ ├── output_65_0.png │ │ ├── output_72_1.png │ │ ├── output_96_0.png │ │ ├── output_99_1.png │ │ └── prob.html ├── LICENSE ├── Procfile ├── README.md ├── app.py ├── random_forest_hr_model.sav ├── requirements.txt ├── static │ ├── ATTT.png │ ├── At.png │ └── attta.png └── templates │ ├── gg5.jpg │ ├── home.html │ ├── logo.jpg │ ├── output_103_1.png │ ├── output_110_1.png │ ├── output_17_1.png │ ├── output_25_1.png │ ├── output_30_1.png │ ├── output_34_1.png │ ├── output_36_1.png │ ├── output_38_1.png │ ├── output_40_1.png │ ├── output_43_1.png │ ├── output_46_1.png │ ├── output_48_1.png │ ├── output_50_1.png │ ├── output_52_1.png │ ├── output_55_1.png │ ├── output_57_1.png │ ├── output_60_1.png │ ├── output_63_0.png │ ├── output_65_0.png │ ├── output_72_1.png │ ├── output_96_0.png │ ├── output_99_1.png │ └── prob.html ├── FlightPrice_Prediction ├── Flightprice_Predictions.ipynb ├── Procfile ├── Test.xlsx ├── Train.xlsx ├── app.py ├── requirements.txt ├── static │ └── css │ │ └── styles.css └── templates │ └── home.html ├── Heat Exchanger Price Prediction ├── CAPSTONE.pptx ├── Dashboard.twb ├── Heat Exchanger Price Prediction.pdf ├── Heat Exchanger Price Prediction.py └── dataset1.xlsx ├── IPL-Score-Prediction-with-Deployment ├── LICENSE ├── Procfile ├── Procfile.txt ├── RE.md ├── README.md ├── app.py ├── lr-model.pkl ├── requirements.txt ├── static │ ├── IPL Predictor Output.gif │ ├── P4.jpg │ ├── ipl-favicon.ico │ ├── ipl.jpeg │ ├── p1.jpg │ ├── p2.png │ ├── p3.png │ └── styles.css └── templates │ ├── index.html │ └── result.html ├── LICENSE ├── Leaf-Disease-Classifier-master ├── disease_classifier.ipynb ├── how_to_train │ ├── README.md │ ├── Res50_script.ipynb │ └── rename.py ├── images │ ├── Flow diagram.png │ ├── applescab.jpg │ ├── arrow.png │ ├── block_diagram.png │ ├── leaf_after_yolo.jpeg │ ├── leaf_before_yolo.jpeg │ ├── resnetACC.png │ └── subClasses.png └── readME.md ├── Loan-Default-Prediction ├── Loan_Prediction_Model (1).html ├── Loan_Prediction_Model (1).ipynb └── train.zip ├── Logo recognition from images ├── LICENSE.txt ├── README.md ├── config.py ├── detect_results │ ├── detect_result_029.png │ ├── detect_result_049.png │ ├── detect_result_055.png │ ├── detect_result_056.png │ ├── detect_result_082.png │ └── detect_result_351.png ├── flickr_logos_27_label_map.pbtxt ├── gen_tfrecord.py ├── gen_tfrecord_logos32plus.py ├── logo_detection.py ├── logos32plus_label_map.pbtxt ├── preproc_annot.py ├── query_set_results │ ├── 2180367311_Google.png │ ├── 3198284747_texaco.png │ ├── 3489964654_Intel.png │ ├── 3666600356_Cocacola.png │ ├── 388978947_BMW.png │ ├── 3907703753_Fedex.png │ ├── 401253895_BMW.png │ ├── 4273898682_DHL.png │ ├── 4288066623_Unicef.png │ └── 6651198_McDonalds.png ├── ssd_inception_v2_coco.config └── ssd_inception_v2_coco_logos32plus.config ├── Procfile ├── README.md ├── Real-time-ML-Project-master ├── README.md └── assets │ ├── first.txt │ └── industry.png ├── Restaurant Review Analyser using NLP ├── Procfile ├── Restaurant Review's Sentiment.ipynb ├── app.py ├── cv-transform.pkl ├── requirements.txt ├── restaurant_model.pkl ├── static │ ├── 2.jpg │ ├── favicon.ico │ ├── food.ico │ ├── negative-review.webp │ ├── positive-review.webp │ └── styles.css └── templates │ ├── index.html │ └── result.html ├── app.py ├── awesome production machine learning ├── LICENSE ├── README.md ├── _config.yml └── images │ ├── awesome.svg │ ├── guidelines.jpg │ ├── mleng.png │ ├── mlops1.png │ └── video.png ├── car data.csv ├── carpredicition.ipynb ├── face_unlock ├── README.md ├── dataset │ └── bala venkatesh │ │ ├── 0.jpg │ │ ├── 1.jpg │ │ ├── 10.jpg │ │ ├── 11.jpg │ │ ├── 12.jpg │ │ ├── 13.jpg │ │ ├── 14.jpg │ │ ├── 15.jpg │ │ ├── 16.jpg │ │ ├── 17.jpg │ │ ├── 18.jpg │ │ ├── 19.jpg │ │ ├── 2.jpg │ │ ├── 20.jpg │ │ ├── 21.jpg │ │ ├── 22.jpg │ │ ├── 23.jpg │ │ ├── 24.jpg │ │ ├── 25.jpg │ │ ├── 26.jpg │ │ ├── 27.jpg │ │ ├── 28.jpg │ │ ├── 29.jpg │ │ ├── 3.jpg │ │ ├── 30.jpg │ │ ├── 31.jpg │ │ ├── 32.jpg │ │ ├── 33.jpg │ │ ├── 34.jpg │ │ ├── 35.jpg │ │ ├── 36.jpg │ │ ├── 37.jpg │ │ ├── 38.jpg │ │ ├── 39.jpg │ │ ├── 4.jpg │ │ ├── 40.jpg │ │ ├── 41.jpg │ │ ├── 42.jpg │ │ ├── 43.jpg │ │ ├── 44.jpg │ │ ├── 45.jpg │ │ ├── 46.jpg │ │ ├── 47.jpg │ │ ├── 48.jpg │ │ ├── 49.jpg │ │ ├── 5.jpg │ │ ├── 50.jpg │ │ ├── 51.jpg │ │ ├── 6.jpg │ │ ├── 7.jpg │ │ ├── 8.jpg │ │ └── 9.jpg ├── demo.gif ├── face_generate.py ├── face_train.py ├── face_unlock.py └── trained_knn_model.clf ├── main.py ├── random_forest_regression_model.pkl └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app1:app 2 | 3 | -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/README-Resources/AlcoholQuality.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Alcohol-Quality-Checker/README-Resources/AlcoholQuality.gif -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/README-Resources/AlcoholQuality.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Alcohol-Quality-Checker/README-Resources/AlcoholQuality.jpg -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/README-Resources/Screenshot (105).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Alcohol-Quality-Checker/README-Resources/Screenshot (105).png -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/README-Resources/Screenshot (106).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Alcohol-Quality-Checker/README-Resources/Screenshot (106).png -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/README.md: -------------------------------------------------------------------------------- 1 | # **Alcohol-Quality-Checker** 2 | ## Predicting Quality of Alcohol 3 | 4 | 5 | 6 | --- 7 | 8 | ### **Web APP on Heroku** 9 | 10 | 11 | **[The Project on Heroku](https://alcoholqualitychecker.herokuapp.com/)** 12 | 13 | --- 14 | ## The Dataset 15 | ![](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Alcohol-Quality-Checker/README-Resources/Screenshot%20(105).png) 16 | ### **[Dataset](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Alcohol-Quality-Checker/alcohol-quality-data.csv)** 17 | --- 18 | ## **Overview** 19 | * The Dataset has **'density'**, **'pH'**, **'sulphates'**, **'alcohol'**, **'Quality_Category'** columns. It has **4898 rows** and **5 columns**. 20 | * From the Dataset, we have to predict the **Quality of Alcohol**: **"High"** or **"Low"**. 21 | * **ExtraTreesClassifier** has been used for Feature Selection. 22 | * I have applied **Artificial Neural Network**, **Random Forest**, **Decision Tree**, **K-NN**, **Naive bayes classification** and **SVM** algorithms but at the end, **KNN** gave better results. 23 | 24 | --- 25 | ## **Machine Learning Pipelines:** 26 | --- 27 | ### **1> Feature Engineering:** 28 | 29 | **a> Handling Missing Values:** 30 | * Here, In this data, there is no requirement of handling missing values because already it is a complete dataset. 31 | 32 | **b> Feature Encoding:** 33 | * In this data, we do not have much categorical columns except output column. 34 | 35 | **c> Feature Scaling & Feature Transformation:** 36 | * For alogorithms like K-NN , K means , all neural network etc are based on some distance equations. Hence, they require Scaling. 37 | * But, when i applied it, there was not much of a difference in the accuracy so there was no meaning of using it. Because not everytime,we have to use scaling or transformation. * Transformation also seemed not required for this data because the distribution is almost gaussian for the required columns. 38 | --- 39 | ### **2> Feature Selection:** 40 | * There are various techniques for this but here i have used **ExtraTressClassifier**. For, this Project ExtraTressClassifier showed **2 columns** as most important **"sulfate"** and **"Alcohol Level"**. 41 | 42 | ![Feature Selection](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Alcohol-Quality-Checker/README-Resources/Screenshot%20(106).png) 43 | 44 | --- 45 | 46 | ### **3,4&5> Model Selection**, **Model Creation**, **Testing** 47 | 48 | * To get the proper accuracy and for the proper splitting of the train and test data, I have used **Stratified K Fold Cross Validation** as it is very efficient in splitting the dataset. 49 | 50 | * Here, I have tried many algorithms like **Artificial Neural Network**, **Random Forest**, **Decision Tree**, **K-NN**, **Naive bayes classification** and **SVM**. 51 | * Among these, K-NN has gaven the higher accuracy (80%). 52 | * For this I have tried all the values k values **till 500** and **k=125** gave better results. 53 | 54 | | Algorithm | Average Accuracy | 55 | | ---- | ----| 56 | | Random Forest | 76.19% | 57 | | Decision Tree | 75.88% | 58 | | K-NN | 79.48% | 59 | | SVM | 79.7% | 60 | | Naive bayes | 78.21% | 61 | | ANN | 78.00% | 62 | 63 | --- 64 | * Finally, I decided to go with KNN because as we know **SVM generally has higher variance**, whereas in KNN we can fix it by **choosing the right K value**. In my project **k=125** gave better results. 65 | * For detailed look at Project, go to **[Alcohol-Quality.ipynb](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Alcohol-Quality-Checker/alcohol-quality-data.csv)** and **[model.py](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Alcohol-Quality-Checker/model.py)** 66 | 67 | ## About me 68 | 69 | **Piyush Pathak** 70 | 71 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 72 | 73 | [**GITHUB**](https://github.com/piyushpathak03) 74 | 75 | [**BLOG**](https://medium.com/@piyushpathak03) 76 | 77 | 78 | # 📫 Follw me: 79 | 80 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 81 | 82 |

83 | 84 | 85 | -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/app1.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | from flask import Flask, request, jsonify, render_template 4 | import pickle 5 | 6 | app = Flask(__name__) 7 | model = pickle.load(open('model.pkl', 'rb')) 8 | 9 | @app.route('/') 10 | def home(): 11 | return render_template('index1.html') 12 | 13 | @app.route('/predict',methods=['POST']) 14 | def predict(): 15 | ''' 16 | For rendering results on HTML GUI 17 | ''' 18 | float_features = [float(x) for x in request.form.values()] 19 | final_features = [np.array(float_features)] 20 | prediction = model.predict(final_features) 21 | if (prediction >= 0.5): 22 | a = "High" 23 | else: 24 | a = "Low" 25 | return render_template('index1.html',prediction_text="Quality of Alcohol is {}".format(str(a))) 26 | 27 | 28 | 29 | 30 | @app.route('/predict_api',methods=['POST']) 31 | def predict_api(): 32 | ''' 33 | For direct API calls trought request 34 | ''' 35 | data = request.get_json(force=True) 36 | prediction = model.predict([np.array(list(data.values()))]) 37 | 38 | output = prediction[0] 39 | return jsonify(output) 40 | 41 | if __name__ == "__main__": 42 | app.run(debug=True) -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Alcohol-Quality-Checker/model.pkl -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/model.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | %matplotlib inline 5 | pd.pandas.set_option('display.max_columns',None) 6 | 7 | #Importing Dataset 8 | data = pd.read_csv("alcohol-quality-data.csv") 9 | dataset = data.copy() 10 | 11 | #Preparing Data 12 | Y = pd.DataFrame(dataset['Quality_Category'].replace({"Low":0,"High":1})) 13 | X = dataset.drop(columns=['Quality_Category','pH','density']) 14 | 15 | # Train-Test Split 16 | from sklearn.model_selection import train_test_split 17 | X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.20, random_state=0) 18 | 19 | # Applying KNN 20 | from sklearn.neighbors import KNeighborsClassifier 21 | clf = KNeighborsClassifier(n_neighbors=125) 22 | clf.fit(X_train,np.ravel(y_train)) 23 | prediction = clf.predict(X_test) 24 | 25 | # Getting Accuracy 26 | from sklearn.metrics import accuracy_score 27 | score = accuracy_score(prediction,np.ravel(y_test)) 28 | 29 | # Model 30 | import pickle 31 | pickle.dump(clf,open('model.pkl','wb')) 32 | -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/request.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = 'http://localhost:5000/predict_api' 4 | r = requests.post(url,json={'sulfate':0.52, 'Alcohole Level':10}) 5 | 6 | print(r.json()) 7 | 8 | -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask == 1.1.1 2 | gunicorn == 19.9.0 3 | itsdangerous==1.1.0 4 | Jinja2==2.10.1 5 | MarkupSafe==1.1.1 6 | Werkzeug==0.15.5 7 | numpy>=1.9.2 8 | scipy>=0.15.1 9 | scikit-learn>=0.18 10 | matplotlib>=1.4.3 11 | pandas>=0.19 12 | 13 | -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/static/css/formc.css: -------------------------------------------------------------------------------- 1 | 2 | body{ 3 | background: #405d27; 4 | padding-top: 15%; 5 | 6 | } 7 | form{ 8 | background: #fff; 9 | } 10 | .form-container{ 11 | border-radius: 10px; 12 | padding: 30px; 13 | box-shadow: 0px 0px 10px 0px; 14 | } 15 | .bg{ 16 | width: 70px; 17 | height: 70px; 18 | position: absolute; 19 | top: -40px; 20 | left: 40%; 21 | } 22 | textarea { 23 | width: 100%; 24 | height: 150px; 25 | padding: 12px 20px; 26 | box-sizing: border-box; 27 | border: 2px solid #ccc; 28 | border-radius: 4px; 29 | background-color: #f8f8f8; 30 | resize: none; 31 | } 32 | 33 | form.h3{ 34 | color: #FFFFFF; 35 | } 36 | -------------------------------------------------------------------------------- /Alcohol-Quality-Checker/templates/form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alcohol Quality Checker 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 |
19 | 20 |
21 |

Alcohol Quality Checker

22 |
23 | 24 |
25 |
26 | 27 |
28 | 29 |
30 |
31 |
32 |
33 |

34 |
35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/Cloths_Predictions/__pycache__/predictions.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Cloths-AccessoryClassification using DL/Cloths_Predictions/__pycache__/predictions.cpython-36.pyc -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/Cloths_Predictions/predictions.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tensorflow as tf 3 | import cv2 4 | import numpy as np 5 | from itertools import chain 6 | from tensorflow.keras.applications.vgg16 import preprocess_input 7 | from tensorflow.keras.preprocessing import image 8 | from tensorflow.keras.models import load_model 9 | 10 | 11 | class Cloths_Classification: 12 | def __init__(self): 13 | self.class_names = ['Goggles', 'Hat', 'Jacket', 'Shirt', 'Shoes', 'Shorts', 'T-Shirt', 'Trouser', 'Wallet','Watch'] 14 | self.model = load_model("model/fashion.h5") 15 | 16 | def get_prediction(self, image): 17 | img = cv2.imread(image) 18 | dim = (224, 224) 19 | img = cv2.resize(img, dim, interpolation=cv2.INTER_AREA) 20 | x = np.array(img) 21 | x = np.expand_dims(x, axis=0) 22 | x = preprocess_input(x) 23 | preds = self.model.predict(x) 24 | pred_class = self.class_names[np.argmax(preds[0])] 25 | return pred_class 26 | 27 | def list_and_delete_previous_files(self): 28 | self.list_of_files = [] 29 | if os.path.exists('./uploads'): 30 | self.list_of_files = os.listdir('./uploads') 31 | print('------list of files------') 32 | print(self.list_of_files) 33 | for self.image in self.list_of_files: 34 | try: 35 | print("------Deleting File------") 36 | os.remove("./uploads/" + self.image) 37 | except Exception as e: 38 | print('error in deleting: ', e) 39 | else: 40 | print('Folder Does not exist!!') -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/README.md: -------------------------------------------------------------------------------- 1 | # Cloths-AccessoryClassification 2 | This project is built for classifying total 10 different type of cloths and accessories with VGG Image Classification Model. 3 | 4 | 5 | 6 | 7 | --- 8 | 9 | ## About Model: 10 | * The model is trained for classes: **'Goggles'**, **'Hat'**, **'Jacket'**, **'Shirt'**, **'Shoes'**, **'Shorts'**, **'T-Shirt'**, **'Trouser'**, **'Wallet'**,**'Watch'**. 11 | * Each class had around 30-50 images during training. 12 | * Images are trained with **VGG** Image Classification Model. 13 | 14 | 15 | 16 | --- 17 | 18 | ## Understanding VGG: 19 | 20 | 21 | 22 | * The full name of **VGG** is the **"Visual Geometry Group"**, which belongs to the Department of Science and Engineering of **Oxford University**. 23 | 24 | * In **[ILSVRC'14](http://www.image-net.org/challenges/LSVRC/#:~:text=The%20ImageNet%20Large%20Scale%20Visual,image%20classification%20at%20large%20scale.&text=Another%20motivation%20is%20to%20measure,indexing%20for%20retrieval%20and%20annotation.)**, VGG was **2nd in Image Classification** and **1st in Localization**. 25 | 26 | * The original purpose of VGG's research on the depth of convolutional networks is to understand how the depth of convolutional networks affects the accuracy and large-scale image classification and recognition. 27 | 28 | 29 | 30 | * In order to deepen the number of network layers and to avoid too many parameters, a small 3x3 convolution kernel is used in all layers. 31 | * Input to VGG Model is **224x224** sized **RGB** Images, contains **3x3** and **1x1** filters and number of fully connected layers differs from VGG-11 to VGG-19. 32 | * 1x1 kernels is introduced to increase expressive power of network and reduce the amount of calculations without affecting input and output dimension. 33 | * In VGG, concept of **using multiple small kernels in multiple stacked Conv. layers** is used insead of **using less no. of Conv. layers and large kernels**, to reduce the model size by reducing total parameters. This adds **more non-linearity** as activation function (Relu) in used multiple times in a set of Conv layes. 34 | * Here, the receptive field of large kernel Conv. layer is same as stacked small kernels Conv. layers with **reduced parameteres**. 35 | * The overall structure includes **5 sets of Conv.** layers followed by **Max Pooling** layers. 36 | 37 | --- 38 | 39 | 40 | 41 | ## Implementing Project: 42 | 1. **Clone Repository and Install [Anaconda](https://docs.anaconda.com/anaconda/install/).** 43 | 44 | 2. **Create Conda Environment with Python 3.6:** 45 | 46 | conda create -n env_name python=3.6 47 | 48 | 3. **Install Libraries from Requirements.txt:** 49 | 50 | pip install -r requirements.text 51 | 52 | 4. **Run app.py:** 53 | 54 | python app.py 55 | 56 | This will run the app on your local machine. 57 | 58 | --- 59 | 60 | ## About me 61 | 62 | **Piyush Pathak** 63 | 64 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 65 | 66 | [**GITHUB**](https://github.com/piyushpathak03) 67 | 68 | [**BLOG**](https://medium.com/@piyushpathak03) 69 | 70 | 71 | # 📫 Follw me: 72 | 73 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 74 | 75 |

76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/Readme_Images/Fashion-Model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Cloths-AccessoryClassification using DL/Readme_Images/Fashion-Model.png -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/Readme_Images/VGG-models.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Cloths-AccessoryClassification using DL/Readme_Images/VGG-models.png -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/Readme_Images/cloth-classification.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Cloths-AccessoryClassification using DL/Readme_Images/cloth-classification.gif -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/Readme_Images/vgg16-neural-network.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Cloths-AccessoryClassification using DL/Readme_Images/vgg16-neural-network.jpg -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/app.py: -------------------------------------------------------------------------------- 1 | import sys, os, glob, re 2 | import numpy as np 3 | from wsgiref import simple_server 4 | from flask import Flask, request, jsonify, Response 5 | from flask_cors import CORS, cross_origin 6 | # Keras 7 | from tensorflow.keras.models import load_model 8 | from tensorflow.keras.preprocessing import image 9 | from Cloths_Predictions.predictions import Cloths_Classification 10 | # Flask utils 11 | from flask import Flask, redirect, url_for, request, render_template 12 | from werkzeug.utils import secure_filename 13 | #from gevent.pywsgi import WSGIServer 14 | 15 | # Define a flask app 16 | app = Flask(__name__) 17 | 18 | @app.route('/', methods=['GET']) 19 | def index(): 20 | # Main page 21 | return render_template('index.html') 22 | 23 | 24 | @app.route('/predict', methods=['GET', 'POST']) 25 | def upload(): 26 | if request.method == 'POST': 27 | 28 | cloth = Cloths_Classification() 29 | cloth.list_and_delete_previous_files() 30 | 31 | f = request.files['file'] 32 | basepath = os.path.dirname(__file__) 33 | if not os.path.exists('uploads'): 34 | os.mkdir('uploads') 35 | file_path = os.path.join(basepath, 'uploads', secure_filename(f.filename)) 36 | f.save(file_path) 37 | 38 | result = cloth.get_prediction(file_path) 39 | return result 40 | return None 41 | 42 | 43 | if __name__ == '__main__': 44 | app.run(debug=True) -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/requirements.txt: -------------------------------------------------------------------------------- 1 | absl-py==0.8.0 2 | argon2-cffi==20.1.0 3 | astor==0.8.0 4 | async-generator==1.10 5 | attrs==19.1.0 6 | backcall==0.1.0 7 | bleach==3.1.0 8 | cachetools==4.1.1 9 | certifi==2019.9.11 10 | cffi==1.14.4 11 | chardet==3.0.4 12 | Click==7.0 13 | colorama==0.4.1 14 | cycler==0.10.0 15 | decorator==4.4.0 16 | defusedxml==0.6.0 17 | entrypoints==0.3 18 | Flask==1.1.1 19 | Flask-Cors==3.0.8 20 | gast==0.3.2 21 | google-auth==1.19.0 22 | google-auth-oauthlib==0.4.1 23 | google-pasta==0.1.7 24 | grpcio==1.23.0 25 | h5py==2.10.0 26 | importlib-metadata==3.4.0 27 | ipykernel==5.4.3 28 | ipython==7.16.1 29 | ipython-genutils==0.2.0 30 | ipywidgets==7.6.3 31 | itsdangerous==1.1.0 32 | jedi==0.15.1 33 | Jinja2==2.10.1 34 | joblib==1.0.0 35 | jsonschema==3.2.0 36 | jupyter==1.0.0 37 | jupyter-client==6.1.11 38 | jupyter-console==6.2.0 39 | jupyter-core==4.7.0 40 | jupyterlab-pygments==0.1.2 41 | jupyterlab-widgets==1.0.0 42 | Keras==2.3.0 43 | Keras-Applications==1.0.8 44 | Keras-Preprocessing==1.1.0 45 | kiwisolver==1.1.0 46 | Markdown==3.1.1 47 | MarkupSafe==1.1.1 48 | matplotlib==3.1.1 49 | mistune==0.8.4 50 | nbclient==0.5.1 51 | nbconvert==6.0.7 52 | nbformat==5.1.2 53 | nest-asyncio==1.4.3 54 | notebook==6.2.0 55 | numpy==1.17.2 56 | oauthlib==3.1.0 57 | opencv-contrib-python==4.1.1.26 58 | pandocfilters==1.4.2 59 | parso==0.5.1 60 | pickleshare==0.7.5 61 | Pillow==6.1.0 62 | prometheus-client==0.7.1 63 | prompt-toolkit==2.0.9 64 | protobuf==3.14.0 65 | pyasn1==0.4.8 66 | pyasn1-modules==0.2.8 67 | pycparser==2.20 68 | Pygments==2.7.4 69 | pyparsing==2.4.7 70 | pyrsistent==0.17.3 71 | python-dateutil==2.8.0 72 | pywin32==300 73 | pywinpty==0.5.7 74 | PyYAML==5.3.1 75 | pyzmq==21.0.1 76 | qtconsole==5.0.1 77 | QtPy==1.9.0 78 | requests-oauthlib==1.3.0 79 | rsa==4.6 80 | scikit-learn==0.21.3 81 | scipy==1.3.1 82 | Send2Trash==1.5.0 83 | six==1.12.0 84 | sklearn==0.0 85 | tensorboard==1.14.0 86 | tensorflow==1.14.0 87 | tensorflow-estimator==1.14.0 88 | termcolor==1.1.0 89 | terminado==0.9.2 90 | testpath==0.4.2 91 | tornado==6.1 92 | traitlets==4.3.2 93 | typing-extensions==3.7.4.3 94 | wcwidth==0.1.7 95 | webencodings==0.5.1 96 | Werkzeug==0.16.0 97 | widgetsnbextension==3.5.1 98 | wincertstore==0.2 99 | wrapt==1.11.2 100 | zipp==3.4.0 101 | traitlets==4.3.3 102 | urllib3==1.25.9 103 | wcwidth 104 | webencodings==0.5.1 105 | Werkzeug==1.0.1 106 | widgetsnbextension==3.5.1 107 | wincertstore==0.2 108 | wrapt==1.12.1 109 | zipp==3.1.0 110 | gunicorn==19.7.1 111 | selenium==3.8.0 -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/static/css/main.css: -------------------------------------------------------------------------------- 1 | .img-preview { 2 | width: 256px; 3 | height: 256px; 4 | position: relative; 5 | border: 5px solid #F8F8F8; 6 | box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1); 7 | margin-top: 1em; 8 | margin-bottom: 1em; 9 | } 10 | 11 | 12 | 13 | .img-preview>div { 14 | width: 100%; 15 | height: 100%; 16 | background-size: 256px 256px; 17 | background-repeat: no-repeat; 18 | background-position: center; 19 | } 20 | 21 | input[type="file"] { 22 | display: none; 23 | } 24 | 25 | 26 | .upload-label{ 27 | display: inline-block; 28 | padding: 12px 30px; 29 | background: #39D2B4; 30 | color: #fff; 31 | font-size: 1em; 32 | transition: all .4s; 33 | cursor: pointer; 34 | } 35 | 36 | .upload-label:hover{ 37 | background: #34495E; 38 | color: #39D2B4; 39 | } 40 | 41 | .loader { 42 | border: 8px solid #f3f3f3; /* Light grey */ 43 | border-top: 8px solid #3498db; /* Blue */ 44 | border-radius: 50%; 45 | width: 50px; 46 | height: 50px; 47 | animation: spin 1s linear infinite; 48 | } 49 | 50 | @keyframes spin { 51 | 0% { transform: rotate(0deg); } 52 | 100% { transform: rotate(360deg); } 53 | } -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/static/js/main.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | // Init 3 | $('.image-section').hide(); 4 | $('.loader').hide(); 5 | $('#result').hide(); 6 | 7 | // Upload Preview 8 | function readURL(input) { 9 | if (input.files && input.files[0]) { 10 | var reader = new FileReader(); 11 | reader.onload = function (e) { 12 | $('#imagePreview').css('background-image', 'url(' + e.target.result + ')'); 13 | $('#imagePreview').hide(); 14 | $('#imagePreview').fadeIn(650); 15 | } 16 | reader.readAsDataURL(input.files[0]); 17 | } 18 | } 19 | $("#imageUpload").change(function () { 20 | $('.image-section').show(); 21 | $('#btn-predict').show(); 22 | $('#result').text(''); 23 | $('#result').hide(); 24 | readURL(this); 25 | }); 26 | 27 | // Predict 28 | $('#btn-predict').click(function () { 29 | var form_data = new FormData($('#upload-file')[0]); 30 | 31 | // Show loading animation 32 | $(this).hide(); 33 | $('.loader').show(); 34 | 35 | // Make prediction by calling api /predict 36 | $.ajax({ 37 | type: 'POST', 38 | url: '/predict', 39 | data: form_data, 40 | contentType: false, 41 | cache: false, 42 | processData: false, 43 | async: true, 44 | success: function (data) { 45 | // Get and display the result 46 | $('.loader').hide(); 47 | $('#result').fadeIn(600); 48 | $('#result').text(' Result: ' + data); 49 | console.log('Success!'); 50 | }, 51 | }); 52 | }); 53 | 54 | }); -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Cloths & Accessories Classification Project 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 |
24 |
{% block content %}{% endblock %}
25 |
26 | 27 | 28 | 33 | 34 | 37 | 38 | -------------------------------------------------------------------------------- /Cloths-AccessoryClassification using DL/uploads/jacket1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Cloths-AccessoryClassification using DL/uploads/jacket1.jpg -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/ACT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/ACT.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Dep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Dep.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Details of Variables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Details of Variables.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Employed_FeMale_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Employed_FeMale_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Employed_Male_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Employed_Male_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Employed_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Employed_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/EmploymentStatus vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/EmploymentStatus vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/GNU license.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/GNU license.jpg -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Gender vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Gender vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/MIT license.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/MIT license.jpg -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Marital_status vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Marital_status vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Married_FeMale_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Married_FeMale_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Married_Male_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Married_Male_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Married_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Married_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/OLS Rgression Results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/OLS Rgression Results.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Response variable Distribution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Response variable Distribution.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Screenshot (111).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/Screenshot (111).png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnEmployed_FeMale_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnEmployed_FeMale_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnEmployed_Male_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnEmployed_Male_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnEmployed_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnEmployed_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnMarried_People vs Policy_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/UnMarried_People vs Policy_type.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/bar1 total cliam vs education.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/bar1 total cliam vs education.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/bar2 total cliam vs Gender.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/bar2 total cliam vs Gender.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/bar3 total cliam vs empstatus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/bar3 total cliam vs empstatus.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clt vs tca scatterplot empstatus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clt vs tca scatterplot empstatus.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clt vs tca scatterplot maritalstatus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clt vs tca scatterplot maritalstatus.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clt vs tca scatterplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clt vs tca scatterplot.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clv.jpg -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clvout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/clvout.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/fit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/fit.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/hist 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/hist 1.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/hist 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/hist 2.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/hist 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/hist 3.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/res.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP Analysis Output/res.png -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:app 2 | -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/Procfile.txt: -------------------------------------------------------------------------------- 1 | web: gunicorn app:Customer-Life-Time-Value-Prediction-api 2 | -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/README.md: -------------------------------------------------------------------------------- 1 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP%20Analysis%20Output/clv.jpg) 2 | 3 | # CUSTOMER LIFE TIME VALUE PREDICTION 4 |
5 | 6 | Heroku App Link : https://customerlifetimevaluepred.herokuapp.com/ 7 | 8 | ## DEPLOYMENT OUTPUT 9 | 10 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP%20Analysis%20Output/clvout.png) 11 | 12 | # Table Of Contents 13 | - [PROJECT GOAL](#PROJECT-GOAL) 14 | - [Project Motivation](#Project-Motivation) 15 | - [Requirements Installation](#Requirements-Installation) 16 | - [File Section](#File-Section) 17 | - [Technologies Used](#Technologies-Used) 18 | - [OLS REGRESSION MODEL OUTPUT](#OLS-REGRESSION-MODEL-OUTPUT) 19 | - [License](#License) 20 | - [Sample EDA VISUALIZATIONS](#Sample-EDA-VISUALIZATIONS) 21 | 22 | # PROJECT GOAL 23 | 24 | #### This project is designed to predict the CUSTOMER LIFE TIME VALUE of four wheeler insurance company using Regression Analysis with Python, FLASK, HTML, SQL 25 | #### A highly comprehensive analysis with all data cleaning, exploration, visualization, feature selection, model building, evaluation and MLR assumptions validity steps explained in detail. 26 | 27 | # Project Motivation 28 | 29 | **Every Organization runs with the goal to get a profit from their product and customers, most of the organization is workig hard without compromizing quality of products to help those organization business requirement, this project has been designed** 30 | 31 | # Requirements Installation 32 | 33 | **The Code is written in Python 3.7. If you don't have Python installed you can find it here. If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip. To install the required packages and libraries, run this command in the project directory after cloning the repository** 34 | 35 | pip install -r requirements.txt 36 | 37 | # File Section:- 38 | 39 | 40 | ### In Customer Lifetime Value (Exploratory Data Analysis).py 41 | 42 | 1- **Data Preprocessing** and some **Exploratory Data Analysis** to understand the data 43 | 44 | 2- **Data cleaning** 45 | 46 | 47 | 48 | ### In Customer Lifetime Value (Feature Engineering).py 49 | 50 | 1- Data preparation: **Feature Engineering and Scaling** 51 | 52 | 2- Feature Selection using **RFE and Model Building** 53 | 54 | 3- **Regression Assumptions** Validation and **Outlier Removal** 55 | 56 | 4- Rebuilding the Model Post Outlier Removal: Feature Selection & RFE 57 | 58 | 5- **Removing Multicollinearity**, Model Re-evaluation and Assumptions Validation 59 | 60 | ## Details of Variables [Response Variable ==> Customer Life Time Value] 61 | 62 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP%20Analysis%20Output/Details%20of%20Variables.png) 63 | 64 | ## OLS REGRESSION MODEL OUTPUT 65 | 66 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP%20Analysis%20Output/res.png) 67 | 68 | ## Data Points vs Fitted Line 69 | 70 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP%20Analysis%20Output/fit.png) 71 | 72 | ## Actual Points vs Fitted Points 73 | 74 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP%20Analysis%20Output/ACT.png) 75 | 76 | # Technologies Used 77 | 78 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p1.jpg) 79 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p2.png) 80 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p3.png) 81 | 82 | ## About me 83 | 84 | **Piyush Pathak** 85 | 86 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 87 | 88 | [**GITHUB**](https://github.com/piyushpathak03) 89 | 90 | [**BLOG**](https://medium.com/@piyushpathak03) 91 | 92 | 93 | # 📫 Follw me 94 | 95 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 96 | 97 |

98 | 99 | 100 | -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/RF_KModel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/RF_KModel.pkl -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/app.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from flask import Flask, request, jsonify, render_template 3 | import pickle 4 | 5 | app = Flask(__name__) 6 | regressor = pickle.load(open('RF_KModel.pkl', 'rb')) 7 | 8 | @app.route('/') 9 | def home(): 10 | return render_template('index.html') 11 | 12 | @app.route('/predict',methods=['POST']) 13 | def predict(): 14 | if request.method == "POST": 15 | Income = request.form["Income"] 16 | Monthly_Premium_Auto = float(request.form["Monthly_Premium_Auto"]) 17 | Months_Since_Last_Claim = float(request.form["Months_Since_Last_Claim"]) 18 | Months_Since_Policy_Inception = float(request.form["Months_Since_Policy_Inception"]) 19 | Number_of_Policies = float(request.form["Number_of_Policies"]) 20 | Total_Claim_Amount = float(request.form["Total_Claim_Amount"]) 21 | distance = float(request.form["distance"]) 22 | 23 | 24 | prediction=regressor.predict([[ 25 | Income, 26 | Monthly_Premium_Auto, 27 | Months_Since_Last_Claim, 28 | Months_Since_Policy_Inception, 29 | Number_of_Policies, 30 | Total_Claim_Amount, 31 | distance 32 | ]]) 33 | 34 | output=round(prediction[0],2) 35 | 36 | return render_template('index.html',prediction_text="Your Customer Life Time price is Rs. {}".format(output)) 37 | 38 | 39 | return render_template("index.html") 40 | 41 | 42 | 43 | 44 | 45 | 46 | if __name__ == "__main__": 47 | app.run(debug=True) -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/requirements.txt: -------------------------------------------------------------------------------- 1 | flasgger==0.9.4 2 | Flask==1.0.3 3 | gunicorn==19.9.0 4 | itsdangerous==1.1.0 5 | Jinja2==2.10.1 6 | MarkupSafe==1.1.1 7 | Werkzeug==0.15.5 8 | numpy==1.18.1 9 | pandas==1.0.3 10 | scikit-learn==0.22.1 11 | scipy==1.4.1 12 | seaborn==0.10.1 13 | -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/static/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/static/cover.jpg -------------------------------------------------------------------------------- /Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/templates/img_girl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/templates/img_girl.jpg -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:app -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/README.md: -------------------------------------------------------------------------------- 1 | ![Alt Text](https://github.com/DheerajKumar97/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku/blob/master/static/ATTT.png) 2 | 3 | # Employee Attrition Rate Prediction 4 | 5 | Heroku App Link : https://emloyeeattritionrate.herokuapp.com/home 6 | 7 | # Table Of Contents 8 | - [PROJECT GOAL](#PROJECT-GOAL) 9 | - [Project Motivation](#Project-Motivation) 10 | - [Requirements Installation](#Requirements-Installation) 11 | - [File Section](#File-Section) 12 | - [Technologies Used](#Technologies-Used) 13 | - [License](#License) 14 | - [Credits](#Credits) 15 | 16 | # PROJECT GOAL 17 | 18 | #### This project is designed to predict the E MPLOYEE ATTRITION RATE Iin corporate organization or company using Regression Analysis with Python, FLASK, HTML, SQL 19 | #### A highly comprehensive analysis with all data cleaning, exploration, visualization, feature selection, model building, evaluation and MLR assumptions validity steps explained in detail. 20 | 21 | # Project Motivation 22 | 23 | **Every Organization runs with the goal to get a profit from their products, most of the organization is workig hard with support of employed professionals so Attrition is important to consider, so its motivated me to do this project** 24 | 25 | # Requirements Installation 26 | 27 | **The Code is written in Python 3.7. If you don't have Python installed you can find it here. If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip. To install the required packages and libraries, run this command in the project directory after cloning the repository** 28 | 29 | pip install -r requirements.txt 30 | 31 | # File Section 32 | 33 | 1- **Data Preprocessing** and some **Exploratory Data Analysis** to understand the data 34 | 35 | 2- **Data cleaning** 36 | 37 | 3- Feature Selection using **RFE and Model Building** 38 | 39 | 4- **Regression Assumptions** Validation and **Outlier Removal** 40 | 41 | 5- Rebuilding the Model Post Outlier Removal: Feature Selection & RFE 42 | 43 | 6- **Removing Multicollinearity**, Model Re-evaluation and Assumptions Validation 44 | 45 | # Technologies Used 46 | 47 | ![Alt Text](https://github.com/DheerajKumar97/IPL-Score-Prediction-with-Flask-Deployment-Heroku/blob/master/static/p1.jpg) 48 | ![Alt Text](https://github.com/DheerajKumar97/IPL-Score-Prediction-with-Flask-Deployment-Heroku/blob/master/static/p2.png) 49 | ![Alt Text](https://github.com/DheerajKumar97/IPL-Score-Prediction-with-Flask-Deployment-Heroku/blob/master/static/p3.png) 50 | 51 | # License 52 | 53 | ![Alt Text](https://github.com/DheerajKumar97/FIFA-World-Cup-Analysis/blob/master/apache.jpg) 54 |
55 | 56 | 57 | https://www.apache.org/licenses/LICENSE-2.0 58 | 59 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 60 |
61 | 62 | # Credits 63 | Jason Brownlee 64 | -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request, redirect, url_for,session 2 | import pandas as pd 3 | import numpy as np 4 | import pickle 5 | from werkzeug.utils import secure_filename 6 | import os 7 | from flask import jsonify 8 | 9 | 10 | #prep data 11 | def prep_data(df): 12 | 13 | cat_df = pd.get_dummies(df[['OverTime']], drop_first=True) 14 | num_df = df[['Age','HourlyRate','DailyRate','MonthlyIncome','TotalWorkingYears','YearsAtCompany','NumCompaniesWorked','DistanceFromHome']] 15 | new_df = pd.concat([num_df,cat_df], axis=1) 16 | return new_df 17 | 18 | # 19 | def allowed_file(filename): 20 | return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS 21 | 22 | UPLOAD_FOLDER = './templates' 23 | ALLOWED_EXTENSIONS = set(['csv']) 24 | 25 | 26 | 27 | ## Initialize the app 28 | app = Flask(__name__) 29 | 30 | app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER 31 | 32 | @app.route('/home') 33 | def analysis_page(): 34 | # render a static template 35 | return render_template('home.html') 36 | 37 | @app.route('/') 38 | def index(): 39 | # redirect to home 40 | return redirect(url_for('analysis_page')) 41 | 42 | @app.route('/prediction', methods=['GET','POST']) 43 | def prediction_page(): 44 | if request.method == 'POST': 45 | #check if post request has the file type 46 | if 'file' not in request.files: 47 | return render_template('home.html', error='No File part',retJson ='No file part') 48 | file = request.files['file'] 49 | # if user the did not select file 50 | if file.filename == '': 51 | return render_template ('home.html',error='No file Selected', retJson='No File Selected') 52 | #check for allowed extension 53 | if file and allowed_file(file.filename): 54 | filename = secure_filename(file.filename) 55 | file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) 56 | # load the model from disk 57 | loaded_model = pickle.load(open('./random_forest_hr_model.sav', 'rb')) 58 | # read csv 59 | data = pd.read_csv(filename) 60 | prediction = loaded_model.predict_proba(prep_data(data)) 61 | # get percentage proba 62 | retJson = [] 63 | count = 0 64 | for prob in prediction: 65 | count+=1 66 | retJson.append("The probability of Employee Attrition with index {} : {} % ".format(count,prob[0] * 100)) 67 | 68 | 69 | 70 | #retJson =jsonify({'retJson' :retJson}) 71 | 72 | return render_template('home.html',error=None, retJson= retJson ) 73 | # render a static template 74 | return render_template('home.html') 75 | 76 | @app.route('/attrition', methods=['GET','POST']) 77 | def single_prediction_page(): 78 | if request.method == 'POST': 79 | Age = request.form['Age'] 80 | HourlyRate = request.form['HourlyRate'] 81 | OverTime = request.form['OverTime'] 82 | DailyRate = request.form['DailyRate'] 83 | MonthlyIncome = request.form['MonthlyIncome'] 84 | TotalWorkingYears = request.form['TotalWorkingYears'] 85 | YearsAtCompany = request.form['YearsAtCompany'] 86 | NumCompaniesWorked = request.form['NumCompaniesWorked'] 87 | DistanceFromHome = request.form['DistanceFromHome'] 88 | 89 | if len(Age) <= 0 or len(HourlyRate) <= 0 or len(OverTime) <= 0 or len(DailyRate) <= 0 or len(MonthlyIncome)<= 0 or len(TotalWorkingYears) <= 0 or len(YearsAtCompany) <= 0 or len(NumCompaniesWorked) <= 0: 90 | return render_template('home.html', retJson= 'All filed is required to make prediction' ) 91 | 92 | if OverTime == 'Yes': 93 | OverTime_Yes = 1 94 | else: 95 | OverTime_Yes = 0 96 | #create a pandas dataframe 97 | df = pd.DataFrame([{'Age': Age, 'HourlyRate': HourlyRate,'DailyRate':DailyRate, 'MonthlyIncome': MonthlyIncome, 98 | 'TotalWorkingYears':TotalWorkingYears, 'YearsAtCompany': YearsAtCompany, 'NumCompaniesWorked':NumCompaniesWorked, 99 | 'DistanceFromHome':DistanceFromHome, 'OverTime_Yes': OverTime_Yes}]) 100 | loaded_model = pickle.load(open('./random_forest_hr_model.sav', 'rb')) 101 | #print(df.head()) 102 | 103 | #temp = [ Age, HourlyRate, DailyRate, MonthlyIncome,TotalWorkingYears, YearsAtCompany, NumCompaniesWorked,DistanceFromHome, OverTime_Yes] 104 | #temp = np.reshape(1,-1) 105 | 106 | prediction = loaded_model.predict_proba(df) 107 | 108 | retJson = [] 109 | for prob in prediction: 110 | retJson.append("The probability is : {} % ".format(prob[0] * 100)) 111 | 112 | return render_template('prob.html',error=None, retJson= retJson ) 113 | # render a static template 114 | return render_template('home.html') 115 | 116 | 117 | 118 | if __name__ =='__main__': 119 | app.run(debug=True) 120 | 121 | 122 | -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/random_forest_hr_model.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/random_forest_hr_model.sav -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | numpy 3 | pandas 4 | sklearn 5 | werkzeug 6 | gunicorn 7 | 8 | -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/ATTT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/ATTT.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/At.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/At.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/attta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/attta.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/gg5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/gg5.jpg -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/logo.jpg -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_103_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_103_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_110_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_110_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_17_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_17_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_25_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_25_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_30_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_30_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_34_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_34_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_36_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_36_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_38_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_38_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_40_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_40_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_43_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_43_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_46_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_46_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_48_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_48_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_50_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_50_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_52_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_52_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_55_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_55_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_57_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_57_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_60_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_60_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_63_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_63_0.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_65_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_65_0.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_72_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_72_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_96_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_96_0.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_99_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_99_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/prob.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Home 12 | 13 | 14 | 15 | 16 | 17 | 44 | 45 |

46 | 55 |

{{ retJson }}

56 | 57 |

58 | 59 | 60 | 61 | 62 | 63 | 64 | 76 | 77 | -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:app -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/README.md: -------------------------------------------------------------------------------- 1 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/ATTT.png) 2 | 3 | # Employee Attrition Rate Prediction 4 | 5 | Heroku App Link : https://emloyeeattritionrate.herokuapp.com/home 6 | 7 | # Table Of Contents 8 | - [PROJECT GOAL](#PROJECT-GOAL) 9 | - [Project Motivation](#Project-Motivation) 10 | - [Requirements Installation](#Requirements-Installation) 11 | - [File Section](#File-Section) 12 | - [Technologies Used](#Technologies-Used) 13 | - [License](#License) 14 | - [Credits](#Credits) 15 | 16 | # PROJECT GOAL 17 | 18 | #### This project is designed to predict the E MPLOYEE ATTRITION RATE Iin corporate organization or company using Regression Analysis with Python, FLASK, HTML, SQL 19 | #### A highly comprehensive analysis with all data cleaning, exploration, visualization, feature selection, model building, evaluation and MLR assumptions validity steps explained in detail. 20 | 21 | # Project Motivation 22 | 23 | **Every Organization runs with the goal to get a profit from their products, most of the organization is workig hard with support of employed professionals so Attrition is important to consider, so its motivated me to do this project** 24 | 25 | # Requirements Installation 26 | 27 | **The Code is written in Python 3.7. If you don't have Python installed you can find it here. If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip. To install the required packages and libraries, run this command in the project directory after cloning the repository** 28 | 29 | pip install -r requirements.txt 30 | 31 | # File Section 32 | 33 | 1- **Data Preprocessing** and some **Exploratory Data Analysis** to understand the data 34 | 35 | 2- **Data cleaning** 36 | 37 | 3- Feature Selection using **RFE and Model Building** 38 | 39 | 4- **Regression Assumptions** Validation and **Outlier Removal** 40 | 41 | 5- Rebuilding the Model Post Outlier Removal: Feature Selection & RFE 42 | 43 | 6- **Removing Multicollinearity**, Model Re-evaluation and Assumptions Validation 44 | 45 | 46 | # Technologies Used 47 | 48 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p1.jpg) 49 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p2.png) 50 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p3.png) 51 | 52 | 53 | ## About me 54 | 55 | **Piyush Pathak** 56 | 57 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 58 | 59 | [**GITHUB**](https://github.com/piyushpathak03) 60 | 61 | [**BLOG**](https://medium.com/@piyushpathak03) 62 | 63 | 64 | # 📫 Follw me: 65 | 66 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 67 | 68 |

69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request, redirect, url_for,session 2 | import pandas as pd 3 | import numpy as np 4 | import pickle 5 | from werkzeug.utils import secure_filename 6 | import os 7 | from flask import jsonify 8 | 9 | 10 | #prep data 11 | def prep_data(df): 12 | 13 | cat_df = pd.get_dummies(df[['OverTime']], drop_first=True) 14 | num_df = df[['Age','HourlyRate','DailyRate','MonthlyIncome','TotalWorkingYears','YearsAtCompany','NumCompaniesWorked','DistanceFromHome']] 15 | new_df = pd.concat([num_df,cat_df], axis=1) 16 | return new_df 17 | 18 | # 19 | def allowed_file(filename): 20 | return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS 21 | 22 | UPLOAD_FOLDER = './templates' 23 | ALLOWED_EXTENSIONS = set(['csv']) 24 | 25 | 26 | 27 | ## Initialize the app 28 | app = Flask(__name__) 29 | 30 | app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER 31 | 32 | @app.route('/home') 33 | def analysis_page(): 34 | # render a static template 35 | return render_template('home.html') 36 | 37 | @app.route('/') 38 | def index(): 39 | # redirect to home 40 | return redirect(url_for('analysis_page')) 41 | 42 | @app.route('/prediction', methods=['GET','POST']) 43 | def prediction_page(): 44 | if request.method == 'POST': 45 | #check if post request has the file type 46 | if 'file' not in request.files: 47 | return render_template('home.html', error='No File part',retJson ='No file part') 48 | file = request.files['file'] 49 | # if user the did not select file 50 | if file.filename == '': 51 | return render_template ('home.html',error='No file Selected', retJson='No File Selected') 52 | #check for allowed extension 53 | if file and allowed_file(file.filename): 54 | filename = secure_filename(file.filename) 55 | file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) 56 | # load the model from disk 57 | loaded_model = pickle.load(open('./random_forest_hr_model.sav', 'rb')) 58 | # read csv 59 | data = pd.read_csv(filename) 60 | prediction = loaded_model.predict_proba(prep_data(data)) 61 | # get percentage proba 62 | retJson = [] 63 | count = 0 64 | for prob in prediction: 65 | count+=1 66 | retJson.append("The probability of Employee Attrition with index {} : {} % ".format(count,prob[0] * 100)) 67 | 68 | 69 | 70 | #retJson =jsonify({'retJson' :retJson}) 71 | 72 | return render_template('home.html',error=None, retJson= retJson ) 73 | # render a static template 74 | return render_template('home.html') 75 | 76 | @app.route('/attrition', methods=['GET','POST']) 77 | def single_prediction_page(): 78 | if request.method == 'POST': 79 | Age = request.form['Age'] 80 | HourlyRate = request.form['HourlyRate'] 81 | OverTime = request.form['OverTime'] 82 | DailyRate = request.form['DailyRate'] 83 | MonthlyIncome = request.form['MonthlyIncome'] 84 | TotalWorkingYears = request.form['TotalWorkingYears'] 85 | YearsAtCompany = request.form['YearsAtCompany'] 86 | NumCompaniesWorked = request.form['NumCompaniesWorked'] 87 | DistanceFromHome = request.form['DistanceFromHome'] 88 | 89 | if len(Age) <= 0 or len(HourlyRate) <= 0 or len(OverTime) <= 0 or len(DailyRate) <= 0 or len(MonthlyIncome)<= 0 or len(TotalWorkingYears) <= 0 or len(YearsAtCompany) <= 0 or len(NumCompaniesWorked) <= 0: 90 | return render_template('home.html', retJson= 'All filed is required to make prediction' ) 91 | 92 | if OverTime == 'Yes': 93 | OverTime_Yes = 1 94 | else: 95 | OverTime_Yes = 0 96 | #create a pandas dataframe 97 | df = pd.DataFrame([{'Age': Age, 'HourlyRate': HourlyRate,'DailyRate':DailyRate, 'MonthlyIncome': MonthlyIncome, 98 | 'TotalWorkingYears':TotalWorkingYears, 'YearsAtCompany': YearsAtCompany, 'NumCompaniesWorked':NumCompaniesWorked, 99 | 'DistanceFromHome':DistanceFromHome, 'OverTime_Yes': OverTime_Yes}]) 100 | loaded_model = pickle.load(open('./random_forest_hr_model.sav', 'rb')) 101 | #print(df.head()) 102 | 103 | #temp = [ Age, HourlyRate, DailyRate, MonthlyIncome,TotalWorkingYears, YearsAtCompany, NumCompaniesWorked,DistanceFromHome, OverTime_Yes] 104 | #temp = np.reshape(1,-1) 105 | 106 | prediction = loaded_model.predict_proba(df) 107 | 108 | retJson = [] 109 | for prob in prediction: 110 | retJson.append("The probability is : {} % ".format(prob[0] * 100)) 111 | 112 | return render_template('prob.html',error=None, retJson= retJson ) 113 | # render a static template 114 | return render_template('home.html') 115 | 116 | 117 | 118 | if __name__ =='__main__': 119 | app.run(debug=True) 120 | 121 | 122 | -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/random_forest_hr_model.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/random_forest_hr_model.sav -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | numpy 3 | pandas 4 | sklearn 5 | werkzeug 6 | gunicorn 7 | 8 | -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/ATTT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/ATTT.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/At.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/At.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/attta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/attta.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/gg5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/gg5.jpg -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/logo.jpg -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_103_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_103_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_110_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_110_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_17_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_17_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_25_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_25_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_30_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_30_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_34_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_34_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_36_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_36_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_38_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_38_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_40_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_40_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_43_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_43_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_46_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_46_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_48_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_48_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_50_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_50_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_52_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_52_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_55_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_55_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_57_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_57_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_60_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_60_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_63_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_63_0.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_65_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_65_0.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_72_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_72_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_96_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_96_0.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_99_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/output_99_1.png -------------------------------------------------------------------------------- /Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/templates/prob.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Home 12 | 13 | 14 | 15 | 16 | 17 | 44 | 45 |

46 | 55 |

{{ retJson }}

56 | 57 |

58 | 59 | 60 | 61 | 62 | 63 | 64 | 76 | 77 | -------------------------------------------------------------------------------- /FlightPrice_Prediction/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:app -------------------------------------------------------------------------------- /FlightPrice_Prediction/Test.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/FlightPrice_Prediction/Test.xlsx -------------------------------------------------------------------------------- /FlightPrice_Prediction/Train.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/FlightPrice_Prediction/Train.xlsx -------------------------------------------------------------------------------- /FlightPrice_Prediction/requirements.txt: -------------------------------------------------------------------------------- 1 | appdirs==1.4.3 2 | certifi==2020.6.20 3 | click==7.1.2 4 | distlib==0.3.0 5 | Flask==1.1.2 6 | Flask-Cors==3.0.8 7 | gunicorn==20.0.4 8 | itsdangerous==1.1.0 9 | Jinja2==2.11.2 10 | joblib==0.15.1 11 | MarkupSafe==1.1.1 12 | numpy==1.18.1 13 | pandas==1.0.1 14 | python-dateutil==2.8.1 15 | pytz==2019.3 16 | scikit-learn==0.22.1 17 | scipy==1.4.1 18 | six==1.14.0 19 | virtualenv==20.0.7 20 | Werkzeug==1.0.1 21 | wincertstore==0.2 22 | -------------------------------------------------------------------------------- /FlightPrice_Prediction/static/css/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #e1f4f3; 3 | text-align: center; 4 | } 5 | 6 | .navbar { 7 | background-color: #333333; 8 | } 9 | 10 | a { 11 | color: #f1f9f9; 12 | } 13 | 14 | a:hover { 15 | color: #f0f0f0; 16 | } -------------------------------------------------------------------------------- /Heat Exchanger Price Prediction/CAPSTONE.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Heat Exchanger Price Prediction/CAPSTONE.pptx -------------------------------------------------------------------------------- /Heat Exchanger Price Prediction/Heat Exchanger Price Prediction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Heat Exchanger Price Prediction/Heat Exchanger Price Prediction.pdf -------------------------------------------------------------------------------- /Heat Exchanger Price Prediction/dataset1.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Heat Exchanger Price Prediction/dataset1.xlsx -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 K Dheeraj Kumar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:app -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/Procfile.txt: -------------------------------------------------------------------------------- 1 | web: gunicorn app:IPL-Score-Prediction-api 2 | -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/README.md: -------------------------------------------------------------------------------- 1 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/ipl.jpeg) 2 |
3 | # IPL-Score-Prediction-with-Flask-Deployment 4 | Heroku App Link : https://iplscoreprediction.herokuapp.com/ 5 | 6 | # Deployment Demo 7 | 8 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/IPL%20Predictor%20Output.gif) 9 |
10 | # Table Of Contents 11 | - [Project Goal](#Project-Goal) 12 | - [Project Motivation](#Project-Motivation) 13 | - [Requirements Installation](#Requirements-Installation) 14 | - [File Sections](#File-Sections) 15 | - [Technologies Used](#Technologies-Used) 16 | - [License](#License) 17 | 18 | # Project Goal 19 | 20 | **This Project is to designed to predict the Score of Indian Premier League using Regression Analysis with PYTHON,FLASK,HTML,SQL** 21 | 22 | # Project Motivation 23 | 24 | **Every Year IPL will be going on but unfortunately in 2020 due to this pandemic everyone was in lockdown. I was Missing the IPL Match this year, and during this Lockdown i have gon through so much ideas in Machine Learning at that time i got inspired on this IPL Score Prediction concept.** 25 | 26 | # Requirements Installation 27 | 28 | **The Code is written in Python 3.7. If you don't have Python installed you can find it here. If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip. To install the required packages and libraries, run this command in the project directory after cloning the repository** 29 | 30 | pip install -r requirements.txt 31 | 32 | # The Python file has following sections: 33 | 34 | ## IPL Score Prediction.py 35 | 36 | 1- **Data Preprocessing** and some **Exploratory Data Analysis** to understand the data 37 | 38 | 2- **Data preparation**: **Feature Engineering** and Scaling 39 | 40 | 3- **Feature Selection** using **RFE** and Model Building 41 | 42 | 4- **Regression Assumptions** Validation and **Outlier Removal** 43 | 44 | 5- **Rebuilding the Model** Post Outlier Removal: Feature Selection & RFE 45 | 46 | 6- **Removing Multicollinearity**, Model Re-evaluation and Assumptions Validation 47 | 48 | # Technologies Used 49 | 50 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p1.jpg) 51 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p2.png) 52 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p3.png) 53 | 54 | 55 | ## About me 56 | 57 | **Piyush Pathak** 58 | 59 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 60 | 61 | [**GITHUB**](https://github.com/piyushpathak03) 62 | 63 | [**BLOG**](https://medium.com/@piyushpathak03) 64 | 65 | 66 | # 📫 Follw me: 67 | 68 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 69 | 70 |

71 | -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/app.py: -------------------------------------------------------------------------------- 1 | # Importing essential libraries 2 | from flask import Flask, render_template, request 3 | import pickle 4 | import numpy as np 5 | 6 | # Load the Random Forest CLassifier model 7 | filename = 'lr-model.pkl' 8 | regressor = pickle.load(open(filename, 'rb')) 9 | 10 | app = Flask(__name__) 11 | 12 | @app.route('/') 13 | def home(): 14 | return render_template('index.html') 15 | 16 | @app.route('/predict', methods=['POST']) 17 | def predict(): 18 | temp_array = list() 19 | 20 | if request.method == 'POST': 21 | 22 | batting_team = request.form['batting-team'] 23 | if batting_team == 'Chennai Super Kings': 24 | temp_array = temp_array + [1,0,0,0,0,0,0,0] 25 | elif batting_team == 'Delhi Daredevils': 26 | temp_array = temp_array + [0,1,0,0,0,0,0,0] 27 | elif batting_team == 'Kings XI Punjab': 28 | temp_array = temp_array + [0,0,1,0,0,0,0,0] 29 | elif batting_team == 'Kolkata Knight Riders': 30 | temp_array = temp_array + [0,0,0,1,0,0,0,0] 31 | elif batting_team == 'Mumbai Indians': 32 | temp_array = temp_array + [0,0,0,0,1,0,0,0] 33 | elif batting_team == 'Rajasthan Royals': 34 | temp_array = temp_array + [0,0,0,0,0,1,0,0] 35 | elif batting_team == 'Royal Challengers Bangalore': 36 | temp_array = temp_array + [0,0,0,0,0,0,1,0] 37 | elif batting_team == 'Sunrisers Hyderabad': 38 | temp_array = temp_array + [0,0,0,0,0,0,0,1] 39 | 40 | 41 | bowling_team = request.form['bowling-team'] 42 | if bowling_team == 'Chennai Super Kings': 43 | temp_array = temp_array + [1,0,0,0,0,0,0,0] 44 | elif bowling_team == 'Delhi Daredevils': 45 | temp_array = temp_array + [0,1,0,0,0,0,0,0] 46 | elif bowling_team == 'Kings XI Punjab': 47 | temp_array = temp_array + [0,0,1,0,0,0,0,0] 48 | elif bowling_team == 'Kolkata Knight Riders': 49 | temp_array = temp_array + [0,0,0,1,0,0,0,0] 50 | elif bowling_team == 'Mumbai Indians': 51 | temp_array = temp_array + [0,0,0,0,1,0,0,0] 52 | elif bowling_team == 'Rajasthan Royals': 53 | temp_array = temp_array + [0,0,0,0,0,1,0,0] 54 | elif bowling_team == 'Royal Challengers Bangalore': 55 | temp_array = temp_array + [0,0,0,0,0,0,1,0] 56 | elif bowling_team == 'Sunrisers Hyderabad': 57 | temp_array = temp_array + [0,0,0,0,0,0,0,1] 58 | 59 | 60 | overs = float(request.form['overs']) 61 | runs = int(request.form['runs']) 62 | wickets = int(request.form['wickets']) 63 | runs_in_prev_5 = int(request.form['runs_in_prev_5']) 64 | wickets_in_prev_5 = int(request.form['wickets_in_prev_5']) 65 | 66 | temp_array = temp_array + [overs, runs, wickets, runs_in_prev_5, wickets_in_prev_5] 67 | 68 | data = np.array([temp_array]) 69 | my_prediction = int(regressor.predict(data)[0]) 70 | 71 | return render_template('result.html', lower_limit = my_prediction-10, upper_limit = my_prediction+5) 72 | 73 | 74 | 75 | if __name__ == '__main__': 76 | app.run(debug=True) 77 | -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/lr-model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/lr-model.pkl -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==1.1.1 2 | gunicorn==19.9.0 3 | itsdangerous==1.1.0 4 | Jinja2==2.10.1 5 | MarkupSafe==1.1.1 6 | Werkzeug==0.15.5 7 | numpy>=1.9.2 8 | scipy>=0.15.1 9 | scikit-learn>=0.18 10 | matplotlib>=1.4.3 11 | pandas>=0.19 12 | -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/static/IPL Predictor Output.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/static/IPL Predictor Output.gif -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/static/P4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/static/P4.jpg -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/static/ipl-favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/static/ipl-favicon.ico -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/static/ipl.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/static/ipl.jpeg -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/static/p1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/static/p1.jpg -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/static/p2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/static/p2.png -------------------------------------------------------------------------------- /IPL-Score-Prediction-with-Deployment/static/p3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/IPL-Score-Prediction-with-Deployment/static/p3.png -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/how_to_train/README.md: -------------------------------------------------------------------------------- 1 | # How to Train 2 | 3 | This section covers on how to train the LeafNet network. Again, this section is further divided into 2 parts: 4 | 5 | - YOLOv3 (Darknet) 6 | - Deep Residual network (Resnet 50) 7 | 8 | *Note: You might need a mass-file rename script file (rename.py) for training and annotating the train images for YOLOv3 (if you need). 9 | 10 | 11 | ## YOLOv3 (DarkNet 53) : 12 | 13 | - YOLO - You look Only Once Version3 - is used as the leaf detector for the LeafNet classifier. It is based on YOLOv3 Darknet53 pre-trained weights and makes use of transfer learning wherein the model, before, was trained on a very large dataset. 14 | 15 | - To train, I used the following tutorials and resources, 16 | 17 | - https://medium.com/@manivannan_data/how-to-train-yolov3-to-detect-custom-objects-ccbcafeb13d2 : This tutorial starts off by intoducing YOLOv3 darknet and how to train (with details and helpful commands). 18 | 19 | - https://medium.com/@manivannan_data/how-to-train-yolov2-to-detect-custom-objects-9010df784f36 : USE this tutorial ONLY FOR image/ data annotation, beacuse, this tutorial consists of training the model in YOLOv2. 20 | 21 | - https://github.com/ManivannanMurugavel/YOLO-Annotation-Tool : Make use of this annotation tool for annotation of images. 22 | 23 | - https://github.com/deepakHonakeri05/darknet.git : (Forked from AlexeyAB --> pjreddy's github repository) In case if you are UNABLE to find YOLOv3 Darknet 24 | 25 | 26 | Important Note : 27 | If you need the config files for this YOLOv3 Darknet : check [config file location] 28 | - cfg/ leaf.cfg 29 | - cfg/ leaf.data 30 | - cfg/ leaf.names 31 | 32 | [config file location] : https://github.com/deepakHonakeri05/darknet/tree/master/cfg 33 | 34 | 35 | ## Deep Residual network (Resnet 50) : 36 | 37 | - This part of training, is relatively simple but can be tedious task which requires training the model for 8 different classifiers. The training involves taking a pretrained Resnet network trained on imagenet dataset. This too, involves transfer learning. 38 | 39 | - "Res50_script.ipynb" Includes the model architecture and the template used in training the model. In order to train, the 8 different classifiers please use this same script and vary the number of classes and epochs as you desire. 40 | 41 | - However, in the script of the training for Resnet model, the code is very easy to understand and it is self-explanatory. Hence, I will not be covering the architecture here. 42 | -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/how_to_train/rename.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | path = './server/' 4 | counter = 1 5 | for f in os.listdir(path): 6 | suffix = f.split('.')[-1] 7 | #if suffix == 'jpg' or suffix == 'png' or suffix == 'JPG'or suffix == 'jpeg': 8 | if suffix == 'png': 9 | new = '{}.{}'.format('init_'+str(counter), 'png') 10 | os.rename(path + f, path + new) 11 | counter = int(counter) + 1 12 | -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/Flow diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/Flow diagram.png -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/applescab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/applescab.jpg -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/arrow.png -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/block_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/block_diagram.png -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/leaf_after_yolo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/leaf_after_yolo.jpeg -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/leaf_before_yolo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/leaf_before_yolo.jpeg -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/resnetACC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/resnetACC.png -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/images/subClasses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Leaf-Disease-Classifier-master/images/subClasses.png -------------------------------------------------------------------------------- /Leaf-Disease-Classifier-master/readME.md: -------------------------------------------------------------------------------- 1 | # Leaf-Disease-Classifier 2 | 3 | * Leaf Disease Classifier classifies disease based on image processing techniques for automated vision system used at agricultural field. 4 | 5 | * Check out my resreach paper : deepakhonakeri.ml/static/docs/Research_paper_IJCSE.pdf 6 | 7 | * The classifier is trained on the dataset found at 8 | * https://www.kaggle.com/emmarex/plantdisease 9 | * https://github.com/spMohanty/PlantVillage-Dataset 10 | 11 | 12 | # Deep Dive into Concepts 13 | - [Disease Classifier](##DiseaseClassifier) 14 | - [How To Train](##HowToTrain) 15 | - [Run Model](##RunModel) 16 | 17 | ## Disease Classifier 18 | 19 | The whole disease classification process is divided into 3 stages as in 20 | 21 | 22 | 23 | - An input image is initially taken, A You Only Look Once (YOLOv3), object detector is run over the input image to obtain the coordinates of bounding boxes around leaves present in the image if any. The detector divides the input image into a grid and then analyzes every cell to identify features of the target object. The adjacent cells where the features are detected with high confidence are then put together to produce the output of the model. 24 | 25 | 26 | 27 | 28 | - The leaves are then cropped out of the image using the OpenCV library using the given coordinates from the bounding boxes. These extracted images are passed as input to a CNN Classifier which classifies the input into the 8 classes of plants from the dataset. 29 | 30 | 31 | 32 | - 8 CNN classifiers are trained to identify the diseases of each of the 8 plant classes. The result from stage 2 is used to call the classifier that has been trained to classify the different diseases for that plant. If there are none, the leaf would be classified as 'Healthy'. 33 | 34 | 35 | 36 | - All the above CNN's are trained on a Deep Residual Network- ResNet-50 Architecture using "Transfer Learning" from the ImageNet weights. 37 | 38 | [//]: # () 39 | 40 | - Frameworks used : Keras, DarkNet. 41 | 42 | 43 | # How-To-Train: 44 | 45 | Check the "how_to_train" folder for detailed explanation on getting started and how to train the each of the models (explained in the next section) are trained. 46 | 47 | Find it here : https://github.com/piyushpathak03/End-to-End-small-projects/tree/master/Leaf-Disease-Classifier-master/how_to_train 48 | 49 | ## Run Model 50 | 51 | - To run and setup the model, you’ll need at least OpenCV 3.4.2. 52 | - Dataset structure used in the project : 53 | * git clone https://github.com/deepakHonakeri05/yolo_dataset.git 54 | - The weights of the networks can be given on-demand due constraints set on GitHub. 55 | 56 | ## About me 57 | 58 | **Piyush Pathak** 59 | 60 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 61 | 62 | [**GITHUB**](https://github.com/piyushpathak03) 63 | 64 | [**BLOG**](https://medium.com/@piyushpathak03) 65 | 66 | 67 | # 📫 Follw me: 68 | 69 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 70 | 71 |

72 | -------------------------------------------------------------------------------- /Loan-Default-Prediction/train.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Loan-Default-Prediction/train.zip -------------------------------------------------------------------------------- /Logo recognition from images/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 satojkovic 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Logo recognition from images/config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | TRAIN_DIR = 'flickr_logos_27_dataset' 4 | IMAGES_DIR = os.path.join(TRAIN_DIR, 'flickr_logos_27_dataset_images') 5 | CROPPED_IMAGES_DIR = os.path.join(TRAIN_DIR, 'flickr_logos_27_dataset_images_cropped') 6 | ANNOT_FILE = os.path.join(TRAIN_DIR, 'flickr_logos_27_dataset_training_set_annotation.txt') 7 | CROPPED_ANNOT_FILE = os.path.join(TRAIN_DIR, 'flickr_logos_27_dataset_training_set_annotation_cropped.txt') 8 | CROPPED_ANNOT_FILE_TEST = os.path.join(TRAIN_DIR, 'flickr_logos_27_dataset_test_set_annotation_cropped.txt') 9 | 10 | CLASS_NAMES = [ 11 | 'Adidas', 'Apple', 'BMW', 'Citroen', 'Cocacola', 'DHL', 'Fedex', 'Ferrari', 12 | 'Ford', 'Google', 'HP', 'Heineken', 'Intel', 'McDonalds', 'Mini', 'Nbc', 13 | 'Nike', 'Pepsi', 'Porsche', 'Puma', 'RedBull', 'Sprite', 'Starbucks', 14 | 'Texaco', 'Unicef', 'Vodafone', 'Yahoo' 15 | ] 16 | CLASS_NAMES_FILE = os.path.join(TRAIN_DIR, 'flickr_logos_27_dataset_class_names.txt') 17 | -------------------------------------------------------------------------------- /Logo recognition from images/detect_results/detect_result_029.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/detect_results/detect_result_029.png -------------------------------------------------------------------------------- /Logo recognition from images/detect_results/detect_result_049.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/detect_results/detect_result_049.png -------------------------------------------------------------------------------- /Logo recognition from images/detect_results/detect_result_055.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/detect_results/detect_result_055.png -------------------------------------------------------------------------------- /Logo recognition from images/detect_results/detect_result_056.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/detect_results/detect_result_056.png -------------------------------------------------------------------------------- /Logo recognition from images/detect_results/detect_result_082.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/detect_results/detect_result_082.png -------------------------------------------------------------------------------- /Logo recognition from images/detect_results/detect_result_351.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/detect_results/detect_result_351.png -------------------------------------------------------------------------------- /Logo recognition from images/flickr_logos_27_label_map.pbtxt: -------------------------------------------------------------------------------- 1 | item { 2 | id: 1 3 | display_name: "Adidas" 4 | } 5 | item { 6 | id: 2 7 | display_name: "Apple" 8 | } 9 | item { 10 | id: 3 11 | display_name: "BMW" 12 | } 13 | item { 14 | id: 4 15 | display_name: "Citroen" 16 | } 17 | item { 18 | id: 5 19 | display_name: "Cocacola" 20 | } 21 | item { 22 | id: 6 23 | display_name: "DHL" 24 | } 25 | item { 26 | id: 7 27 | display_name: "Fedex" 28 | } 29 | item { 30 | id: 8 31 | display_name: "Ferrari" 32 | } 33 | item { 34 | id: 9 35 | display_name: "Ford" 36 | } 37 | item { 38 | id: 10 39 | display_name: "Google" 40 | } 41 | item { 42 | id: 11 43 | display_name: "HP" 44 | } 45 | item { 46 | id: 12 47 | display_name: "Heineken" 48 | } 49 | item { 50 | id: 13 51 | display_name: "Intel" 52 | } 53 | item { 54 | id: 14 55 | display_name: "McDonalds" 56 | } 57 | item { 58 | id: 15 59 | display_name: "Mini" 60 | } 61 | item { 62 | id: 16 63 | display_name: "Nbc" 64 | } 65 | item { 66 | id: 17 67 | display_name: "Nike" 68 | } 69 | item { 70 | id: 18 71 | display_name: "Pepsi" 72 | } 73 | item { 74 | id: 19 75 | display_name: "Porsche" 76 | } 77 | item { 78 | id: 20 79 | display_name: "Puma" 80 | } 81 | item { 82 | id: 21 83 | display_name: "RedBull" 84 | } 85 | item { 86 | id: 22 87 | display_name: "Sprite" 88 | } 89 | item { 90 | id: 23 91 | display_name: "Starbucks" 92 | } 93 | item { 94 | id: 24 95 | display_name: "Texaco" 96 | } 97 | item { 98 | id: 25 99 | display_name: "Unicef" 100 | } 101 | item { 102 | id: 26 103 | display_name: "Vodafone" 104 | } 105 | item { 106 | id: 27 107 | display_name: "Yahoo" 108 | } 109 | -------------------------------------------------------------------------------- /Logo recognition from images/gen_tfrecord.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding=utf-8 -*- 3 | 4 | import argparse 5 | import os 6 | import numpy as np 7 | import io 8 | from PIL import Image 9 | import config 10 | 11 | import tensorflow as tf 12 | from object_detection.utils import dataset_util 13 | 14 | 15 | def parse_arguments(): 16 | parser = argparse.ArgumentParser() 17 | parser.add_argument('--train_or_test', required=True, help='Generate tfrecord for train or test') 18 | parser.add_argument('--csv_input', required=True, help='Path to the csv input') 19 | parser.add_argument('--img_dir', required=True, help='Path to the image directory') 20 | parser.add_argument('--output_path', required=True, help='Path to output tfrecord') 21 | return parser.parse_args() 22 | 23 | 24 | def create_tf_example(csv, img_dir): 25 | img_fname = csv[0] 26 | x1, y1, x2, y2 = list(map(int, csv[1:-1])) 27 | cls_idx = int(csv[-1]) 28 | cls_text = config.CLASS_NAMES[cls_idx].encode('utf8') 29 | with tf.gfile.GFile(os.path.join(img_dir, img_fname), 'rb') as fid: 30 | encoded_jpg = fid.read() 31 | encoded_jpg_io = io.BytesIO(encoded_jpg) 32 | image = Image.open(encoded_jpg_io) 33 | width, height = image.size 34 | 35 | xmin = [x1 / width] 36 | xmax = [x2 / width] 37 | ymin = [y1 / height] 38 | ymax = [y2 / height] 39 | cls_text = [cls_text] 40 | cls_idx = [cls_idx] 41 | 42 | filename = img_fname.encode('utf8') 43 | image_format = b'jpg' 44 | 45 | tf_example = tf.train.Example(features=tf.train.Features(feature={ 46 | 'image/height': dataset_util.int64_feature(height), 47 | 'image/width': dataset_util.int64_feature(width), 48 | 'image/filename': dataset_util.bytes_feature(filename), 49 | 'image/source_id': dataset_util.bytes_feature(filename), 50 | 'image/encoded': dataset_util.bytes_feature(encoded_jpg), 51 | 'image/format': dataset_util.bytes_feature(image_format), 52 | 'image/object/bbox/xmin': dataset_util.float_list_feature(xmin), 53 | 'image/object/bbox/xmax': dataset_util.float_list_feature(xmax), 54 | 'image/object/bbox/ymin': dataset_util.float_list_feature(ymin), 55 | 'image/object/bbox/ymax': dataset_util.float_list_feature(ymax), 56 | 'image/object/class/text': dataset_util.bytes_list_feature(cls_text), 57 | 'image/object/class/label': dataset_util.int64_list_feature(cls_idx), 58 | })) 59 | 60 | return tf_example 61 | 62 | 63 | if __name__ == "__main__": 64 | args = parse_arguments() 65 | train_or_test = args.train_or_test.lower() 66 | 67 | writer = tf.python_io.TFRecordWriter(args.output_path) 68 | csvs = np.loadtxt(args.csv_input, dtype=str, delimiter=',') 69 | img_fnames = set() 70 | num_data = 0 71 | for csv in csvs: 72 | img_fname = csv[0] 73 | tf_example = create_tf_example(csv, args.img_dir) 74 | if train_or_test == 'train' or (train_or_test == 'test' and not img_fname in img_fnames): 75 | writer.write(tf_example.SerializeToString()) 76 | num_data += 1 77 | img_fnames.add(img_fname) 78 | 79 | writer.close() 80 | print('Generated ({} imgs): {}'.format(num_data, args.output_path)) -------------------------------------------------------------------------------- /Logo recognition from images/gen_tfrecord_logos32plus.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding=utf-8 -*- 3 | 4 | import argparse 5 | import os 6 | import numpy as np 7 | import io 8 | from PIL import Image 9 | import config 10 | import scipy.io as sio 11 | from sklearn.model_selection import train_test_split 12 | from tqdm import tqdm 13 | 14 | import tensorflow as tf 15 | from object_detection.utils import dataset_util 16 | 17 | 18 | def parse_arguments(): 19 | parser = argparse.ArgumentParser() 20 | parser.add_argument('--gt_mat', required=True, help='Path to grountruth.mat') 21 | parser.add_argument('--img_dir', required=True, help='Path to image directory') 22 | return parser.parse_args() 23 | 24 | 25 | def create_tf_example(img_fname, logo_name, bbox, img_dir, logo_names): 26 | x1, y1, w, h = list(map(int, bbox)) 27 | x2, y2 = x1 + w, y1 + h 28 | cls_idx = logo_names[logo_name] 29 | cls_text = logo_name.encode('utf8') 30 | with tf.gfile.GFile(os.path.join(img_dir, img_fname), 'rb') as fid: 31 | encoded_jpg = fid.read() 32 | encoded_jpg_io = io.BytesIO(encoded_jpg) 33 | image = Image.open(encoded_jpg_io) 34 | width, height = image.size 35 | 36 | xmin = [x1 / width] 37 | xmax = [x2 / width] 38 | ymin = [y1 / height] 39 | ymax = [y2 / height] 40 | cls_text = [cls_text] 41 | cls_idx = [cls_idx] 42 | 43 | filename = img_fname.encode('utf8') 44 | image_format = b'jpg' 45 | 46 | tf_example = tf.train.Example(features=tf.train.Features(feature={ 47 | 'image/height': dataset_util.int64_feature(height), 48 | 'image/width': dataset_util.int64_feature(width), 49 | 'image/filename': dataset_util.bytes_feature(filename), 50 | 'image/source_id': dataset_util.bytes_feature(filename), 51 | 'image/encoded': dataset_util.bytes_feature(encoded_jpg), 52 | 'image/format': dataset_util.bytes_feature(image_format), 53 | 'image/object/bbox/xmin': dataset_util.float_list_feature(xmin), 54 | 'image/object/bbox/xmax': dataset_util.float_list_feature(xmax), 55 | 'image/object/bbox/ymin': dataset_util.float_list_feature(ymin), 56 | 'image/object/bbox/ymax': dataset_util.float_list_feature(ymax), 57 | 'image/object/class/text': dataset_util.bytes_list_feature(cls_text), 58 | 'image/object/class/label': dataset_util.int64_list_feature(cls_idx), 59 | })) 60 | 61 | return tf_example 62 | 63 | 64 | if __name__ == "__main__": 65 | args = parse_arguments() 66 | 67 | gts = sio.loadmat(args.gt_mat) 68 | logo_names = {gt[2][0] for gt in gts['groundtruth'][0]} 69 | logo_names = sorted(list(logo_names)) 70 | logo_names = {name: i for i, name in enumerate(logo_names)} 71 | gt_train, gt_test = train_test_split(gts['groundtruth'][0]) 72 | 73 | train_writer = tf.python_io.TFRecordWriter('train_logos32plus.tfrecord') 74 | for gt in tqdm(gt_train): 75 | img_fname = gt[0][0].replace('\\', '/') 76 | logo_name = gt[2][0] 77 | for bbox in gt[1]: 78 | tf_example = create_tf_example(img_fname, logo_name, bbox, args.img_dir, logo_names) 79 | train_writer.write(tf_example.SerializeToString()) 80 | train_writer.close() 81 | 82 | test_writer = tf.python_io.TFRecordWriter('test_logos32plus.tfrecord') 83 | num_data = 0 84 | for gt in tqdm(gt_test): 85 | img_fname = gt[0][0].replace('\\', '/') 86 | logo_name = gt[2][0] 87 | for bbox in gt[1]: 88 | tf_example = create_tf_example(img_fname, logo_name, bbox, args.img_dir, logo_names) 89 | test_writer.write(tf_example.SerializeToString()) 90 | break 91 | num_data += 1 92 | test_writer.close() 93 | print('Test ({} imgs)'.format(num_data)) 94 | -------------------------------------------------------------------------------- /Logo recognition from images/logos32plus_label_map.pbtxt: -------------------------------------------------------------------------------- 1 | item { 2 | id: 1 3 | display_name: "HP" 4 | } 5 | item { 6 | id: 2 7 | display_name: "adidas" 8 | } 9 | item { 10 | id: 3 11 | display_name: "aldi" 12 | } 13 | item { 14 | id: 4 15 | display_name: "apple" 16 | } 17 | item { 18 | id: 5 19 | display_name: "becks" 20 | } 21 | item { 22 | id: 6 23 | display_name: "bmw" 24 | } 25 | item { 26 | id: 7 27 | display_name: "carlsberg" 28 | } 29 | item { 30 | id: 8 31 | display_name: "chimay" 32 | } 33 | item { 34 | id: 9 35 | display_name: "cocacola" 36 | } 37 | item { 38 | id: 10 39 | display_name: "corona" 40 | } 41 | item { 42 | id: 11 43 | display_name: "dhl" 44 | } 45 | item { 46 | id: 12 47 | display_name: "erdinger" 48 | } 49 | item { 50 | id: 13 51 | display_name: "esso" 52 | } 53 | item { 54 | id: 14 55 | display_name: "fedex" 56 | } 57 | item { 58 | id: 15 59 | display_name: "ferrari" 60 | } 61 | item { 62 | id: 16 63 | display_name: "ford" 64 | } 65 | item { 66 | id: 17 67 | display_name: "fosters" 68 | } 69 | item { 70 | id: 18 71 | display_name: "google" 72 | } 73 | item { 74 | id: 19 75 | display_name: "guinness" 76 | } 77 | item { 78 | id: 20 79 | display_name: "heineken" 80 | } 81 | item { 82 | id: 21 83 | display_name: "milka" 84 | } 85 | item { 86 | id: 22 87 | display_name: "nvidia" 88 | } 89 | item { 90 | id: 23 91 | display_name: "paulaner" 92 | } 93 | item { 94 | id: 24 95 | display_name: "pepsi" 96 | } 97 | item { 98 | id: 25 99 | display_name: "rittersport" 100 | } 101 | item { 102 | id: 26 103 | display_name: "shell" 104 | } 105 | item { 106 | id: 27 107 | display_name: "singha" 108 | } 109 | item { 110 | id: 28 111 | display_name: "starbucks" 112 | } 113 | item { 114 | id: 29 115 | display_name: "stellaartois" 116 | } 117 | item { 118 | id: 30 119 | display_name: "texaco" 120 | } 121 | item { 122 | id: 31 123 | display_name: "tsingtao" 124 | } 125 | item { 126 | id: 32 127 | display_name: "ups" 128 | } 129 | -------------------------------------------------------------------------------- /Logo recognition from images/preproc_annot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding=utf-8 -*- 3 | 4 | import pandas as pd 5 | from skimage import io 6 | import config 7 | import os 8 | import warnings 9 | import numpy as np 10 | 11 | def main(): 12 | # Load annot file 13 | logos_frame = pd.read_csv(config.ANNOT_FILE, header=None, delim_whitespace=True) 14 | print('Num. of annots:', len(logos_frame)) 15 | 16 | if not os.path.exists(config.CROPPED_IMAGES_DIR): 17 | os.makedirs(config.CROPPED_IMAGES_DIR) 18 | 19 | num_cropped_images = 0 20 | annots = [] 21 | for i, row in logos_frame.iterrows(): 22 | img_name = row[0] 23 | cls_name = row[1] 24 | cls_idx = config.CLASS_NAMES.index(cls_name) 25 | subset = row[2] 26 | x1, y1, x2, y2 = row[3:] 27 | w, h = (x2 - x1), (y2 - y1) 28 | if w == 0 or h == 0: 29 | print('Skip:', img_name) 30 | continue 31 | img = io.imread(os.path.join(config.IMAGES_DIR, img_name)) 32 | img_height, img_width, _ = img.shape 33 | x = (x1 + x2) / 2 34 | y = (y1 + y1) / 2 35 | annot = ','.join([img_name, str(x1), str(y1), str(x2), str(y2), str(cls_idx)]) 36 | annots.append(annot) 37 | num_cropped_images += 1 38 | 39 | np.random.shuffle(annots) 40 | num_train = int(num_cropped_images * 0.8) 41 | with open(config.CROPPED_ANNOT_FILE, 'w') as f: 42 | for annot in annots[:num_train]: 43 | f.writelines(annot) 44 | f.writelines("\n") 45 | 46 | seen = set() 47 | num_test = 0 48 | with open(config.CROPPED_ANNOT_FILE_TEST, 'w') as f: 49 | for annot in annots[num_train:]: 50 | img_fn = annot.split(',')[0] 51 | if img_fn in seen: 52 | continue 53 | f.writelines(annot) 54 | f.writelines("\n") 55 | seen.add(img_fn) 56 | num_test += 1 57 | print('Num. of annotations: {}(train) {}(test)'.format(num_train, num_test)) 58 | print('Created: {}'.format(config.CROPPED_ANNOT_FILE)) 59 | print('Created: {}'.format(config.CROPPED_ANNOT_FILE_TEST)) 60 | 61 | if __name__ == "__main__": 62 | with warnings.catch_warnings(): 63 | # Supress low contrast warnings 64 | warnings.simplefilter("ignore") 65 | 66 | # Crop logo images 67 | main() -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/2180367311_Google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/2180367311_Google.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/3198284747_texaco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/3198284747_texaco.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/3489964654_Intel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/3489964654_Intel.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/3666600356_Cocacola.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/3666600356_Cocacola.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/388978947_BMW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/388978947_BMW.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/3907703753_Fedex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/3907703753_Fedex.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/401253895_BMW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/401253895_BMW.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/4273898682_DHL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/4273898682_DHL.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/4288066623_Unicef.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/4288066623_Unicef.png -------------------------------------------------------------------------------- /Logo recognition from images/query_set_results/6651198_McDonalds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Logo recognition from images/query_set_results/6651198_McDonalds.png -------------------------------------------------------------------------------- /Logo recognition from images/ssd_inception_v2_coco.config: -------------------------------------------------------------------------------- 1 | # SSD with Inception v2 configuration for MSCOCO Dataset. 2 | # Users should configure the fine_tune_checkpoint field in the train config as 3 | # well as the label_map_path and input_path fields in the train_input_reader and 4 | # eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that 5 | # should be configured. 6 | 7 | model { 8 | ssd { 9 | num_classes: 27 10 | box_coder { 11 | faster_rcnn_box_coder { 12 | y_scale: 10.0 13 | x_scale: 10.0 14 | height_scale: 5.0 15 | width_scale: 5.0 16 | } 17 | } 18 | matcher { 19 | argmax_matcher { 20 | matched_threshold: 0.5 21 | unmatched_threshold: 0.5 22 | ignore_thresholds: false 23 | negatives_lower_than_unmatched: true 24 | force_match_for_each_row: true 25 | } 26 | } 27 | similarity_calculator { 28 | iou_similarity { 29 | } 30 | } 31 | anchor_generator { 32 | ssd_anchor_generator { 33 | num_layers: 6 34 | min_scale: 0.2 35 | max_scale: 0.95 36 | aspect_ratios: 1.0 37 | aspect_ratios: 2.0 38 | aspect_ratios: 0.5 39 | aspect_ratios: 3.0 40 | aspect_ratios: 0.3333 41 | reduce_boxes_in_lowest_layer: true 42 | } 43 | } 44 | image_resizer { 45 | fixed_shape_resizer { 46 | height: 300 47 | width: 300 48 | } 49 | } 50 | box_predictor { 51 | convolutional_box_predictor { 52 | min_depth: 0 53 | max_depth: 0 54 | num_layers_before_predictor: 0 55 | use_dropout: false 56 | dropout_keep_probability: 0.8 57 | kernel_size: 3 58 | box_code_size: 4 59 | apply_sigmoid_to_scores: false 60 | conv_hyperparams { 61 | activation: RELU_6, 62 | regularizer { 63 | l2_regularizer { 64 | weight: 0.00004 65 | } 66 | } 67 | initializer { 68 | truncated_normal_initializer { 69 | stddev: 0.03 70 | mean: 0.0 71 | } 72 | } 73 | } 74 | } 75 | } 76 | feature_extractor { 77 | type: 'ssd_inception_v2' 78 | min_depth: 16 79 | depth_multiplier: 1.0 80 | conv_hyperparams { 81 | activation: RELU_6, 82 | regularizer { 83 | l2_regularizer { 84 | weight: 0.00004 85 | } 86 | } 87 | initializer { 88 | truncated_normal_initializer { 89 | stddev: 0.03 90 | mean: 0.0 91 | } 92 | } 93 | batch_norm { 94 | train: true, 95 | scale: true, 96 | center: true, 97 | decay: 0.9997, 98 | epsilon: 0.001, 99 | } 100 | } 101 | override_base_feature_extractor_hyperparams: true 102 | } 103 | loss { 104 | classification_loss { 105 | weighted_sigmoid { 106 | } 107 | } 108 | localization_loss { 109 | weighted_smooth_l1 { 110 | } 111 | } 112 | hard_example_miner { 113 | num_hard_examples: 3000 114 | iou_threshold: 0.99 115 | loss_type: CLASSIFICATION 116 | max_negatives_per_positive: 3 117 | min_negatives_per_image: 0 118 | } 119 | classification_weight: 1.0 120 | localization_weight: 1.0 121 | } 122 | normalize_loss_by_num_matches: true 123 | post_processing { 124 | batch_non_max_suppression { 125 | score_threshold: 1e-8 126 | iou_threshold: 0.6 127 | max_detections_per_class: 100 128 | max_total_detections: 100 129 | } 130 | score_converter: SIGMOID 131 | } 132 | } 133 | } 134 | 135 | train_config: { 136 | batch_size: 24 137 | optimizer { 138 | rms_prop_optimizer: { 139 | learning_rate: { 140 | exponential_decay_learning_rate { 141 | initial_learning_rate: 0.004 142 | decay_steps: 800720 143 | decay_factor: 0.95 144 | } 145 | } 146 | momentum_optimizer_value: 0.9 147 | decay: 0.9 148 | epsilon: 1.0 149 | } 150 | } 151 | fine_tune_checkpoint: "ssd_inception_v2_coco_2018_01_28/model.ckpt" 152 | from_detection_checkpoint: true 153 | # Note: The below line limits the training process to 200K steps, which we 154 | # empirically found to be sufficient enough to train the pets dataset. This 155 | # effectively bypasses the learning rate schedule (the learning rate will 156 | # never decay). Remove the below line to train indefinitely. 157 | num_steps: 200000 158 | data_augmentation_options { 159 | random_horizontal_flip { 160 | } 161 | } 162 | data_augmentation_options { 163 | ssd_random_crop { 164 | } 165 | } 166 | data_augmentation_options { 167 | random_rotation90 { 168 | } 169 | } 170 | } 171 | 172 | train_input_reader: { 173 | tf_record_input_reader { 174 | input_path: "train.tfrecord" 175 | } 176 | label_map_path: "flickr_logos_27_label_map.pbtxt" 177 | } 178 | 179 | eval_config: { 180 | num_examples: 8000 181 | # Note: The below line limits the evaluation process to 10 evaluations. 182 | # Remove the below line to evaluate indefinitely. 183 | max_evals: 10 184 | } 185 | 186 | eval_input_reader: { 187 | tf_record_input_reader { 188 | input_path: "test.tfrecord" 189 | } 190 | label_map_path: "flickr_logos_27_label_map.pbtxt" 191 | shuffle: false 192 | num_readers: 1 193 | } 194 | -------------------------------------------------------------------------------- /Logo recognition from images/ssd_inception_v2_coco_logos32plus.config: -------------------------------------------------------------------------------- 1 | # SSD with Inception v2 configuration for MSCOCO Dataset. 2 | # Users should configure the fine_tune_checkpoint field in the train config as 3 | # well as the label_map_path and input_path fields in the train_input_reader and 4 | # eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that 5 | # should be configured. 6 | 7 | model { 8 | ssd { 9 | num_classes: 32 10 | box_coder { 11 | faster_rcnn_box_coder { 12 | y_scale: 10.0 13 | x_scale: 10.0 14 | height_scale: 5.0 15 | width_scale: 5.0 16 | } 17 | } 18 | matcher { 19 | argmax_matcher { 20 | matched_threshold: 0.5 21 | unmatched_threshold: 0.5 22 | ignore_thresholds: false 23 | negatives_lower_than_unmatched: true 24 | force_match_for_each_row: true 25 | } 26 | } 27 | similarity_calculator { 28 | iou_similarity { 29 | } 30 | } 31 | anchor_generator { 32 | ssd_anchor_generator { 33 | num_layers: 6 34 | min_scale: 0.2 35 | max_scale: 0.95 36 | aspect_ratios: 1.0 37 | aspect_ratios: 2.0 38 | aspect_ratios: 0.5 39 | aspect_ratios: 3.0 40 | aspect_ratios: 0.3333 41 | reduce_boxes_in_lowest_layer: true 42 | } 43 | } 44 | image_resizer { 45 | fixed_shape_resizer { 46 | height: 300 47 | width: 300 48 | } 49 | } 50 | box_predictor { 51 | convolutional_box_predictor { 52 | min_depth: 0 53 | max_depth: 0 54 | num_layers_before_predictor: 0 55 | use_dropout: false 56 | dropout_keep_probability: 0.8 57 | kernel_size: 3 58 | box_code_size: 4 59 | apply_sigmoid_to_scores: false 60 | conv_hyperparams { 61 | activation: RELU_6, 62 | regularizer { 63 | l2_regularizer { 64 | weight: 0.00004 65 | } 66 | } 67 | initializer { 68 | truncated_normal_initializer { 69 | stddev: 0.03 70 | mean: 0.0 71 | } 72 | } 73 | } 74 | } 75 | } 76 | feature_extractor { 77 | type: 'ssd_inception_v2' 78 | min_depth: 16 79 | depth_multiplier: 1.0 80 | conv_hyperparams { 81 | activation: RELU_6, 82 | regularizer { 83 | l2_regularizer { 84 | weight: 0.00004 85 | } 86 | } 87 | initializer { 88 | truncated_normal_initializer { 89 | stddev: 0.03 90 | mean: 0.0 91 | } 92 | } 93 | batch_norm { 94 | train: true, 95 | scale: true, 96 | center: true, 97 | decay: 0.9997, 98 | epsilon: 0.001, 99 | } 100 | } 101 | override_base_feature_extractor_hyperparams: true 102 | } 103 | loss { 104 | classification_loss { 105 | weighted_sigmoid { 106 | } 107 | } 108 | localization_loss { 109 | weighted_smooth_l1 { 110 | } 111 | } 112 | hard_example_miner { 113 | num_hard_examples: 3000 114 | iou_threshold: 0.99 115 | loss_type: CLASSIFICATION 116 | max_negatives_per_positive: 3 117 | min_negatives_per_image: 0 118 | } 119 | classification_weight: 1.0 120 | localization_weight: 1.0 121 | } 122 | normalize_loss_by_num_matches: true 123 | post_processing { 124 | batch_non_max_suppression { 125 | score_threshold: 1e-8 126 | iou_threshold: 0.6 127 | max_detections_per_class: 100 128 | max_total_detections: 100 129 | } 130 | score_converter: SIGMOID 131 | } 132 | } 133 | } 134 | 135 | train_config: { 136 | batch_size: 24 137 | optimizer { 138 | rms_prop_optimizer: { 139 | learning_rate: { 140 | exponential_decay_learning_rate { 141 | initial_learning_rate: 0.004 142 | decay_steps: 800720 143 | decay_factor: 0.95 144 | } 145 | } 146 | momentum_optimizer_value: 0.9 147 | decay: 0.9 148 | epsilon: 1.0 149 | } 150 | } 151 | fine_tune_checkpoint: "ssd_inception_v2_coco_2018_01_28/model.ckpt" 152 | from_detection_checkpoint: true 153 | # Note: The below line limits the training process to 200K steps, which we 154 | # empirically found to be sufficient enough to train the pets dataset. This 155 | # effectively bypasses the learning rate schedule (the learning rate will 156 | # never decay). Remove the below line to train indefinitely. 157 | num_steps: 200000 158 | data_augmentation_options { 159 | random_horizontal_flip { 160 | } 161 | } 162 | data_augmentation_options { 163 | ssd_random_crop { 164 | } 165 | } 166 | } 167 | 168 | train_input_reader: { 169 | tf_record_input_reader { 170 | input_path: "train_logos32plus.tfrecord" 171 | } 172 | label_map_path: "logos32plus_label_map.pbtxt" 173 | } 174 | 175 | eval_config: { 176 | num_examples: 1958 177 | # Note: The below line limits the evaluation process to 10 evaluations. 178 | # Remove the below line to evaluate indefinitely. 179 | max_evals: 10 180 | } 181 | 182 | eval_input_reader: { 183 | tf_record_input_reader { 184 | input_path: "test_logos32plus.tfrecord" 185 | } 186 | label_map_path: "logos32plus_label_map.pbtxt" 187 | shuffle: false 188 | num_readers: 1 189 | } 190 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:app 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # End-to-End-small-projects 2 | A repository for multiple end to end small machine learning and deep learning projects from scratch to production 3 | 4 | # projects 5 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Customer-Life-Time-Value-Prediction-Flask-Deployment--Heroku-master/CLTP%20Analysis%20Output/clv.jpg) 6 | 7 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/Employee-Attrition-Rate-Prediction-Flask--Deployment-Heroku-master/static/ATTT.png) 8 | 9 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/ipl.jpeg) 10 | 11 | 12 | 13 | 14 | ![Demo video](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/face_unlock/demo.gif) 15 | 16 | # Technologies Used 17 | 18 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p1.jpg) 19 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p2.png) 20 | ![Alt Text](https://github.com/piyushpathak03/End-to-End-small-projects/blob/master/IPL-Score-Prediction-with-Deployment/static/p3.png) 21 | 22 | 23 | ## About me 24 | 25 | **Piyush Pathak** 26 | 27 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 28 | 29 | [**GITHUB**](https://github.com/piyushpathak03) 30 | 31 | [**BLOG**](https://medium.com/@piyushpathak03) 32 | 33 | 34 | # 📫 Follw me: 35 | 36 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 37 | 38 |

39 | 40 | -------------------------------------------------------------------------------- /Real-time-ML-Project-master/assets/first.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Real-time-ML-Project-master/assets/industry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Real-time-ML-Project-master/assets/industry.png -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:app -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/app.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | 7 | # Importing essential libraries 8 | from flask import Flask, render_template, request 9 | import pickle 10 | 11 | # Load the Multinomial Naive Bayes model and CountVectorizer object from disk 12 | filename = 'restaurant_model.pkl' 13 | classifier = pickle.load(open(filename, 'rb')) 14 | cv = pickle.load(open('cv-transform.pkl','rb')) 15 | 16 | app = Flask(__name__) 17 | 18 | @app.route('/') 19 | def home(): 20 | return render_template('index.html') 21 | 22 | @app.route('/predict', methods=['POST']) 23 | def predict(): 24 | if request.method == 'POST': 25 | message = request.form['message'] 26 | data = [message] 27 | vect = cv.transform(data).toarray() 28 | my_prediction = classifier.predict(vect) 29 | return render_template('result.html', prediction=my_prediction) 30 | 31 | if __name__ == '__main__': 32 | app.run(debug=True) 33 | 34 | -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/cv-transform.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Restaurant Review Analyser using NLP/cv-transform.pkl -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==1.1.2 2 | gunicorn>=19.9.0 3 | numpy>=1.9.2 4 | scipy>=0.15.1 5 | scikit-learn>=0.18 6 | matplotlib>=1.4.3 7 | pandas>=0.19 -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/restaurant_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Restaurant Review Analyser using NLP/restaurant_model.pkl -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/static/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Restaurant Review Analyser using NLP/static/2.jpg -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Restaurant Review Analyser using NLP/static/favicon.ico -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/static/food.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Restaurant Review Analyser using NLP/static/food.ico -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/static/negative-review.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Restaurant Review Analyser using NLP/static/negative-review.webp -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/static/positive-review.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/Restaurant Review Analyser using NLP/static/positive-review.webp -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/static/styles.css: -------------------------------------------------------------------------------- 1 | html{ 2 | height: 100%; 3 | margin: 0; 4 | } 5 | 6 | 7 | body{ 8 | 9 | background-image:url('2.jpg'); 10 | background-repeat: no-repeat; 11 | background-position: center; 12 | background-size: cover; 13 | 14 | font-family: Arial, Helvetica,sans-serif; 15 | text-align: center; 16 | margin: 0; 17 | padding: 0; 18 | width: 100%; 19 | height: 100%; 20 | display: flex; 21 | flex-direction: column; 22 | } 23 | 24 | 25 | /* Website Title */ 26 | .container{ 27 | padding: 30px; 28 | position: relative; 29 | background: #eb6d65; 30 | background-size: 500% 500%; 31 | 32 | } 33 | 34 | 35 | .container-heading{ 36 | margin: 0; 37 | font-size: 35px; 38 | } 39 | 40 | .description,.footer-description{ 41 | font-style: italic; 42 | font-size: 14px; 43 | margin: 3px 0 0; 44 | } 45 | 46 | /* Text Area */ 47 | .ml-container{ 48 | 49 | margin: 30px 0; 50 | flex: 1 0 auto; 51 | } 52 | 53 | .message-box{ 54 | background-color: rgb(0,0,0); /* Fallback color */ 55 | background-color: rgba(0,0,0, 0.4); /* Black w/opacity/see-through */ 56 | color: #E9E9E9; 57 | margin-bottom: 20px; 58 | } 59 | 60 | 61 | 62 | /* Predict Button */ 63 | .my-cta-button{ 64 | background-color:#E9E9E9; 65 | border-radius: 5px; 66 | display:inline-block; 67 | cursor:pointer; 68 | color:#000000; 69 | font-family:Arial; 70 | font-size:15px; 71 | font-weight:bold; 72 | padding:7px 30px; 73 | margin-top: 10px; 74 | text-decoration:none; 75 | transition: 0.5s ease-out; 76 | } 77 | 78 | .my-cta-button:hover{ 79 | background-color: #0c0c0c; 80 | color: #ffffff; 81 | box-shadow: inset 7px 3px 16px -10px rgba(0,0,0,0.75); 82 | } 83 | 84 | .my-cta-button:active{ 85 | position:relative; 86 | top:1px; 87 | } 88 | 89 | /* Footer */ 90 | .footer{ 91 | bottom: 0; 92 | font-size: 14px; 93 | padding: 20px; 94 | flex-shrink: 0; 95 | position: relative; 96 | background: #eb6d65; 97 | background-size: 500% 500%; 98 | 99 | } 100 | 101 | .contact-icon{ 102 | color: #000000; 103 | padding: 7px; 104 | } 105 | 106 | 107 | .contact-icon:hover{ 108 | color: #8c8c8c; 109 | } 110 | 111 | 112 | 113 | 114 | h1 { 115 | color: white; 116 | text-shadow: 2px 2px 4px #000000; 117 | } 118 | 119 | 120 | h2 { 121 | color: white; 122 | text-shadow: 2px 2px 4px #000000; 123 | } 124 | 125 | .description{ 126 | color: black; 127 | } 128 | -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Restaurant Review - Sentiment Analyser 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 |

Restaurant Review's Sentiment Analyser

24 |
25 |

26 | 27 |

28 |
29 |

https://www.linkedin.com/in/piyushpathak03/

30 |


31 |

32 |

Made by Piyush Pathak.

33 | 34 | -------------------------------------------------------------------------------- /Restaurant Review Analyser using NLP/templates/result.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Restaurant Review - Sentiment Analyser 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 |

Restaurant Review's Sentiment Analyser

24 |

{% if prediction==1 %} 25 |

26 |

I love calories. They are dаmn tasty.

27 |

28 | {% elif prediction==0 %} 29 |

30 |

Ooops! I don't share blame but I am an explorer of food.

31 |

32 |








{% endif %} 33 |

34 |

https://www.linkedin.com/in/piyushpathak03/

35 |

Made by Piyush Pathak


36 |

37 |



38 |

39 | 40 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | import requests 3 | import pickle 4 | import numpy as np 5 | import sklearn 6 | from sklearn.preprocessing import StandardScaler 7 | app = Flask(__name__) 8 | model = pickle.load(open('random_forest_regression_model.pkl', 'rb')) 9 | @app.route('/',methods=['GET']) 10 | def Home(): 11 | return render_template('index.html') 12 | 13 | 14 | standard_to = StandardScaler() 15 | @app.route("/predict", methods=['POST']) 16 | def predict(): 17 | Fuel_Type_Diesel=0 18 | if request.method == 'POST': 19 | Year = int(request.form['Year']) 20 | Present_Price=float(request.form['Present_Price']) 21 | Kms_Driven=int(request.form['Kms_Driven']) 22 | Kms_Driven2=np.log(Kms_Driven) 23 | Owner=int(request.form['Owner']) 24 | Fuel_Type_Petrol=request.form['Fuel_Type_Petrol'] 25 | if(Fuel_Type_Petrol=='Petrol'): 26 | Fuel_Type_Petrol=1 27 | Fuel_Type_Diesel=0 28 | elif(Fuel_Type_Petrol=='Diesel'): 29 | Fuel_Type_Petrol=0 30 | Fuel_Type_Diesel=1 31 | else: 32 | Fuel_Type_Petrol=0 33 | Fuel_Type_Diesel=0 34 | 35 | Year=2020-Year 36 | Seller_Type_Individual=request.form['Seller_Type_Individual'] 37 | if(Seller_Type_Individual=='Individual'): 38 | Seller_Type_Individual=1 39 | else: 40 | Seller_Type_Individual=0 41 | Transmission_Mannual=request.form['Transmission_Mannual'] 42 | if(Transmission_Mannual=='Mannual'): 43 | Transmission_Mannual=1 44 | else: 45 | Transmission_Mannual=0 46 | prediction=model.predict([[Present_Price,Kms_Driven2,Owner,Year,Fuel_Type_Diesel,Fuel_Type_Petrol,Seller_Type_Individual,Transmission_Mannual]]) 47 | output=round(prediction[0],2) 48 | if output<0: 49 | return render_template('index.html',prediction_texts="Sorry you cannot sell this car") 50 | else: 51 | return render_template('index.html',prediction_text="You Can Sell The Car at {}".format(output)) 52 | else: 53 | return render_template('index.html') 54 | 55 | if __name__=="__main__": 56 | app.run(debug=True) 57 | 58 | -------------------------------------------------------------------------------- /awesome production machine learning/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alejandro Saucedo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /awesome production machine learning/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker 2 | -------------------------------------------------------------------------------- /awesome production machine learning/images/awesome.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /awesome production machine learning/images/guidelines.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/awesome production machine learning/images/guidelines.jpg -------------------------------------------------------------------------------- /awesome production machine learning/images/mleng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/awesome production machine learning/images/mleng.png -------------------------------------------------------------------------------- /awesome production machine learning/images/mlops1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/awesome production machine learning/images/mlops1.png -------------------------------------------------------------------------------- /awesome production machine learning/images/video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/awesome production machine learning/images/video.png -------------------------------------------------------------------------------- /face_unlock/README.md: -------------------------------------------------------------------------------- 1 | # Lock/Unlock Ubuntu OS 2 | 3 | ## Introduction 4 | We can lock and unlock our Ubuntu system using face recognition(currently only on Ubuntu). 5 | 6 | ## Article about implementation 7 | [Automatically Locking & Unlocking Ubuntu with Computer Vision Using a Human Face!!!](https://medium.com/p/automatically-locking-unlocking-ubuntu-with-computer-vision-using-a-human-face-db35cbe312f7?source=email-7d2dbe2d619d--writer.postDistributed&sk=b7d25089643c2c719eb6e36aecfef085) 8 | 9 | ## Demo 10 | ![Demo video](demo.gif) 11 | 12 | ## Requirements 13 | 14 | Install below the required library in your local machine. 15 | 16 | 1) python 3.7 17 | 2) opencv 4.1.0 18 | 3) numpy 19 | 4) face-recognition 20 | 5) sudo apt-get install gnome-screensaver 21 | 6) sudo apt-get install xdotool 22 | 23 | ## Quick Start 24 | I have used three python files to solve this issue. 25 | 26 | 1) **face_generate.py** 27 |  This will detect your face and save it in the dataset folder then the new folder will create with your name. 28 |   29 | 2) **face_train.py** 30 |  This python file will open the dataset folder and take your image from that and train your face using the K-nearest neighbor algorithm and face_recognition library. 31 |   32 | 3) **face_unlock.py** 33 |  This is an important python file that will detect your face using the webcam and unlock the system. 34 | 35 | ## Having problems? 36 | 37 | If you run into problems, Please feel free to connect me on [Linkedin](https://www.linkedin.com/in/bala-venkatesh-67964247/) and [Twitter](https://twitter.com/balavenkatesh22) 38 | 39 | 40 | ## Contributing 41 | 42 | Code contributions are also very welcome. feel free to open an issue for that too. 43 | 44 | 45 | To do: 46 | - [ ] Support Windows and Mac OS. 47 | - [ ] Train face using browser(UI). 48 | - [ ] Increase performance and speed. 49 | 50 | 51 | ## About me 52 | 53 | **Piyush Pathak** 54 | 55 | [**PORTFOLIO**](https://anirudhrapathak3.wixsite.com/piyush) 56 | 57 | [**GITHUB**](https://github.com/piyushpathak03) 58 | 59 | [**BLOG**](https://medium.com/@piyushpathak03) 60 | 61 | 62 | # 📫 Follw me: 63 | 64 | [![Linkedin Badge](https://img.shields.io/badge/-PiyushPathak-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/piyushpathak03/)](https://www.linkedin.com/in/piyushpathak03/) 65 | 66 |

67 | -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/0.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/1.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/10.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/11.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/12.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/13.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/14.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/15.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/16.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/17.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/18.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/19.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/2.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/20.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/21.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/22.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/23.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/24.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/25.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/26.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/27.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/28.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/28.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/29.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/3.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/30.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/31.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/32.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/33.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/34.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/35.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/36.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/37.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/38.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/39.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/4.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/40.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/41.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/42.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/43.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/44.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/44.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/45.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/45.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/46.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/46.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/47.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/47.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/48.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/48.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/49.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/49.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/5.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/50.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/50.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/51.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/51.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/6.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/7.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/8.jpg -------------------------------------------------------------------------------- /face_unlock/dataset/bala venkatesh/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/dataset/bala venkatesh/9.jpg -------------------------------------------------------------------------------- /face_unlock/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/demo.gif -------------------------------------------------------------------------------- /face_unlock/face_generate.py: -------------------------------------------------------------------------------- 1 | 2 | # import the necessary packages 3 | from imutils import face_utils 4 | import numpy as np 5 | import argparse 6 | import imutils 7 | import dlib 8 | import cv2 9 | import h5py 10 | import _pickle as cPickle 11 | 12 | import os 13 | 14 | # construct the argument parser and parse the arguments 15 | ap = argparse.ArgumentParser() 16 | ap.add_argument("-v", "--video", help="path to the (optional) video file") 17 | args = vars(ap.parse_args()) 18 | 19 | number=0; 20 | frame_count=0 21 | detector = dlib.get_frontal_face_detector() 22 | print("enter the person name") 23 | name = input() 24 | folder_name="dataset/"+name 25 | 26 | if os.path.exists(folder_name): 27 | print ("Folder exist") 28 | else: 29 | os.mkdir(folder_name) 30 | 31 | # if a video path was not supplied, grab the reference to the webcam 32 | if not args.get("video", False): 33 | 34 | camera = cv2.VideoCapture(0) 35 | 36 | # otherwise, grab a reference to the video file 37 | else: 38 | camera = cv2.VideoCapture(args["video"]) 39 | 40 | 41 | while True: 42 | 43 | if frame_count % 5 == 0: 44 | 45 | print("keyframe") 46 | 47 | # grab the current frame 48 | (grabbed, image) = camera.read() 49 | # if we are viewing a video and we did not grab a 50 | # frame, then we have reached the end of the video 51 | if args.get("video") and not grabbed: 52 | break 53 | image = imutils.resize(image, width=500) 54 | gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 55 | # detect faces in the grayscale image 56 | rects = detector(gray, 1) 57 | # loop over the face detections 58 | for (i, rect) in enumerate(rects): 59 | # determine the facial landmarks for the face region, then 60 | (x, y, w, h) = face_utils.rect_to_bb(rect) 61 | #print rect.dtype 62 | cro=image[y: y + h, x: x + w] 63 | 64 | out_image = cv2.resize(cro,(108,108)) 65 | 66 | fram= os.path.join(folder_name+"/",str(number)+ "." + "jpg") 67 | number+=1 68 | cv2.imwrite(fram,out_image) 69 | cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) 70 | frame_count+=1 71 | 72 | else: 73 | 74 | frame_count+=1 75 | print("redudant frame") 76 | 77 | if number >51: 78 | break 79 | #cv2.imshow("output", image) 80 | cv2.imshow("output image",image) 81 | if cv2.waitKey(1) & 0xFF == ord('q'): 82 | break 83 | 84 | # clean up the camera and close any open windows 85 | camera.release() 86 | cv2.destroyAllWindows() -------------------------------------------------------------------------------- /face_unlock/face_train.py: -------------------------------------------------------------------------------- 1 | import math 2 | from sklearn import neighbors 3 | import os 4 | import os.path 5 | import pickle 6 | from PIL import Image, ImageDraw 7 | import face_recognition 8 | from face_recognition.face_recognition_cli import image_files_in_folder 9 | import numpy as np 10 | 11 | ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'} 12 | 13 | 14 | def train(train_dir, model_save_path=None, n_neighbors=None, knn_algo='ball_tree', verbose=False): 15 | 16 | # The training data would be all the face encodings from all the known images and the labels are their names 17 | encodings = [] 18 | names = [] 19 | 20 | # Training directory 21 | 22 | train_dir = os.listdir('dataset/') 23 | print(train_dir) 24 | 25 | # Loop through each person in the training directory 26 | for person in train_dir: 27 | pix = os.listdir("dataset/" + person) 28 | 29 | # Loop through each training image for the current person 30 | for person_img in pix: 31 | # Get the face encodings for the face in each image file 32 | print("dataset/" + person + "/" + person_img) 33 | face = face_recognition.load_image_file("dataset/" + person + "/" + person_img) 34 | print(face.shape) 35 | # Assume the whole image is the location of the face 36 | #height, width, _ = face.shape 37 | # location is in css order - top, right, bottom, left 38 | height, width, _ = face.shape 39 | face_location = (0, width, height, 0) 40 | print(width,height) 41 | 42 | face_enc = face_recognition.face_encodings(face, known_face_locations=[face_location]) 43 | 44 | 45 | 46 | face_enc = np.array(face_enc) 47 | face_enc = face_enc.flatten() 48 | 49 | # Add face encoding for current image with corresponding label (name) to the training data 50 | encodings.append(face_enc) 51 | names.append(person) 52 | 53 | print(np.array(encodings).shape) 54 | print(np.array(names).shape) 55 | # Create and train the KNN classifier 56 | knn_clf = neighbors.KNeighborsClassifier(n_neighbors=n_neighbors, algorithm=knn_algo, weights='distance') 57 | knn_clf.fit(encodings,names) 58 | 59 | # Save the trained KNN classifier 60 | if model_save_path is not None: 61 | with open(model_save_path, 'wb') as f: 62 | pickle.dump(knn_clf, f) 63 | 64 | return knn_clf 65 | 66 | 67 | 68 | if __name__ == "__main__": 69 | # STEP 1: Train the KNN classifier and save it to disk 70 | # Once the model is trained and saved, you can skip this step next time. 71 | print("Training KNN classifier...") 72 | classifier = train("dataset", model_save_path="trained_knn_model.clf", n_neighbors=2) 73 | print("Training complete!") -------------------------------------------------------------------------------- /face_unlock/face_unlock.py: -------------------------------------------------------------------------------- 1 | # import the necessary packages 2 | from imutils import face_utils 3 | import numpy as np 4 | import argparse 5 | import imutils 6 | import dlib 7 | import cv2 8 | import h5py 9 | #import _pickle as cPickle 10 | import pickle 11 | import face_recognition 12 | 13 | import os 14 | from PIL import Image, ImageDraw 15 | 16 | # construct the argument parser and parse the arguments 17 | ap = argparse.ArgumentParser() 18 | ap.add_argument("-v", "--video", help="path to the (optional) video file") 19 | args = vars(ap.parse_args()) 20 | 21 | with open("trained_knn_model.clf", 'rb') as f: 22 | knn_clf = pickle.load(f) 23 | 24 | # if a video path was not supplied, grab the reference to the webcam 25 | if not args.get("video", False): 26 | 27 | camera = cv2.VideoCapture(0) 28 | 29 | # otherwise, grab a reference to the video file 30 | else: 31 | camera = cv2.VideoCapture(args["video"]) 32 | 33 | 34 | while True: 35 | 36 | # grab the current frame 37 | (grabbed, image1) = camera.read() 38 | # if we are viewing a video and we did not grab a 39 | # frame, then we have reached the end of the video 40 | if args.get("video") and not grabbed: 41 | break 42 | 43 | image = image1[:, :, ::-1] 44 | 45 | X_face_locations = face_recognition.face_locations(image) 46 | 47 | # If no faces are found in the image, return an empty result. 48 | if len(X_face_locations) != 0: 49 | 50 | # Find encodings for faces in the test iamge 51 | faces_encodings = face_recognition.face_encodings(image, known_face_locations=X_face_locations) 52 | 53 | # Use the KNN model to find the best matches for the test face 54 | print(np.array(faces_encodings).shape) 55 | closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=1) 56 | are_matches = [closest_distances[0][i][0] <= 0.4 for i in range(len(X_face_locations))] 57 | 58 | #draw = ImageDraw.Draw(image) 59 | 60 | # Predict classes and remove classifications that aren't within the threshold 61 | predictions = [(pred, loc) if rec else ("unknown", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_face_locations, are_matches)] 62 | for name, (top, right, bottom, left) in predictions: 63 | # Draw a box around the face using the Pillow module 64 | #draw.rectangle(((left, top), (right, bottom)), outline=(0, 0, 255)) 65 | if name not in "unknown": 66 | os.popen('gnome-screensaver-command -d && xdotool key Return') 67 | 68 | # There's a bug in Pillow where it blows up with non-UTF-8 text 69 | # when using the default bitmap font 70 | #name = name.encode("UTF-8") 71 | #rect = (left,top,right,bottom) 72 | #(x, y, w, h) = face_utils.rect_to_bb(rect) 73 | cv2.rectangle(image1, (left,bottom),(right,top), (0, 255, 0), 2) 74 | 75 | # show the face number 76 | cv2.putText(image1, "{}".format(name), (left-10, top-10),cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) 77 | 78 | # Draw a label with a name below the face 79 | #text_width, text_height = draw.textsize(name) 80 | #draw.rectangle(((left, bottom - text_height - 10), (right, bottom)), fill=(0, 0, 255), outline=(0, 0, 255)) 81 | #draw.text((left + 6, bottom - text_height - 5), name, fill=(255, 255, 255, 255)) 82 | else: 83 | os.popen('gnome-screensaver-command -a') 84 | #print(predictions) 85 | #cv2.imshow("output", image) 86 | cv2.imshow("output image",image1) 87 | if cv2.waitKey(1) & 0xFF == ord('q'): 88 | break 89 | 90 | # clean up the camera and close any open windows 91 | camera.release() 92 | cv2.destroyAllWindows() -------------------------------------------------------------------------------- /face_unlock/trained_knn_model.clf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/face_unlock/trained_knn_model.clf -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | import jsonify 3 | import requests 4 | import pickle 5 | import numpy as np 6 | import sklearn 7 | from sklearn.preprocessing import StandardScaler 8 | app = Flask(__name__) 9 | model = pickle.load(open('random_forest_regression_model.pkl', 'rb')) 10 | @app.route('/',methods=['GET']) 11 | def Home(): 12 | return render_template('index.html') 13 | 14 | 15 | standard_to = StandardScaler() 16 | @app.route("/predict", methods=['POST']) 17 | def predict(): 18 | Fuel_Type_Diesel=0 19 | if request.method == 'POST': 20 | Year = int(request.form['Year']) 21 | Present_Price=float(request.form['Present_Price']) 22 | Kms_Driven=int(request.form['Kms_Driven']) 23 | Kms_Driven2=np.log(Kms_Driven) 24 | Owner=int(request.form['Owner']) 25 | Fuel_Type_Petrol=request.form['Fuel_Type_Petrol'] 26 | if(Fuel_Type_Petrol=='Petrol'): 27 | Fuel_Type_Petrol=1 28 | Fuel_Type_Diesel=0 29 | else: 30 | Fuel_Type_Petrol=0 31 | Fuel_Type_Diesel=1 32 | Year=2020-Year 33 | Seller_Type_Individual=request.form['Seller_Type_Individual'] 34 | if(Seller_Type_Individual=='Individual'): 35 | Seller_Type_Individual=1 36 | else: 37 | Seller_Type_Individual=0 38 | Transmission_Mannual=request.form['Transmission_Mannual'] 39 | if(Transmission_Mannual=='Mannual'): 40 | Transmission_Mannual=1 41 | else: 42 | Transmission_Mannual=0 43 | prediction=model.predict([[Present_Price,Kms_Driven2,Owner,Year,Fuel_Type_Diesel,Fuel_Type_Petrol,Seller_Type_Individual,Transmission_Mannual]]) 44 | output=round(prediction[0],2) 45 | if output<0: 46 | return render_template('index.html',prediction_texts="Sorry you cannot sell this car") 47 | else: 48 | return render_template('index.html',prediction_text="You Can Sell The Car at {}".format(output)) 49 | else: 50 | return render_template('index.html') 51 | 52 | if __name__=="__main__": 53 | app.run(debug=True) 54 | 55 | -------------------------------------------------------------------------------- /random_forest_regression_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piyushpathak03/End-to-End-small-projects/b3a94999cad7cf3a0140635d12a7f41c59cc48b5/random_forest_regression_model.pkl -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2020.6.20 2 | joblib==0.15.1 3 | numpy==1.19.0 4 | scikit-learn==0.23.1 5 | scipy==1.5.0 6 | sklearn==0.0 7 | threadpoolctl==2.1.0 8 | wincertstore==0.2 9 | --------------------------------------------------------------------------------