{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: tensorflow in c:\\users\\sedef\\anaconda3\\lib\\site-packages (2.17.0)\n", "Requirement already satisfied: tensorflow-intel==2.17.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow) (2.17.0)\n", "Requirement already satisfied: absl-py>=1.0.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (2.1.0)\n", "Requirement already satisfied: astunparse>=1.6.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (1.6.3)\n", "Requirement already satisfied: flatbuffers>=24.3.25 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (24.3.25)\n", "Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (0.6.0)\n", "Requirement already satisfied: google-pasta>=0.1.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (0.2.0)\n", "Requirement already satisfied: h5py>=3.10.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (3.11.0)\n", "Requirement already satisfied: libclang>=13.0.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (18.1.1)\n", "Requirement already satisfied: ml-dtypes<0.5.0,>=0.3.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (0.4.1)\n", "Requirement already satisfied: opt-einsum>=2.3.2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (3.3.0)\n", "Requirement already satisfied: packaging in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (23.2)\n", "Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (4.25.4)\n", "Requirement already satisfied: requests<3,>=2.21.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (2.32.2)\n", "Requirement already satisfied: setuptools in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (69.5.1)\n", "Requirement already satisfied: six>=1.12.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (1.16.0)\n", "Requirement already satisfied: termcolor>=1.1.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (2.4.0)\n", "Requirement already satisfied: typing-extensions>=3.6.6 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (4.11.0)\n", "Requirement already satisfied: wrapt>=1.11.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (1.14.1)\n", "Requirement already satisfied: grpcio<2.0,>=1.24.3 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (1.66.1)\n", "Requirement already satisfied: tensorboard<2.18,>=2.17 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (2.17.1)\n", "Requirement already satisfied: keras>=3.2.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (3.5.0)\n", "Requirement already satisfied: numpy<2.0.0,>=1.26.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorflow-intel==2.17.0->tensorflow) (1.26.4)\n", "Requirement already satisfied: wheel<1.0,>=0.23.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from astunparse>=1.6.0->tensorflow-intel==2.17.0->tensorflow) (0.43.0)\n", "Requirement already satisfied: rich in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from keras>=3.2.0->tensorflow-intel==2.17.0->tensorflow) (13.3.5)\n", "Requirement already satisfied: namex in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from keras>=3.2.0->tensorflow-intel==2.17.0->tensorflow) (0.0.8)\n", "Requirement already satisfied: optree in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from keras>=3.2.0->tensorflow-intel==2.17.0->tensorflow) (0.12.1)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.17.0->tensorflow) (2.0.4)\n", "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.17.0->tensorflow) (3.7)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.17.0->tensorflow) (2.2.2)\n", "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.21.0->tensorflow-intel==2.17.0->tensorflow) (2024.8.30)\n", "Requirement already satisfied: markdown>=2.6.8 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorboard<2.18,>=2.17->tensorflow-intel==2.17.0->tensorflow) (3.4.1)\n", "Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorboard<2.18,>=2.17->tensorflow-intel==2.17.0->tensorflow) (0.7.2)\n", "Requirement already satisfied: werkzeug>=1.0.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from tensorboard<2.18,>=2.17->tensorflow-intel==2.17.0->tensorflow) (3.0.3)\n", "Requirement already satisfied: MarkupSafe>=2.1.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from werkzeug>=1.0.1->tensorboard<2.18,>=2.17->tensorflow-intel==2.17.0->tensorflow) (2.1.3)\n", "Requirement already satisfied: markdown-it-py<3.0.0,>=2.2.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from rich->keras>=3.2.0->tensorflow-intel==2.17.0->tensorflow) (2.2.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from rich->keras>=3.2.0->tensorflow-intel==2.17.0->tensorflow) (2.15.1)\n", "Requirement already satisfied: mdurl~=0.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from markdown-it-py<3.0.0,>=2.2.0->rich->keras>=3.2.0->tensorflow-intel==2.17.0->tensorflow) (0.1.0)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install tensorflow" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: flask in c:\\users\\sedef\\anaconda3\\lib\\site-packages (3.0.3)\n", "Requirement already satisfied: Werkzeug>=3.0.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from flask) (3.0.3)\n", "Requirement already satisfied: Jinja2>=3.1.2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from flask) (3.1.4)\n", "Requirement already satisfied: itsdangerous>=2.1.2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from flask) (2.2.0)\n", "Requirement already satisfied: click>=8.1.3 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from flask) (8.1.7)\n", "Requirement already satisfied: blinker>=1.6.2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from flask) (1.6.2)\n", "Requirement already satisfied: colorama in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from click>=8.1.3->flask) (0.4.6)\n", "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from Jinja2>=3.1.2->flask) (2.1.3)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install flask" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: numpy in c:\\users\\sedef\\anaconda3\\lib\\site-packages (1.26.4)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install numpy" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: pillow in c:\\users\\sedef\\anaconda3\\lib\\site-packages (10.3.0)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install pillow" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: streamlit in c:\\users\\sedef\\anaconda3\\lib\\site-packages (1.32.0)\n", "Requirement already satisfied: altair<6,>=4.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (5.0.1)\n", "Requirement already satisfied: blinker<2,>=1.0.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (1.6.2)\n", "Requirement already satisfied: cachetools<6,>=4.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (5.3.3)\n", "Requirement already satisfied: click<9,>=7.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (8.1.7)\n", "Requirement already satisfied: numpy<2,>=1.19.3 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (1.26.4)\n", "Requirement already satisfied: packaging<24,>=16.8 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (23.2)\n", "Requirement already satisfied: pandas<3,>=1.3.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (2.2.2)\n", "Requirement already satisfied: pillow<11,>=7.1.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (10.3.0)\n", "Requirement already satisfied: protobuf<5,>=3.20 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (4.25.4)\n", "Requirement already satisfied: pyarrow>=7.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (14.0.2)\n", "Requirement already satisfied: requests<3,>=2.27 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (2.32.2)\n", "Requirement already satisfied: rich<14,>=10.14.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (13.3.5)\n", "Requirement already satisfied: tenacity<9,>=8.1.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (8.2.2)\n", "Requirement already satisfied: toml<2,>=0.10.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (0.10.2)\n", "Requirement already satisfied: typing-extensions<5,>=4.3.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (4.11.0)\n", "Requirement already satisfied: gitpython!=3.1.19,<4,>=3.0.7 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (3.1.37)\n", "Requirement already satisfied: pydeck<1,>=0.8.0b4 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (0.8.0)\n", "Requirement already satisfied: tornado<7,>=6.0.3 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (6.4.1)\n", "Requirement already satisfied: watchdog>=2.1.5 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from streamlit) (4.0.1)\n", "Requirement already satisfied: jinja2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from altair<6,>=4.0->streamlit) (3.1.4)\n", "Requirement already satisfied: jsonschema>=3.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from altair<6,>=4.0->streamlit) (4.19.2)\n", "Requirement already satisfied: toolz in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from altair<6,>=4.0->streamlit) (0.12.0)\n", "Requirement already satisfied: colorama in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from click<9,>=7.0->streamlit) (0.4.6)\n", "Requirement already satisfied: gitdb<5,>=4.0.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from gitpython!=3.1.19,<4,>=3.0.7->streamlit) (4.0.7)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2.9.0.post0)\n", "Requirement already satisfied: pytz>=2020.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2024.1)\n", "Requirement already satisfied: tzdata>=2022.7 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2023.3)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.27->streamlit) (2.0.4)\n", "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.27->streamlit) (3.7)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.27->streamlit) (2.2.2)\n", "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from requests<3,>=2.27->streamlit) (2024.8.30)\n", "Requirement already satisfied: markdown-it-py<3.0.0,>=2.2.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from rich<14,>=10.14.0->streamlit) (2.2.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from rich<14,>=10.14.0->streamlit) (2.15.1)\n", "Requirement already satisfied: smmap<5,>=3.0.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from gitdb<5,>=4.0.1->gitpython!=3.1.19,<4,>=3.0.7->streamlit) (4.0.0)\n", "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from jinja2->altair<6,>=4.0->streamlit) (2.1.3)\n", "Requirement already satisfied: attrs>=22.2.0 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (23.1.0)\n", "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (2023.7.1)\n", "Requirement already satisfied: referencing>=0.28.4 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (0.30.2)\n", "Requirement already satisfied: rpds-py>=0.7.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (0.10.6)\n", "Requirement already satisfied: mdurl~=0.1 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from markdown-it-py<3.0.0,>=2.2.0->rich<14,>=10.14.0->streamlit) (0.1.0)\n", "Requirement already satisfied: six>=1.5 in c:\\users\\sedef\\anaconda3\\lib\\site-packages (from python-dateutil>=2.8.2->pandas<3,>=1.3.0->streamlit) (1.16.0)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install streamlit" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING:absl:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.\n", "2024-12-11 16:58:19.616 \n", " \u001b[33m\u001b[1mWarning:\u001b[0m to view this Streamlit app on a browser, run it with the following\n", " command:\n", "\n", " streamlit run C:\\Users\\Sedef\\AppData\\Roaming\\Python\\Python312\\site-packages\\ipykernel_launcher.py [ARGUMENTS]\n" ] } ], "source": [ "import streamlit as st\n", "from tensorflow.keras.models import load_model\n", "from PIL import Image\n", "import numpy as np\n", "\n", "model = load_model('cnn_model_epoch_100.h5')\n", "\n", "def process_image(img):\n", " img = img.resize((170, 170)) # Boyutu 170x170 piksel yaptık\n", " img = np.array(img) / 255.0 # Normalize ettik\n", " img = np.expand_dims(img, axis=0) # 0. ortada olsun diye sayfada\n", "\n", "st.title('Kanser Resmi sınıflandırma :cancer:')\n", "img_file = st.file_uploader('Bir Resim Seç', type=['jpeg', 'png'])\n", "\n", "if img_file is not None:\n", " img = Image.open(img_file)\n", " st.image(img, caption='Yüklenen resim')\n", " prediction = model.predict(img)\n", "\n", "st.title('Kanser Resmi Sınıflandırma :cancer:')\n", "st.write('Resim seç ve model kanser olup olmadığını tahmin etsin.')\n", "\n", "file = st.file_uploader('Bir Resim Seç', type=['jpg', 'jpeg', 'png'])\n", "\n", "if file is not None:\n", " img = Image.open(file)\n", " st.image(img, caption='Yüklenen resim')\n", " image = process_image(img)\n", " prediction = model.predict(image)\n", " predicted_class = np.argmax(prediction)\n", "\n", " class_names = ['Kanser Değil', 'Kanser']\n", " st.write(class_names[predicted_class])\n" ] } ], "metadata": { "kernelspec": { "display_name": "base", "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.12.4" } }, "nbformat": 4, "nbformat_minor": 2 }