Spaces:
Runtime error
Runtime error
aryanpareek07
commited on
Commit
•
c10d4e9
1
Parent(s):
0c04601
Delete HPGR.ipynb
Browse files- HPGR.ipynb +0 -549
HPGR.ipynb
DELETED
@@ -1,549 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 1,
|
6 |
-
"metadata": {},
|
7 |
-
"outputs": [],
|
8 |
-
"source": [
|
9 |
-
"import pandas as pd \n",
|
10 |
-
"import numpy as np\n",
|
11 |
-
"import gradio as gr\n",
|
12 |
-
"import warnings \n",
|
13 |
-
"warnings.filterwarnings('ignore')"
|
14 |
-
]
|
15 |
-
},
|
16 |
-
{
|
17 |
-
"cell_type": "code",
|
18 |
-
"execution_count": 2,
|
19 |
-
"metadata": {},
|
20 |
-
"outputs": [],
|
21 |
-
"source": [
|
22 |
-
"m = pd.read_pickle(r'Heart_Prediction.pkl')"
|
23 |
-
]
|
24 |
-
},
|
25 |
-
{
|
26 |
-
"cell_type": "code",
|
27 |
-
"execution_count": 3,
|
28 |
-
"metadata": {},
|
29 |
-
"outputs": [
|
30 |
-
{
|
31 |
-
"name": "stdout",
|
32 |
-
"output_type": "stream",
|
33 |
-
"text": [
|
34 |
-
"Running on local URL: http://127.0.0.1:7860\n",
|
35 |
-
"\n",
|
36 |
-
"Could not create share link. Please check your internet connection or our status page: https://status.gradio.app. \n",
|
37 |
-
"\n",
|
38 |
-
"Also please ensure that your antivirus or firewall is not blocking the binary file located at: c:\\Users\\apary\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\gradio\\frpc_windows_amd64_v0.2\n"
|
39 |
-
]
|
40 |
-
},
|
41 |
-
{
|
42 |
-
"data": {
|
43 |
-
"text/plain": []
|
44 |
-
},
|
45 |
-
"execution_count": 3,
|
46 |
-
"metadata": {},
|
47 |
-
"output_type": "execute_result"
|
48 |
-
}
|
49 |
-
],
|
50 |
-
"source": [
|
51 |
-
"# Creating Function for getting Predictions\n",
|
52 |
-
"def make_prediction(age,cp,slp,thalachh,O2):\n",
|
53 |
-
"\n",
|
54 |
-
" preds = m.predict([[age,cp,slp,thalachh,O2]])\n",
|
55 |
-
" min_age = 29\n",
|
56 |
-
" max_age = 77\n",
|
57 |
-
" min_cp = 0\n",
|
58 |
-
" max_cp = 3\n",
|
59 |
-
" min_slp = 0\n",
|
60 |
-
" max_slp = 2\n",
|
61 |
-
" min_thalachh = 71\n",
|
62 |
-
" max_thalachh = 202\n",
|
63 |
-
" min_O2 = 96.50\n",
|
64 |
-
" max_O2 = 98.60\n",
|
65 |
-
"\n",
|
66 |
-
" try:\n",
|
67 |
-
" age = float(age)\n",
|
68 |
-
" cp = float(cp)\n",
|
69 |
-
" slp = float(slp)\n",
|
70 |
-
" thalachh = float(thalachh)\n",
|
71 |
-
" O2 = float(O2)\n",
|
72 |
-
" if min_age <= age <= max_age and min_cp <= cp <= max_cp and min_slp <= slp <= max_slp and min_thalachh <= thalachh <= max_thalachh and min_O2 <= O2 <= max_O2:\n",
|
73 |
-
" if preds == 1:\n",
|
74 |
-
" return '''You have chances 100 % chances of getting an Heart Attack, Consult your doctor immedetly!!'''\n",
|
75 |
-
" return '''Less chances of Heart Attack!!'''\n",
|
76 |
-
" else:\n",
|
77 |
-
" return f\"Invalid Parameters.\\nEnter valid values only.\"\n",
|
78 |
-
" except ValueError:\n",
|
79 |
-
" return \"Invalid input.\\nEnter valid inputs for all the parameters.\"\n",
|
80 |
-
" \n",
|
81 |
-
"\n",
|
82 |
-
"#Create the input component for Gradio since we are expecting 5 inputs\n",
|
83 |
-
"\n",
|
84 |
-
"age_input = gr.Number(label = \"Enter Your Age \" , step = None)\n",
|
85 |
-
"cp_input = gr.Number(label = \"Enter the cp \" , step = None, info= \"Chest pain type, 0 = typical type 1, 1 = typical type angina 2 = non-angina pain 3 = asymptomatic\")\n",
|
86 |
-
"slp_input = gr.Number(label = \"Enter the slp \", step = None, info= \"Speech-language pathologists (SLPs)\")\n",
|
87 |
-
"thalachh_input = gr.Number(label = \"Enter the thalachh \", step = None, info= \"The Maximum heart rate achieved by your Heart\")\n",
|
88 |
-
"o2_input = gr.Number(label = \"Enter the O2 Saturation \", step = None, info= 'This is the blood oxygen level in your report')\n",
|
89 |
-
"\n",
|
90 |
-
"# We create the output\n",
|
91 |
-
"output = gr.Textbox(label='Result')\n",
|
92 |
-
"\n",
|
93 |
-
"app = gr.Interface(fn = make_prediction, \n",
|
94 |
-
" inputs=[age_input, cp_input, slp_input, thalachh_input, o2_input], \n",
|
95 |
-
" outputs=output,\n",
|
96 |
-
" description= '''Enter all the details asked below and get the predictions of Heart Attack \\n\\nAnd in case you find any bug related to the app or model please use the button named 'Flag' \\n\\n\\nYou can find Examples below \\n\\n\\n\\nwhich are the minimum and maximum values of all parameteres respectivly ''', \n",
|
97 |
-
" # theme=gr.themes.Monochrome(), \n",
|
98 |
-
" theme= gr.themes.Base(),\n",
|
99 |
-
" # theme= gr.themes.Soft(),\n",
|
100 |
-
" title='Heart Attack Predictor ❤️',\n",
|
101 |
-
" examples=[[29,0,0,71,96.50],[77,3,2,202,98.60]],\n",
|
102 |
-
" )\n",
|
103 |
-
"app.launch(auth = ['admin','password'],auth_message='Enter the Username and Password!!',share= True)"
|
104 |
-
]
|
105 |
-
},
|
106 |
-
{
|
107 |
-
"cell_type": "code",
|
108 |
-
"execution_count": null,
|
109 |
-
"metadata": {},
|
110 |
-
"outputs": [],
|
111 |
-
"source": [
|
112 |
-
"# def Predict(age,cp,slp,thalachh,O2):\n",
|
113 |
-
"# #turning the arguments into a numpy array \n",
|
114 |
-
"\n",
|
115 |
-
"# x = np.array(['age','cp','slp','thalachh','O2'])\n",
|
116 |
-
"# prediction = m.predict(x.reshape(1, -1))\n",
|
117 |
-
"# return prediction"
|
118 |
-
]
|
119 |
-
},
|
120 |
-
{
|
121 |
-
"cell_type": "code",
|
122 |
-
"execution_count": null,
|
123 |
-
"metadata": {},
|
124 |
-
"outputs": [
|
125 |
-
{
|
126 |
-
"name": "stdout",
|
127 |
-
"output_type": "stream",
|
128 |
-
"text": [
|
129 |
-
"Running on local URL: http://127.0.0.1:7866\n",
|
130 |
-
"\n",
|
131 |
-
"To create a public link, set `share=True` in `launch()`.\n"
|
132 |
-
]
|
133 |
-
},
|
134 |
-
{
|
135 |
-
"data": {
|
136 |
-
"text/html": [
|
137 |
-
"<div><iframe src=\"http://127.0.0.1:7866/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
138 |
-
],
|
139 |
-
"text/plain": [
|
140 |
-
"<IPython.core.display.HTML object>"
|
141 |
-
]
|
142 |
-
},
|
143 |
-
"metadata": {},
|
144 |
-
"output_type": "display_data"
|
145 |
-
},
|
146 |
-
{
|
147 |
-
"data": {
|
148 |
-
"text/plain": []
|
149 |
-
},
|
150 |
-
"execution_count": 23,
|
151 |
-
"metadata": {},
|
152 |
-
"output_type": "execute_result"
|
153 |
-
}
|
154 |
-
],
|
155 |
-
"source": [
|
156 |
-
"def make_prediction(age,cp,slp,thalachh,O2):\n",
|
157 |
-
" # with open(\"filename.pkl\", \"rb\") as f:\n",
|
158 |
-
" # clf = pickle.load(f)\n",
|
159 |
-
" preds = m.predict([[age,cp,slp,thalachh,O2]])\n",
|
160 |
-
" \n",
|
161 |
-
" if preds == 1:\n",
|
162 |
-
" return '''You are going to a Heart Attack, consult your doctor '''\n",
|
163 |
-
" return \"You are safe from Heart Attack keep it up!!\"\n",
|
164 |
-
"\n",
|
165 |
-
"\n",
|
166 |
-
"#Create the input component for Gradio since we are expecting 5 inputs\n",
|
167 |
-
"\n",
|
168 |
-
"age_input = gr.Number(label = \"Enter Your Age \" , min=29, max=77,step = None)\n",
|
169 |
-
"# age_input = gr.Number(label = \"Enter Your Age \" , minimum=29, maximum=77,step = None)\n",
|
170 |
-
"cp_input = gr.Number(label = \"Enter the cp \" , minimum = 0, maximum = 6)\n",
|
171 |
-
"slp_input = gr.Number(label = \"Enter the slp \")\n",
|
172 |
-
"thalachh_input = gr.Number(label = \"Enter the thalachh \")\n",
|
173 |
-
"o2_input = gr.Number(label = \"Enter the O2 Saturation \")\n",
|
174 |
-
"\n",
|
175 |
-
"# We create the output\n",
|
176 |
-
"output = gr.Textbox(label='Result')\n",
|
177 |
-
"\n",
|
178 |
-
"app = gr.Interface(fn = make_prediction, \n",
|
179 |
-
" inputs=[age_input, cp_input, slp_input, thalachh_input, o2_input], \n",
|
180 |
-
" outputs=output,\n",
|
181 |
-
" description= '''Enter all the details asked below and get the predictions of Heart Attack \\n\\nAnd in case you find any bug related to the app or model please use the button named 'Flag' \\n\\n\\nThank You!!🙏🙏 ''', \n",
|
182 |
-
" # theme=gr.themes.Monochrome(), \n",
|
183 |
-
" title='Heart Attack Predictor ❤️',\n",
|
184 |
-
" examples=[[44,3,33,33,99]],\n",
|
185 |
-
" css = \"\"\"\n",
|
186 |
-
"/* Remove default Gradio styles */\n",
|
187 |
-
".gradio-interface {\n",
|
188 |
-
" font-family: inherit;\n",
|
189 |
-
" background-color: inherit;\n",
|
190 |
-
" color: inherit;\n",
|
191 |
-
" border: none;\n",
|
192 |
-
" box-shadow: none;\n",
|
193 |
-
" padding: 0;\n",
|
194 |
-
"}\n",
|
195 |
-
"\n",
|
196 |
-
".gradio-input-container {\n",
|
197 |
-
" background-color: inherit;\n",
|
198 |
-
" border: none;\n",
|
199 |
-
" padding: 0;\n",
|
200 |
-
"}\n",
|
201 |
-
"\n",
|
202 |
-
".gradio-output-container {\n",
|
203 |
-
" background-color: inherit;\n",
|
204 |
-
" border: none;\n",
|
205 |
-
" padding: 0;\n",
|
206 |
-
"}\n",
|
207 |
-
"\n",
|
208 |
-
"/* Apply your own custom styles */\n",
|
209 |
-
"body {\n",
|
210 |
-
" background-color: #f2f2f2;\n",
|
211 |
-
"}\n",
|
212 |
-
"\n",
|
213 |
-
"input {\n",
|
214 |
-
" border-radius: 4px;\n",
|
215 |
-
" padding: 8px 12px;\n",
|
216 |
-
" border: 1px solid #ccc;\n",
|
217 |
-
"}\n",
|
218 |
-
"\n",
|
219 |
-
"button {\n",
|
220 |
-
" background-color: #1976d2;\n",
|
221 |
-
" color: #fff;\n",
|
222 |
-
" border-radius: 4px;\n",
|
223 |
-
" padding: 8px 16px;\n",
|
224 |
-
" border: none;\n",
|
225 |
-
" cursor: pointer;\n",
|
226 |
-
"}\n",
|
227 |
-
"\"\"\" \n",
|
228 |
-
" )\n",
|
229 |
-
"app.launch()"
|
230 |
-
]
|
231 |
-
},
|
232 |
-
{
|
233 |
-
"cell_type": "code",
|
234 |
-
"execution_count": 3,
|
235 |
-
"metadata": {},
|
236 |
-
"outputs": [
|
237 |
-
{
|
238 |
-
"ename": "NameError",
|
239 |
-
"evalue": "name 'make_prediction' is not defined",
|
240 |
-
"output_type": "error",
|
241 |
-
"traceback": [
|
242 |
-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
243 |
-
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
|
244 |
-
"Cell \u001b[1;32mIn[3], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m make_prediction(\u001b[39m44\u001b[39m,\u001b[39m3\u001b[39m,\u001b[39m33\u001b[39m,\u001b[39m33\u001b[39m,\u001b[39m99\u001b[39m)\n",
|
245 |
-
"\u001b[1;31mNameError\u001b[0m: name 'make_prediction' is not defined"
|
246 |
-
]
|
247 |
-
}
|
248 |
-
],
|
249 |
-
"source": [
|
250 |
-
"make_prediction(44,3,33,33,99)"
|
251 |
-
]
|
252 |
-
},
|
253 |
-
{
|
254 |
-
"cell_type": "code",
|
255 |
-
"execution_count": 5,
|
256 |
-
"metadata": {},
|
257 |
-
"outputs": [
|
258 |
-
{
|
259 |
-
"name": "stdout",
|
260 |
-
"output_type": "stream",
|
261 |
-
"text": [
|
262 |
-
"Running on local URL: http://127.0.0.1:7861\n",
|
263 |
-
"\n",
|
264 |
-
"Could not create share link. Please check your internet connection or our status page: https://status.gradio.app. \n",
|
265 |
-
"\n",
|
266 |
-
"Also please ensure that your antivirus or firewall is not blocking the binary file located at: c:\\Users\\apary\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\gradio\\frpc_windows_amd64_v0.2\n"
|
267 |
-
]
|
268 |
-
},
|
269 |
-
{
|
270 |
-
"data": {
|
271 |
-
"text/html": [
|
272 |
-
"<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
273 |
-
],
|
274 |
-
"text/plain": [
|
275 |
-
"<IPython.core.display.HTML object>"
|
276 |
-
]
|
277 |
-
},
|
278 |
-
"metadata": {},
|
279 |
-
"output_type": "display_data"
|
280 |
-
},
|
281 |
-
{
|
282 |
-
"data": {
|
283 |
-
"text/plain": []
|
284 |
-
},
|
285 |
-
"execution_count": 5,
|
286 |
-
"metadata": {},
|
287 |
-
"output_type": "execute_result"
|
288 |
-
}
|
289 |
-
],
|
290 |
-
"source": [
|
291 |
-
"import gradio as gr\n",
|
292 |
-
"\n",
|
293 |
-
"def greet(age):\n",
|
294 |
-
" return f\"You are {age} years old!\"\n",
|
295 |
-
"\n",
|
296 |
-
"iface = gr.Interface(fn=greet, inputs=gr.inputs.Slider(minimum=18, maximum=65, step=1), outputs=\"text\")\n",
|
297 |
-
"iface.launch(share=True)\n"
|
298 |
-
]
|
299 |
-
},
|
300 |
-
{
|
301 |
-
"cell_type": "markdown",
|
302 |
-
"metadata": {},
|
303 |
-
"source": [
|
304 |
-
"pip install ipywidgets"
|
305 |
-
]
|
306 |
-
},
|
307 |
-
{
|
308 |
-
"attachments": {},
|
309 |
-
"cell_type": "markdown",
|
310 |
-
"metadata": {},
|
311 |
-
"source": [
|
312 |
-
"!pip install --upgrade gradio"
|
313 |
-
]
|
314 |
-
},
|
315 |
-
{
|
316 |
-
"cell_type": "code",
|
317 |
-
"execution_count": 18,
|
318 |
-
"metadata": {},
|
319 |
-
"outputs": [
|
320 |
-
{
|
321 |
-
"name": "stdout",
|
322 |
-
"output_type": "stream",
|
323 |
-
"text": [
|
324 |
-
"Running on local URL: http://127.0.0.1:7871\n",
|
325 |
-
"\n",
|
326 |
-
"To create a public link, set `share=True` in `launch()`.\n"
|
327 |
-
]
|
328 |
-
},
|
329 |
-
{
|
330 |
-
"data": {
|
331 |
-
"text/plain": []
|
332 |
-
},
|
333 |
-
"execution_count": 18,
|
334 |
-
"metadata": {},
|
335 |
-
"output_type": "execute_result"
|
336 |
-
}
|
337 |
-
],
|
338 |
-
"source": [
|
339 |
-
"def make_prediction(age,cp,slp,thalachh,O2):\n",
|
340 |
-
"\n",
|
341 |
-
" preds = m.predict([[age,cp,slp,thalachh,O2]])\n",
|
342 |
-
" min_age = 29\n",
|
343 |
-
" max_age = 77\n",
|
344 |
-
" min_cp = 0\n",
|
345 |
-
" max_cp = 3\n",
|
346 |
-
" min_slp = 0\n",
|
347 |
-
" max_slp = 2\n",
|
348 |
-
" min_thalachh = 71\n",
|
349 |
-
" max_thalachh = 202\n",
|
350 |
-
" min_O2 = 96.50\n",
|
351 |
-
" max_O2 = 98.60\n",
|
352 |
-
"\n",
|
353 |
-
" try:\n",
|
354 |
-
" age = float(age)\n",
|
355 |
-
" cp = float(cp)\n",
|
356 |
-
" slp = float(slp)\n",
|
357 |
-
" thalachh = float(thalachh)\n",
|
358 |
-
" O2 = float(O2)\n",
|
359 |
-
" if min_age <= age <= max_age and min_cp <= cp <= max_cp and min_slp <= slp <= max_slp and min_thalachh <= thalachh <= max_thalachh and min_O2 <= O2 <= max_O2:\n",
|
360 |
-
" if preds == 1:\n",
|
361 |
-
" return '''You have chances 100 % chances of getting an Heart Attack, Consult your doctor immedetly!!'''\n",
|
362 |
-
" return '''Less chances of Heart Attack!!'''\n",
|
363 |
-
" else:\n",
|
364 |
-
" return f\"Invalid Parameters.\\nEnter valid values only.\"\n",
|
365 |
-
" except ValueError:\n",
|
366 |
-
" return \"Invalid input.\\nEnter valid inputs for all the parameters.\"\n",
|
367 |
-
" \n",
|
368 |
-
"\n",
|
369 |
-
"#Create the input component for Gradio since we are expecting 5 inputs\n",
|
370 |
-
"\n",
|
371 |
-
"age_input = gr.Number(label = \"Enter Your Age \" , step = None)\n",
|
372 |
-
"cp_input = gr.Number(label = \"Enter the cp \" )\n",
|
373 |
-
"slp_input = gr.Number(label = \"Enter the slp \")\n",
|
374 |
-
"thalachh_input = gr.Number(label = \"Enter the thalachh \")\n",
|
375 |
-
"o2_input = gr.Number(label = \"Enter the O2 Saturation \")\n",
|
376 |
-
"\n",
|
377 |
-
"# We create the output\n",
|
378 |
-
"output = gr.Textbox(label='Result')\n",
|
379 |
-
"\n",
|
380 |
-
"app = gr.Interface(fn = make_prediction, \n",
|
381 |
-
" inputs=[age_input, cp_input, slp_input, thalachh_input, o2_input], \n",
|
382 |
-
" outputs=output,\n",
|
383 |
-
" description= '''Enter all the details asked below and get the predictions of Heart Attack \\n\\nAnd in case you find any bug related to the app or model please use the button named 'Flag' \\n\\n\\nYou can find Examples below \\n\\n\\n\\nwhich are the minimum and maximum values of all parameteres respectivly ''', \n",
|
384 |
-
" # theme=gr.themes.Monochrome(), \n",
|
385 |
-
" theme= gr.themes.Base(),\n",
|
386 |
-
" # theme= gr.themes.Soft(),\n",
|
387 |
-
" title='Heart Attack Predictor ❤️',\n",
|
388 |
-
" examples=[[29,0,0,71,96.50],[77,3,2,202,98.60]],\n",
|
389 |
-
"# css = \"\"\"\n",
|
390 |
-
"# /* Remove default Gradio styles */\n",
|
391 |
-
"# .gradio-interface {\n",
|
392 |
-
"# font-family: inherit;\n",
|
393 |
-
"# background-color: inherit;\n",
|
394 |
-
"# color: inherit;\n",
|
395 |
-
"# border: none;\n",
|
396 |
-
"# box-shadow: none;\n",
|
397 |
-
"# padding: 0;\n",
|
398 |
-
"# }\n",
|
399 |
-
"\n",
|
400 |
-
"# .gradio-input-container {\n",
|
401 |
-
"# background-color: inherit;\n",
|
402 |
-
"# border: none;\n",
|
403 |
-
"# padding: 0;\n",
|
404 |
-
"# }\n",
|
405 |
-
"\n",
|
406 |
-
"# .gradio-output-container {\n",
|
407 |
-
"# background-color: inherit;\n",
|
408 |
-
"# border: none;\n",
|
409 |
-
"# padding: 0;\n",
|
410 |
-
"# }\n",
|
411 |
-
"\n",
|
412 |
-
"# /* Apply your own custom styles */\n",
|
413 |
-
"# body {\n",
|
414 |
-
"# background-color: #f2f2f2;\n",
|
415 |
-
"# }\n",
|
416 |
-
"\n",
|
417 |
-
"# input {\n",
|
418 |
-
"# border-radius: 4px;\n",
|
419 |
-
"# padding: 8px 12px;\n",
|
420 |
-
"# border: 1px solid #ccc;\n",
|
421 |
-
"# }\n",
|
422 |
-
"\n",
|
423 |
-
"# button {\n",
|
424 |
-
"# background-color: #1976d2;\n",
|
425 |
-
"# color: #fff;\n",
|
426 |
-
"# border-radius: 4px;\n",
|
427 |
-
"# padding: 8px 16px;\n",
|
428 |
-
"# border: none;\n",
|
429 |
-
"# cursor: pointer;\n",
|
430 |
-
"# }\n",
|
431 |
-
"# \"\"\" \n",
|
432 |
-
" )\n",
|
433 |
-
"# def userpass(u,p):\n",
|
434 |
-
"# while True:\n",
|
435 |
-
"# sNewUser1 = input(\"\"\"Please enter a new username.\n",
|
436 |
-
"# The username must NOT contain any spaces, it must have at least 5 characters and\n",
|
437 |
-
"# it cannot include any special characters: \\n\\n\"\"\")\n",
|
438 |
-
"\n",
|
439 |
-
"# if len(sNewUser1) < 5:\n",
|
440 |
-
"# \"Your username is too short, please enter 5 or more characters! Please try again!\\n\"\n",
|
441 |
-
"\n",
|
442 |
-
"# elif sNewUser1.count(\" \") > 0:\n",
|
443 |
-
"# \"Your username contains one or more spaces, this is not allowed! Please try again! \\n\"\n",
|
444 |
-
"\n",
|
445 |
-
"# elif sNewUser1.isalnum() == False:\n",
|
446 |
-
"# \"Your username contains a special character please try again! \\n\"\n",
|
447 |
-
"\n",
|
448 |
-
"# else:\n",
|
449 |
-
"# userpass()\n",
|
450 |
-
"# break\n",
|
451 |
-
"\n",
|
452 |
-
"# while True:\n",
|
453 |
-
"# sNewPass1 = input(\"\"\"\\n\\nPlease enter a new password.\n",
|
454 |
-
"# It must contain:\n",
|
455 |
-
"# At least one Capital letter\n",
|
456 |
-
"# At least one lower case letter\n",
|
457 |
-
"# At least one special character\n",
|
458 |
-
"# It has to be at least 6 characters in length:\\n\\n\"\"\")\n",
|
459 |
-
"\n",
|
460 |
-
"# if len(sNewPass1) < 6:\n",
|
461 |
-
"# \"Your username is too short, please enter 5 or more characters! Please try again!\\n\"\n",
|
462 |
-
" \n",
|
463 |
-
"\n",
|
464 |
-
"app.launch(auth = ['admin','password'],auth_message='Enter the Username and Password!!')"
|
465 |
-
]
|
466 |
-
},
|
467 |
-
{
|
468 |
-
"cell_type": "code",
|
469 |
-
"execution_count": null,
|
470 |
-
"metadata": {},
|
471 |
-
"outputs": [
|
472 |
-
{
|
473 |
-
"name": "stdout",
|
474 |
-
"output_type": "stream",
|
475 |
-
"text": [
|
476 |
-
"Running on local URL: http://127.0.0.1:7869\n",
|
477 |
-
"\n",
|
478 |
-
"To create a public link, set `share=True` in `launch()`.\n"
|
479 |
-
]
|
480 |
-
},
|
481 |
-
{
|
482 |
-
"data": {
|
483 |
-
"text/html": [
|
484 |
-
"<div><iframe src=\"http://127.0.0.1:7869/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
485 |
-
],
|
486 |
-
"text/plain": [
|
487 |
-
"<IPython.core.display.HTML object>"
|
488 |
-
]
|
489 |
-
},
|
490 |
-
"metadata": {},
|
491 |
-
"output_type": "display_data"
|
492 |
-
},
|
493 |
-
{
|
494 |
-
"data": {
|
495 |
-
"text/plain": []
|
496 |
-
},
|
497 |
-
"execution_count": 31,
|
498 |
-
"metadata": {},
|
499 |
-
"output_type": "execute_result"
|
500 |
-
}
|
501 |
-
],
|
502 |
-
"source": [
|
503 |
-
"import gradio as gr\n",
|
504 |
-
"\n",
|
505 |
-
"def greet(age):\n",
|
506 |
-
" min_age = 18 # Minimum allowed age\n",
|
507 |
-
" max_age = 65 # Maximum allowed age\n",
|
508 |
-
" try:\n",
|
509 |
-
" age = float(age)\n",
|
510 |
-
" if min_age <= age <= max_age:\n",
|
511 |
-
" return f\"You are {age} years old!\"\n",
|
512 |
-
" else:\n",
|
513 |
-
" return f\"Invalid age. Please enter an age between {min_age} and {max_age}.\"\n",
|
514 |
-
" except ValueError:\n",
|
515 |
-
" return \"Invalid input. Please enter a numeric age.\"\n",
|
516 |
-
"\n",
|
517 |
-
"iface = gr.Interface(fn=greet, inputs=\"text\", outputs=\"text\")\n",
|
518 |
-
"iface.launch()\n"
|
519 |
-
]
|
520 |
-
}
|
521 |
-
],
|
522 |
-
"metadata": {
|
523 |
-
"kernelspec": {
|
524 |
-
"display_name": "Python 3",
|
525 |
-
"language": "python",
|
526 |
-
"name": "python3"
|
527 |
-
},
|
528 |
-
"language_info": {
|
529 |
-
"codemirror_mode": {
|
530 |
-
"name": "ipython",
|
531 |
-
"version": 3
|
532 |
-
},
|
533 |
-
"file_extension": ".py",
|
534 |
-
"mimetype": "text/x-python",
|
535 |
-
"name": "python",
|
536 |
-
"nbconvert_exporter": "python",
|
537 |
-
"pygments_lexer": "ipython3",
|
538 |
-
"version": "3.9.5"
|
539 |
-
},
|
540 |
-
"orig_nbformat": 4,
|
541 |
-
"vscode": {
|
542 |
-
"interpreter": {
|
543 |
-
"hash": "36dbd9e66a8594264431eb8261a6da189bbe6ec12cb3505050e0fa15a349cadd"
|
544 |
-
}
|
545 |
-
}
|
546 |
-
},
|
547 |
-
"nbformat": 4,
|
548 |
-
"nbformat_minor": 2
|
549 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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