Commit 26949ed5 authored by Pasindu-Vimukthi's avatar Pasindu-Vimukthi

Model

parent 3d9fcf42
This diff is collapsed.
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "b95bcb5e",
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"import pandas as pd\n",
"import numpy as np\n",
"def predict(colour,select_person,react,select_image,sleeping_hours): \n",
" load_model=pickle.load(open(\"best_model.sav\", 'rb'))\n",
" in_X=pd.read_csv('in_X.csv')\n",
" col_list=['Purple', 'Dark Blue', 'Light Blue', 'Brown', 'Black', 'Green','Yellow', 'Orange', 'Grey']\n",
" react_list=['happy','mid happy','un happy','low sad','angry','sad']\n",
" selimg_list=['angry image','happy image','proud image','sad image','suicide image']\n",
" in_X['perfercol_'+col_list[colour]]=1\n",
" in_X['react_'+react_list[react]]=1\n",
" in_X['sel_image_'+selimg_list[select_image]]=1\n",
" in_X['sleeping hours']=sleeping_hours/12\n",
" for i in range(3):\n",
" in_X['person_category'+str(select_person[i]+1)]=in_X['person_category'+str(select_person[i]+1)]+1\n",
" y_pred=load_model.predict(in_X)\n",
" return(y_pred[0])"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9c468731",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(colour=4,select_person=(0,1,1),react=1,select_image=2,sleeping_hours=10)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a6842280",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(colour=4,select_person=(3,3,3),react=0,select_image=1,sleeping_hours=10)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "4d5f185a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(colour=5,select_person=(0,0,0),react=0,select_image=2,sleeping_hours=6)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6862609",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"id": "b95bcb5e",
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"def predict(colour,select_person1,select_person2,select_person3,react,select_image,sleeping_hours): \n",
" load_model=pickle.load(open(\"best_model.sav\", 'rb'))\n",
" in_X=pd.read_csv('in_X.csv')\n",
" select_person=(select_person1,select_person2,select_person3)\n",
" col_list=['Purple', 'Dark Blue', 'Light Blue', 'Brown', 'Black', 'Green','Yellow', 'Orange', 'Grey']\n",
" react_list=['happy','mid happy','un happy','low sad','angry','sad']\n",
" selimg_list=['angry image','happy image','proud image','sad image','suicide image']\n",
" in_X['perfercol_'+col_list[colour]]=1\n",
" in_X['react_'+react_list[react]]=1\n",
" in_X['sel_image_'+selimg_list[select_image]]=1\n",
" in_X['sleeping hours']=sleeping_hours/12\n",
" for i in range(3):\n",
" in_X['person_category'+str(select_person[i]+1)]=in_X['person_category'+str(select_person[i]+1)]+1\n",
" y_pred=load_model.predict(in_X)\n",
" return(y_pred[0])"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "9c468731",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(4,0,1,1,1,2,10)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "a6842280",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(4,3,3,3,0,1,10)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "4d5f185a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(5,0,0,0,0,2,6)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "a6862609",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(7,0,0,0,0,2,6)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "1e3c521a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(5,3,3,3,5,4,6)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "42974f85",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: flask-ngrok in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (0.0.25)\n",
"Requirement already satisfied: requests in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from flask-ngrok) (2.26.0)\n",
"Requirement already satisfied: Flask>=0.8 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from flask-ngrok) (2.0.2)\n",
"Requirement already satisfied: itsdangerous>=2.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (2.0.1)\n",
"Requirement already satisfied: Werkzeug>=2.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (2.0.2)\n",
"Requirement already satisfied: Jinja2>=3.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (3.0.2)\n",
"Requirement already satisfied: click>=7.1.2 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (8.0.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (2021.10.8)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (2.0.7)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (1.26.7)\n",
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (3.2)\n",
"Requirement already satisfied: colorama in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from click>=7.1.2->Flask>=0.8->flask-ngrok) (0.4.4)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Jinja2>=3.0->Flask>=0.8->flask-ngrok) (2.0.1)\n"
]
}
],
"source": [
"!pip install flask-ngrok"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "7c0caa04",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" * Serving Flask app '__main__' (lazy loading)\n",
" * Environment: production\n",
"\u001b[31m WARNING: This is a development server. Do not use it in a production deployment.\u001b[0m\n",
"\u001b[2m Use a production WSGI server instead.\u001b[0m\n",
" * Debug mode: off\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n",
"Exception in thread Thread-8:\n",
"Traceback (most recent call last):\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\threading.py\", line 973, in _bootstrap_inner\n",
" self.run()\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\threading.py\", line 1286, in run\n",
" self.function(*self.args, **self.kwargs)\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\flask_ngrok.py\", line 70, in start_ngrok\n",
" ngrok_address = _run_ngrok()\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\flask_ngrok.py\", line 31, in _run_ngrok\n",
" ngrok = subprocess.Popen([executable, 'http', '5000'])\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\subprocess.py\", line 951, in __init__\n",
" self._execute_child(args, executable, preexec_fn, close_fds,\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\subprocess.py\", line 1420, in _execute_child\n",
" hp, ht, pid, tid = _winapi.CreateProcess(executable, args,\n",
"OSError: [WinError 193] %1 is not a valid Win32 application\n"
]
}
],
"source": [
"\n",
"from flask_ngrok import run_with_ngrok\n",
"\n",
"from flask import Flask,jsonify\n",
"app=Flask(__name__)\n",
"run_with_ngrok(app) #starts ngrok when the app is running\n",
"@app.route(\"/<int:color>/<int:person1>/<int:person2>/<int:person3>/<int:react>/<int:image>/<int:sleepingH>\")\n",
"def home(color,person1,person2,person3,react,image,sleepingH):\n",
" p = []\n",
" p +=[color,person1,person2,person3,react,image,sleepingH]\n",
"\n",
" \n",
" \n",
" arr = np.array([p])\n",
" predict =predict(arr)\n",
" if predict == [0]:\n",
" result = \"normal\"\n",
" elif predict == [1]:\n",
" result = \"mid mod\" \n",
" elif predict == [2]:\n",
" result = \"Severe\"\n",
" else:\n",
" result = \"extreame\"\n",
"\n",
" return jsonify(result)\n",
"app.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1d4524e2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
This diff is collapsed.
This diff is collapsed.
sleeping hours,perfercol_Black,perfercol_Brown,perfercol_Dark Blue,perfercol_Green,perfercol_Grey,perfercol_Light Blue,perfercol_Orange,perfercol_Purple,perfercol_Yellow,react_angry,react_happy,react_low sad,react_mid happy,react_sad,react_un happy,sel_image_angry image,sel_image_happy image,sel_image_proud image,sel_image_sad image,sel_image_suicide image,person_category1,person_category2,person_category3,person_category4
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
color=['Purple'-0, 'Dark Blue'-1, 'Light Blue'-2, 'Brown'-3, 'Black'-4, 'Green'-5,'Yellow'-6, 'Orange'-7, 'Grey'-8]
person=[["Mark Zuckerberg","Jack Ma", "Sharuk Khan","Malala Yousafzai","Mahathma Gandhi", "Nelson Mandela"]-0
["Kusal Mendis", "Gotabaya Rajapaksha" , "Sakvithi Ranasinghe"]-1
["Osama-bin-Laden", "Idi Amin", "Adolf Hitler"]-2
["Sushant Singh Rajput", "Dasun Nishan", "Marilyn Monroe"]-3]
react=['happy'-0,'mid happy'-1,'un happy'-2,'low sad'-3,'angry'-4,'sad'-5]
select image=['angry image'-0,'happy image'-1,'proud image'-2,'sad image'-3,'suicide image'-4]
sleep hours=number between 1-12
\ No newline at end of file
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "b95bcb5e",
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"import pandas as pd\n",
"import numpy as np\n",
"def predict(colour,select_person,react,select_image,sleeping_hours): \n",
" load_model=pickle.load(open(\"best_model.sav\", 'rb'))\n",
" in_X=pd.read_csv('in_X.csv')\n",
" col_list=['Purple', 'Dark Blue', 'Light Blue', 'Brown', 'Black', 'Green','Yellow', 'Orange', 'Grey']\n",
" react_list=['happy','mid happy','un happy','low sad','angry','sad']\n",
" selimg_list=['angry image','happy image','proud image','sad image','suicide image']\n",
" in_X['perfercol_'+col_list[colour]]=1\n",
" in_X['react_'+react_list[react]]=1\n",
" in_X['sel_image_'+selimg_list[select_image]]=1\n",
" in_X['sleeping hours']=sleeping_hours/12\n",
" for i in range(3):\n",
" in_X['person_category'+str(select_person[i]+1)]=in_X['person_category'+str(select_person[i]+1)]+1\n",
" y_pred=load_model.predict(in_X)\n",
" return(y_pred[0])"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9c468731",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(colour=4,select_person=(0,1,1),react=1,select_image=2,sleeping_hours=10)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a6842280",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(colour=4,select_person=(3,3,3),react=0,select_image=1,sleeping_hours=10)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "4d5f185a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(colour=5,select_person=(0,0,0),react=0,select_image=2,sleeping_hours=6)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6862609",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "b95bcb5e",
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"def predict(colour,select_person1,select_person2,select_person3,react,select_image,sleeping_hours): \n",
" load_model=pickle.load(open(\"best_model.sav\", 'rb'))\n",
" in_X=pd.read_csv('in_X.csv')\n",
" select_person=(select_person1,select_person2,select_person3)\n",
" col_list=['Purple', 'Dark Blue', 'Light Blue', 'Brown', 'Black', 'Green','Yellow', 'Orange', 'Grey']\n",
" react_list=['happy','mid happy','un happy','low sad','angry','sad']\n",
" selimg_list=['angry image','happy image','proud image','sad image','suicide image']\n",
" in_X['perfercol_'+col_list[colour]]=1\n",
" in_X['react_'+react_list[react]]=1\n",
" in_X['sel_image_'+selimg_list[select_image]]=1\n",
" in_X['sleeping hours']=sleeping_hours/12\n",
" for i in range(3):\n",
" in_X['person_category'+str(select_person[i]+1)]=in_X['person_category'+str(select_person[i]+1)]+1\n",
" y_pred=load_model.predict(in_X)\n",
" return(y_pred[0])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "9c468731",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(4,0,1,1,1,2,10)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a6842280",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(4,3,3,3,0,1,10)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "4d5f185a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(5,0,0,0,0,2,6)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "a6862609",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(7,0,0,0,0,2,6)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "1e3c521a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"predict(5,3,3,3,5,4,6)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "42974f85",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: flask-ngrok in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (0.0.25)\n",
"Requirement already satisfied: Flask>=0.8 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from flask-ngrok) (2.0.2)\n",
"Requirement already satisfied: requests in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from flask-ngrok) (2.26.0)\n",
"Requirement already satisfied: click>=7.1.2 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (8.0.3)\n",
"Requirement already satisfied: Jinja2>=3.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (3.0.2)\n",
"Requirement already satisfied: Werkzeug>=2.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (2.0.2)\n",
"Requirement already satisfied: itsdangerous>=2.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Flask>=0.8->flask-ngrok) (2.0.1)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (2.0.7)\n",
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (3.2)\n",
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (2021.10.8)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->flask-ngrok) (1.26.7)\n",
"Requirement already satisfied: colorama in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from click>=7.1.2->Flask>=0.8->flask-ngrok) (0.4.4)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\pasindu\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from Jinja2>=3.0->Flask>=0.8->flask-ngrok) (2.0.1)\n"
]
}
],
"source": [
"!pip install flask-ngrok"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c0caa04",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" * Serving Flask app '__main__' (lazy loading)\n",
" * Environment: production\n",
"\u001b[31m WARNING: This is a development server. Do not use it in a production deployment.\u001b[0m\n",
"\u001b[2m Use a production WSGI server instead.\u001b[0m\n",
" * Debug mode: off\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n",
"Exception in thread Thread-13:\n",
"Traceback (most recent call last):\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\threading.py\", line 973, in _bootstrap_inner\n",
" self.run()\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\threading.py\", line 1286, in run\n",
" self.function(*self.args, **self.kwargs)\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\flask_ngrok.py\", line 70, in start_ngrok\n",
" ngrok_address = _run_ngrok()\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\flask_ngrok.py\", line 31, in _run_ngrok\n",
" ngrok = subprocess.Popen([executable, 'http', '5000'])\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\subprocess.py\", line 951, in __init__\n",
" self._execute_child(args, executable, preexec_fn, close_fds,\n",
" File \"C:\\Users\\Pasindu\\AppData\\Local\\Programs\\Python\\Python39\\lib\\subprocess.py\", line 1420, in _execute_child\n",
" hp, ht, pid, tid = _winapi.CreateProcess(executable, args,\n",
"OSError: [WinError 193] %1 is not a valid Win32 application\n"
]
}
],
"source": [
"\n",
"from flask_ngrok import run_with_ngrok\n",
"\n",
"from flask import Flask,jsonify\n",
"app=Flask(__name__)\n",
"run_with_ngrok(app) #starts ngrok when the app is running\n",
"@app.route(\"/<int:color>/<int:person1>/<int:person2>/<int:person3>/<int:react>/<int:image>/<int:sleepingH>\")\n",
"def home(color,person1,person2,person3,react,image,sleepingH):\n",
" p = []\n",
" p +=[color,person1,person2,person3,react,image,sleepingH]\n",
"\n",
" \n",
" \n",
" arr = p\n",
" predict =predict(arr)\n",
" if predict == [0]:\n",
" result = \"normal\"\n",
" elif predict == [1]:\n",
" result = \"mid mod\" \n",
" elif predict == [2]:\n",
" result = \"Severe\"\n",
" else:\n",
" result = \"extreame\"\n",
"\n",
" return jsonify(result)\n",
"app.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1d4524e2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment