{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting gradio\n", " Downloading gradio-4.31.4-py3-none-any.whl.metadata (15 kB)\n", "Collecting aiofiles<24.0,>=22.0 (from gradio)\n", " Using cached aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)\n", "Collecting altair<6.0,>=4.2.0 (from gradio)\n", " Using cached altair-5.3.0-py3-none-any.whl.metadata (9.2 kB)\n", "Collecting fastapi (from gradio)\n", " Downloading fastapi-0.111.0-py3-none-any.whl.metadata (25 kB)\n", "Collecting ffmpy (from gradio)\n", " Using cached ffmpy-0.3.2.tar.gz (5.5 kB)\n", " Preparing metadata (setup.py) ... \u001b[?25ldone\n", "\u001b[?25hCollecting gradio-client==0.16.4 (from gradio)\n", " Downloading gradio_client-0.16.4-py3-none-any.whl.metadata (7.1 kB)\n", "Collecting httpx>=0.24.1 (from gradio)\n", " Using cached httpx-0.27.0-py3-none-any.whl.metadata (7.2 kB)\n", "Collecting huggingface-hub>=0.19.3 (from gradio)\n", " Downloading huggingface_hub-0.23.0-py3-none-any.whl.metadata (12 kB)\n", "Requirement already satisfied: importlib-resources<7.0,>=1.3 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (6.4.0)\n", "Collecting jinja2<4.0 (from gradio)\n", " Downloading jinja2-3.1.4-py3-none-any.whl.metadata (2.6 kB)\n", "Requirement already satisfied: markupsafe~=2.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (2.1.5)\n", "Requirement already satisfied: matplotlib~=3.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (3.9.0)\n", "Requirement already satisfied: numpy~=1.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (1.26.4)\n", "Collecting orjson~=3.0 (from gradio)\n", " Downloading orjson-3.10.3-cp312-cp312-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl.metadata (49 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.7/49.7 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: packaging in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (24.0)\n", "Collecting pandas<3.0,>=1.0 (from gradio)\n", " Downloading pandas-2.2.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (19 kB)\n", "Requirement already satisfied: pillow<11.0,>=8.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (10.3.0)\n", "Collecting pydantic>=2.0 (from gradio)\n", " Using cached pydantic-2.7.1-py3-none-any.whl.metadata (107 kB)\n", "Collecting pydub (from gradio)\n", " Using cached pydub-0.25.1-py2.py3-none-any.whl.metadata (1.4 kB)\n", "Collecting python-multipart>=0.0.9 (from gradio)\n", " Using cached python_multipart-0.0.9-py3-none-any.whl.metadata (2.5 kB)\n", "Collecting pyyaml<7.0,>=5.0 (from gradio)\n", " Downloading PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl.metadata (2.1 kB)\n", "Collecting ruff>=0.2.2 (from gradio)\n", " Downloading ruff-0.4.4-py3-none-macosx_11_0_arm64.whl.metadata (23 kB)\n", "Collecting semantic-version~=2.0 (from gradio)\n", " Using cached semantic_version-2.10.0-py2.py3-none-any.whl.metadata (9.7 kB)\n", "Collecting tomlkit==0.12.0 (from gradio)\n", " Using cached tomlkit-0.12.0-py3-none-any.whl.metadata (2.7 kB)\n", "Collecting typer<1.0,>=0.12 (from gradio)\n", " Downloading typer-0.12.3-py3-none-any.whl.metadata (15 kB)\n", "Requirement already satisfied: typing-extensions~=4.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (4.11.0)\n", "Requirement already satisfied: urllib3~=2.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio) (2.2.1)\n", "Collecting uvicorn>=0.14.0 (from gradio)\n", " Using cached uvicorn-0.29.0-py3-none-any.whl.metadata (6.3 kB)\n", "Requirement already satisfied: fsspec in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from gradio-client==0.16.4->gradio) (2024.5.0)\n", "Collecting websockets<12.0,>=10.0 (from gradio-client==0.16.4->gradio)\n", " Downloading websockets-11.0.3-py3-none-any.whl.metadata (6.6 kB)\n", "Collecting jsonschema>=3.0 (from altair<6.0,>=4.2.0->gradio)\n", " Downloading jsonschema-4.22.0-py3-none-any.whl.metadata (8.2 kB)\n", "Collecting toolz (from altair<6.0,>=4.2.0->gradio)\n", " Using cached toolz-0.12.1-py3-none-any.whl.metadata (5.1 kB)\n", "Collecting anyio (from httpx>=0.24.1->gradio)\n", " Using cached anyio-4.3.0-py3-none-any.whl.metadata (4.6 kB)\n", "Requirement already satisfied: certifi in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from httpx>=0.24.1->gradio) (2024.2.2)\n", "Collecting httpcore==1.* (from httpx>=0.24.1->gradio)\n", " Using cached httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)\n", "Requirement already satisfied: idna in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from httpx>=0.24.1->gradio) (3.7)\n", "Collecting sniffio (from httpx>=0.24.1->gradio)\n", " Using cached sniffio-1.3.1-py3-none-any.whl.metadata (3.9 kB)\n", "Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx>=0.24.1->gradio)\n", " Using cached h11-0.14.0-py3-none-any.whl.metadata (8.2 kB)\n", "Collecting filelock (from huggingface-hub>=0.19.3->gradio)\n", " Downloading filelock-3.14.0-py3-none-any.whl.metadata (2.8 kB)\n", "Requirement already satisfied: requests in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from huggingface-hub>=0.19.3->gradio) (2.32.0)\n", "Requirement already satisfied: tqdm>=4.42.1 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from huggingface-hub>=0.19.3->gradio) (4.66.4)\n", "Requirement already satisfied: contourpy>=1.0.1 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from matplotlib~=3.0->gradio) (1.2.1)\n", "Requirement already satisfied: cycler>=0.10 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from matplotlib~=3.0->gradio) (0.12.1)\n", "Requirement already satisfied: fonttools>=4.22.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from matplotlib~=3.0->gradio) (4.51.0)\n", "Requirement already satisfied: kiwisolver>=1.3.1 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from matplotlib~=3.0->gradio) (1.4.5)\n", "Requirement already satisfied: pyparsing>=2.3.1 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from matplotlib~=3.0->gradio) (3.1.2)\n", "Requirement already satisfied: python-dateutil>=2.7 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from matplotlib~=3.0->gradio) (2.9.0.post0)\n", "Collecting pytz>=2020.1 (from pandas<3.0,>=1.0->gradio)\n", " Downloading pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB)\n", "Collecting tzdata>=2022.7 (from pandas<3.0,>=1.0->gradio)\n", " Downloading tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)\n", "Collecting annotated-types>=0.4.0 (from pydantic>=2.0->gradio)\n", " Downloading annotated_types-0.7.0-py3-none-any.whl.metadata (15 kB)\n", "Collecting pydantic-core==2.18.2 (from pydantic>=2.0->gradio)\n", " Downloading pydantic_core-2.18.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (6.5 kB)\n", "Requirement already satisfied: click>=8.0.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n", "Collecting shellingham>=1.3.0 (from typer<1.0,>=0.12->gradio)\n", " Using cached shellingham-1.5.4-py2.py3-none-any.whl.metadata (3.5 kB)\n", "Requirement already satisfied: rich>=10.11.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from typer<1.0,>=0.12->gradio) (13.7.1)\n", "Collecting starlette<0.38.0,>=0.37.2 (from fastapi->gradio)\n", " Using cached starlette-0.37.2-py3-none-any.whl.metadata (5.9 kB)\n", "Collecting fastapi-cli>=0.0.2 (from fastapi->gradio)\n", " Downloading fastapi_cli-0.0.4-py3-none-any.whl.metadata (7.0 kB)\n", "Collecting ujson!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,>=4.0.1 (from fastapi->gradio)\n", " Downloading ujson-5.10.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (9.3 kB)\n", "Collecting email_validator>=2.0.0 (from fastapi->gradio)\n", " Downloading email_validator-2.1.1-py3-none-any.whl.metadata (26 kB)\n", "Collecting dnspython>=2.0.0 (from email_validator>=2.0.0->fastapi->gradio)\n", " Downloading dnspython-2.6.1-py3-none-any.whl.metadata (5.8 kB)\n", "Collecting attrs>=22.2.0 (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio)\n", " Downloading attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)\n", "Collecting jsonschema-specifications>=2023.03.6 (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio)\n", " Downloading jsonschema_specifications-2023.12.1-py3-none-any.whl.metadata (3.0 kB)\n", "Collecting referencing>=0.28.4 (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio)\n", " Downloading referencing-0.35.1-py3-none-any.whl.metadata (2.8 kB)\n", "Collecting rpds-py>=0.7.1 (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio)\n", " Downloading rpds_py-0.18.1-cp312-cp312-macosx_11_0_arm64.whl.metadata (4.1 kB)\n", "Requirement already satisfied: six>=1.5 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n", "Requirement already satisfied: markdown-it-py>=2.2.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n", "Collecting httptools>=0.5.0 (from uvicorn[standard]>=0.12.0->fastapi->gradio)\n", " Downloading httptools-0.6.1-cp312-cp312-macosx_10_9_universal2.whl.metadata (3.6 kB)\n", "Collecting python-dotenv>=0.13 (from uvicorn[standard]>=0.12.0->fastapi->gradio)\n", " Using cached python_dotenv-1.0.1-py3-none-any.whl.metadata (23 kB)\n", "Collecting uvloop!=0.15.0,!=0.15.1,>=0.14.0 (from uvicorn[standard]>=0.12.0->fastapi->gradio)\n", " Downloading uvloop-0.19.0-cp312-cp312-macosx_10_9_universal2.whl.metadata (4.9 kB)\n", "Collecting watchfiles>=0.13 (from uvicorn[standard]>=0.12.0->fastapi->gradio)\n", " Downloading watchfiles-0.21.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (4.9 kB)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from requests->huggingface-hub>=0.19.3->gradio) (3.3.2)\n", "Requirement already satisfied: mdurl~=0.1 in /Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n", "Downloading gradio-4.31.4-py3-none-any.whl (12.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.3/12.3 MB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading gradio_client-0.16.4-py3-none-any.whl (315 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m315.9/315.9 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hUsing cached tomlkit-0.12.0-py3-none-any.whl (37 kB)\n", "Using cached aiofiles-23.2.1-py3-none-any.whl (15 kB)\n", "Using cached altair-5.3.0-py3-none-any.whl (857 kB)\n", "Using cached httpx-0.27.0-py3-none-any.whl (75 kB)\n", "Using cached httpcore-1.0.5-py3-none-any.whl (77 kB)\n", "Downloading huggingface_hub-0.23.0-py3-none-any.whl (401 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m401.2/401.2 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading jinja2-3.1.4-py3-none-any.whl (133 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m133.3/133.3 kB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading orjson-3.10.3-cp312-cp312-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl (253 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m253.8/253.8 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading pandas-2.2.2-cp312-cp312-macosx_11_0_arm64.whl (11.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m11.3/11.3 MB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hUsing cached pydantic-2.7.1-py3-none-any.whl (409 kB)\n", "Downloading pydantic_core-2.18.2-cp312-cp312-macosx_11_0_arm64.whl (1.8 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hUsing cached python_multipart-0.0.9-py3-none-any.whl (22 kB)\n", "Downloading PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl (165 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m165.6/165.6 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading ruff-0.4.4-py3-none-macosx_11_0_arm64.whl (8.0 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m8.0/8.0 MB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hUsing cached semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n", "Downloading typer-0.12.3-py3-none-any.whl (47 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m47.2/47.2 kB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hUsing cached uvicorn-0.29.0-py3-none-any.whl (60 kB)\n", "Downloading fastapi-0.111.0-py3-none-any.whl (91 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.0/92.0 kB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hUsing cached pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n", "Downloading annotated_types-0.7.0-py3-none-any.whl (13 kB)\n", "Downloading email_validator-2.1.1-py3-none-any.whl (30 kB)\n", "Downloading fastapi_cli-0.0.4-py3-none-any.whl (9.5 kB)\n", "Using cached h11-0.14.0-py3-none-any.whl (58 kB)\n", "Downloading jsonschema-4.22.0-py3-none-any.whl (88 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m88.3/88.3 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading pytz-2024.1-py2.py3-none-any.whl (505 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m505.5/505.5 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hUsing cached shellingham-1.5.4-py2.py3-none-any.whl (9.8 kB)\n", "Using cached starlette-0.37.2-py3-none-any.whl (71 kB)\n", "Using cached anyio-4.3.0-py3-none-any.whl (85 kB)\n", "Using cached sniffio-1.3.1-py3-none-any.whl (10 kB)\n", "Downloading tzdata-2024.1-py2.py3-none-any.whl (345 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m345.4/345.4 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading ujson-5.10.0-cp312-cp312-macosx_11_0_arm64.whl (51 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m51.8/51.8 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading websockets-11.0.3-py3-none-any.whl (118 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m118.1/118.1 kB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading filelock-3.14.0-py3-none-any.whl (12 kB)\n", "Using cached toolz-0.12.1-py3-none-any.whl (56 kB)\n", "Downloading attrs-23.2.0-py3-none-any.whl (60 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.8/60.8 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading dnspython-2.6.1-py3-none-any.whl (307 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m307.7/307.7 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading httptools-0.6.1-cp312-cp312-macosx_10_9_universal2.whl (146 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m146.4/146.4 kB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading jsonschema_specifications-2023.12.1-py3-none-any.whl (18 kB)\n", "Using cached python_dotenv-1.0.1-py3-none-any.whl (19 kB)\n", "Downloading referencing-0.35.1-py3-none-any.whl (26 kB)\n", "Downloading rpds_py-0.18.1-cp312-cp312-macosx_11_0_arm64.whl (323 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m323.6/323.6 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading uvloop-0.19.0-cp312-cp312-macosx_10_9_universal2.whl (1.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.4/1.4 MB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading watchfiles-0.21.0-cp312-cp312-macosx_11_0_arm64.whl (417 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m417.3/417.3 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hBuilding wheels for collected packages: ffmpy\n", " Building wheel for ffmpy (setup.py) ... \u001b[?25ldone\n", "\u001b[?25h Created wheel for ffmpy: filename=ffmpy-0.3.2-py3-none-any.whl size=5584 sha256=97651e6dbb547e6b91aabbc5543bdf57b24da837cbeae1b4a111522dc42924b5\n", " Stored in directory: /Users/mabelang/Library/Caches/pip/wheels/8a/63/a8/fad16a1c5c990569a478f40782ce543788ddac224288008635\n", "Successfully built ffmpy\n", "Installing collected packages: pytz, pydub, ffmpy, websockets, uvloop, ujson, tzdata, toolz, tomlkit, sniffio, shellingham, semantic-version, ruff, rpds-py, pyyaml, python-multipart, python-dotenv, pydantic-core, orjson, jinja2, httptools, h11, filelock, dnspython, attrs, annotated-types, aiofiles, uvicorn, referencing, pydantic, pandas, huggingface-hub, httpcore, email_validator, anyio, watchfiles, typer, starlette, jsonschema-specifications, httpx, jsonschema, gradio-client, fastapi-cli, fastapi, altair, gradio\n", "Successfully installed aiofiles-23.2.1 altair-5.3.0 annotated-types-0.7.0 anyio-4.3.0 attrs-23.2.0 dnspython-2.6.1 email_validator-2.1.1 fastapi-0.111.0 fastapi-cli-0.0.4 ffmpy-0.3.2 filelock-3.14.0 gradio-4.31.4 gradio-client-0.16.4 h11-0.14.0 httpcore-1.0.5 httptools-0.6.1 httpx-0.27.0 huggingface-hub-0.23.0 jinja2-3.1.4 jsonschema-4.22.0 jsonschema-specifications-2023.12.1 orjson-3.10.3 pandas-2.2.2 pydantic-2.7.1 pydantic-core-2.18.2 pydub-0.25.1 python-dotenv-1.0.1 python-multipart-0.0.9 pytz-2024.1 pyyaml-6.0.1 referencing-0.35.1 rpds-py-0.18.1 ruff-0.4.4 semantic-version-2.10.0 shellingham-1.5.4 sniffio-1.3.1 starlette-0.37.2 tomlkit-0.12.0 toolz-0.12.1 typer-0.12.3 tzdata-2024.1 ujson-5.10.0 uvicorn-0.29.0 uvloop-0.19.0 watchfiles-0.21.0 websockets-11.0.3\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "# pip install gradio" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/mabelang/Documents/Z. AI apps/AI Task 2_Pokemon Classifier/.venv/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], "source": [ "import gradio as gr\n", "import tensorflow as tf\n", "import numpy as np\n", "from PIL import Image" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "model_path = \"mabel_transferlearning.keras\"\n", "model = tf.keras.models.load_model(model_path)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# Define the core prediction function\n", "def predict_pokemons(image):\n", " # Preprocess image\n", " print(type(image))\n", " image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image\n", " image = image.resize((150, 150)) #resize the image to 28x28 and converts it to gray scale\n", " image = np.array(image)\n", " image = np.expand_dims(image, axis=0) # same as image[None, ...]\n", " \n", " # Predict\n", " prediction = model.predict(image)\n", " \n", " # Apply sigmoid to get probabilities\n", " prediction_prob = tf.sigmoid(prediction).numpy()\n", "\n", " p_Abra = round(prediction_prob[0][0], 2)\n", " p_Pikachu = round(prediction_prob[0][1], 2)\n", " p_Beedrill = round(prediction_prob[0][2], 2)\n", "\n", " return{'Abra': p_Abra, 'Pikachu': p_Pikachu, 'Beedrill': p_Beedrill}" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7863\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create the Gradio interface\n", "input_image = gr.Image()\n", "iface = gr.Interface(\n", " fn=predict_pokemons,\n", " inputs=input_image, \n", " outputs=gr.Label(),\n", " examples=[\"Abra1.png\", \"Abra2.png\", \"Abra3.jpg\", \"Beedrill1.jpg\", \"Beedrill2.jpg\", \"Beedrill3.png\", \"Pikachu1.png\", \"Pikachu2.jpg\", \"Pikachu3.png\"], \n", " description=\"Pokemon Classifier\")\n", "iface.launch()" ] } ], "metadata": { "kernelspec": { "display_name": "venv_new", "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.6" } }, "nbformat": 4, "nbformat_minor": 2 }