Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ML and DL projects #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,621 changes: 1,621 additions & 0 deletions Diabetes_prediction.ipynb

Large diffs are not rendered by default.

1,242 changes: 1,242 additions & 0 deletions Fule_consumption.ipynb

Large diffs are not rendered by default.

2,094 changes: 2,094 additions & 0 deletions Heart_Disease_Prediction.ipynb

Large diffs are not rendered by default.

246 changes: 246 additions & 0 deletions Image_to_Pencil_Sketch_App.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "nyMrgVJ8Mkh2"
},
"source": [
"Important Dependencies"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: opencv-python in /home/yash/.local/lib/python3.10/site-packages (4.9.0.80)\n",
"Requirement already satisfied: numpy>=1.17.3 in /home/yash/.local/lib/python3.10/site-packages (from opencv-python) (1.26.3)\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: gradio in /home/yash/.local/lib/python3.10/site-packages (4.16.0)\n",
"Requirement already satisfied: typing-extensions~=4.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (4.9.0)\n",
"Requirement already satisfied: altair<6.0,>=4.2.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (5.2.0)\n",
"Requirement already satisfied: importlib-resources<7.0,>=1.3 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (6.1.1)\n",
"Requirement already satisfied: numpy~=1.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (1.26.3)\n",
"Requirement already satisfied: pydub in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.25.1)\n",
"Requirement already satisfied: tomlkit==0.12.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.12.0)\n",
"Requirement already satisfied: fastapi in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.109.0)\n",
"Requirement already satisfied: gradio-client==0.8.1 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.8.1)\n",
"Requirement already satisfied: markupsafe~=2.0 in /usr/lib/python3/dist-packages (from gradio) (2.0.1)\n",
"Requirement already satisfied: matplotlib~=3.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (3.8.2)\n",
"Requirement already satisfied: python-multipart in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.0.6)\n",
"Requirement already satisfied: semantic-version~=2.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (2.10.0)\n",
"Requirement already satisfied: packaging in /home/yash/.local/lib/python3.10/site-packages (from gradio) (23.2)\n",
"Requirement already satisfied: jinja2<4.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (3.1.3)\n",
"Requirement already satisfied: pyyaml<7.0,>=5.0 in /usr/lib/python3/dist-packages (from gradio) (5.4.1)\n",
"Requirement already satisfied: pydantic>=2.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (2.5.3)\n",
"Requirement already satisfied: orjson~=3.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (3.9.12)\n",
"Requirement already satisfied: huggingface-hub>=0.19.3 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.20.3)\n",
"Requirement already satisfied: aiofiles<24.0,>=22.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (23.2.1)\n",
"Requirement already satisfied: typer[all]<1.0,>=0.9 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.9.0)\n",
"Requirement already satisfied: pandas<3.0,>=1.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (2.2.0)\n",
"Requirement already satisfied: pillow<11.0,>=8.0 in /usr/lib/python3/dist-packages (from gradio) (9.0.1)\n",
"Requirement already satisfied: ffmpy in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.3.1)\n",
"Requirement already satisfied: httpx in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.26.0)\n",
"Requirement already satisfied: ruff>=0.1.7 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.1.14)\n",
"Requirement already satisfied: uvicorn>=0.14.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio) (0.27.0)\n",
"Requirement already satisfied: websockets<12.0,>=10.0 in /home/yash/.local/lib/python3.10/site-packages (from gradio-client==0.8.1->gradio) (11.0.3)\n",
"Requirement already satisfied: fsspec in /home/yash/.local/lib/python3.10/site-packages (from gradio-client==0.8.1->gradio) (2023.12.2)\n",
"Requirement already satisfied: jsonschema>=3.0 in /home/yash/.local/lib/python3.10/site-packages (from altair<6.0,>=4.2.0->gradio) (4.21.1)\n",
"Requirement already satisfied: toolz in /home/yash/.local/lib/python3.10/site-packages (from altair<6.0,>=4.2.0->gradio) (0.12.1)\n",
"Requirement already satisfied: requests in /home/yash/.local/lib/python3.10/site-packages (from huggingface-hub>=0.19.3->gradio) (2.31.0)\n",
"Requirement already satisfied: filelock in /home/yash/.local/lib/python3.10/site-packages (from huggingface-hub>=0.19.3->gradio) (3.13.1)\n",
"Requirement already satisfied: tqdm>=4.42.1 in /home/yash/.local/lib/python3.10/site-packages (from huggingface-hub>=0.19.3->gradio) (4.66.1)\n",
"Requirement already satisfied: kiwisolver>=1.3.1 in /home/yash/.local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (1.4.5)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /home/yash/.local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (4.47.2)\n",
"Requirement already satisfied: contourpy>=1.0.1 in /home/yash/.local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (1.2.0)\n",
"Requirement already satisfied: cycler>=0.10 in /home/yash/.local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (0.12.1)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /home/yash/.local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio) (2.8.2)\n",
"Requirement already satisfied: pyparsing>=2.3.1 in /usr/lib/python3/dist-packages (from matplotlib~=3.0->gradio) (2.4.7)\n",
"Requirement already satisfied: tzdata>=2022.7 in /home/yash/.local/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio) (2023.4)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/lib/python3/dist-packages (from pandas<3.0,>=1.0->gradio) (2022.1)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in /home/yash/.local/lib/python3.10/site-packages (from pydantic>=2.0->gradio) (0.6.0)\n",
"Requirement already satisfied: pydantic-core==2.14.6 in /home/yash/.local/lib/python3.10/site-packages (from pydantic>=2.0->gradio) (2.14.6)\n",
"Requirement already satisfied: click<9.0.0,>=7.1.1 in /usr/lib/python3/dist-packages (from typer[all]<1.0,>=0.9->gradio) (8.0.3)\n",
"Requirement already satisfied: colorama<0.5.0,>=0.4.3 in /usr/lib/python3/dist-packages (from typer[all]<1.0,>=0.9->gradio) (0.4.4)\n",
"Requirement already satisfied: shellingham<2.0.0,>=1.3.0 in /home/yash/.local/lib/python3.10/site-packages (from typer[all]<1.0,>=0.9->gradio) (1.5.4)\n",
"Requirement already satisfied: rich<14.0.0,>=10.11.0 in /home/yash/.local/lib/python3.10/site-packages (from typer[all]<1.0,>=0.9->gradio) (13.7.0)\n",
"Requirement already satisfied: h11>=0.8 in /home/yash/.local/lib/python3.10/site-packages (from uvicorn>=0.14.0->gradio) (0.14.0)\n",
"Requirement already satisfied: starlette<0.36.0,>=0.35.0 in /home/yash/.local/lib/python3.10/site-packages (from fastapi->gradio) (0.35.1)\n",
"Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from httpx->gradio) (2020.6.20)\n",
"Requirement already satisfied: sniffio in /home/yash/.local/lib/python3.10/site-packages (from httpx->gradio) (1.3.0)\n",
"Requirement already satisfied: httpcore==1.* in /home/yash/.local/lib/python3.10/site-packages (from httpx->gradio) (1.0.2)\n",
"Requirement already satisfied: idna in /usr/lib/python3/dist-packages (from httpx->gradio) (3.3)\n",
"Requirement already satisfied: anyio in /home/yash/.local/lib/python3.10/site-packages (from httpx->gradio) (4.2.0)\n",
"Requirement already satisfied: attrs>=22.2.0 in /home/yash/.local/lib/python3.10/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (23.2.0)\n",
"Requirement already satisfied: rpds-py>=0.7.1 in /home/yash/.local/lib/python3.10/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.17.1)\n",
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /home/yash/.local/lib/python3.10/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (2023.12.1)\n",
"Requirement already satisfied: referencing>=0.28.4 in /home/yash/.local/lib/python3.10/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.32.1)\n",
"Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n",
"Requirement already satisfied: markdown-it-py>=2.2.0 in /home/yash/.local/lib/python3.10/site-packages (from rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (3.0.0)\n",
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /home/yash/.local/lib/python3.10/site-packages (from rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (2.17.2)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /home/yash/.local/lib/python3.10/site-packages (from anyio->httpx->gradio) (1.2.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /home/yash/.local/lib/python3.10/site-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.3.2)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3/dist-packages (from requests->huggingface-hub>=0.19.3->gradio) (1.26.5)\n",
"Requirement already satisfied: mdurl~=0.1 in /home/yash/.local/lib/python3.10/site-packages (from markdown-it-py>=2.2.0->rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (0.1.2)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install opencv-python\n",
"%pip install gradio"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"id": "GCJIckjqL53Q"
},
"outputs": [],
"source": [
"import cv2"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"id": "EZjTKX5QMt2G"
},
"outputs": [],
"source": [
"image = cv2.imread('./tomAndJerry.png')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"id": "TgMu312QRWS4"
},
"outputs": [],
"source": [
"gray_image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)\n",
"inverted = 255-gray_image\n",
"blurred = cv2.GaussianBlur(inverted, (21,21),0)\n",
"invertedblur = 255 - blurred\n",
"pencilsketch = cv2.divide(gray_image, invertedblur, scale = 256.0)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "-GqFrmLDSVSQ",
"outputId": "260333ad-c3df-4e25-b442-a253b5934347"
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cv2.imwrite('./result.png', pencilsketch)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7861\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<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>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import gradio as gr\n",
"import cv2\n",
"import numpy as np\n",
"from PIL import Image\n",
"\n",
"def pencil_sketch(input_image):\n",
" # Convert the image to a NumPy array\n",
" image = np.array(input_image)\n",
" gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n",
" inverted = 255 - gray_image\n",
" blurred = cv2.GaussianBlur(inverted, (21, 21), 0)\n",
" invertedblur = 255 - blurred\n",
" pencilsketch = cv2.divide(gray_image, invertedblur, scale=256.0)\n",
"\n",
" # Convert the processed image to a PIL Image object\n",
" pencilsketch_pil = Image.fromarray(pencilsketch.astype(\"uint8\"), 'L')\n",
" return pencilsketch_pil\n",
"\n",
"iface = gr.Interface(fn=pencil_sketch, inputs=\"image\", outputs=\"image\")\n",
"iface.launch()\n"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"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.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading