【Python】機械学習モデルのUIを作成できる「gradio」をインストール

【Python】機械学習モデルのUI(ユーザーインターフェイス)を作成できる「gradio」のインストールについて解説しています。

「gradio(https://www.gradio.app/)」は、機械学習モデルのユーザーインターフェイスをすばやく作成することができます。Webブラウザでモデルを簡単にデモすることなどができます。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■gradioをインストールする

gradioをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install gradio

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。

py -3.8 -m pip install gradio

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting gradio
  Downloading gradio-2.9.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 726 kB/s
Requirement already satisfied: pillow in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (8.2.0)
Requirement already satisfied: analytics-python in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (1.4.0)
Collecting ffmpy
  Downloading ffmpy-0.3.0.tar.gz (4.8 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: aiohttp in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (3.7.4.post0)
Requirement already satisfied: numpy in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (1.21.5)
Requirement already satisfied: fastapi in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (0.68.1)
Collecting markdown-it-py[linkify,plugins]
  Downloading markdown_it_py-2.0.1-py3-none-any.whl (84 kB)
     |████████████████████████████████| 84 kB 3.0 MB/s
Requirement already satisfied: matplotlib in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (3.4.2)
Collecting orjson
  Downloading orjson-3.6.7-cp38-none-win_amd64.whl (186 kB)
     |████████████████████████████████| 186 kB 2.2 MB/s
Collecting paramiko
  Downloading paramiko-2.10.3-py2.py3-none-any.whl (211 kB)
     |████████████████████████████████| 211 kB 2.2 MB/s
Requirement already satisfied: requests in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (2.27.1)
Requirement already satisfied: uvicorn in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (0.15.0)
Collecting pydub
  Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)
Requirement already satisfied: python-multipart in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (0.0.5)
Requirement already satisfied: pycryptodome in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (3.10.1)
Requirement already satisfied: pandas in c:\users\user_\appdata\roaming\python\python38\site-packages (from gradio) (1.2.4)
Requirement already satisfied: attrs>=17.3.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->gradio) (21.2.0)
Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->gradio) (3.0.4)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->gradio) (5.1.0)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->gradio) (3.7.4.3)
Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->gradio) (3.0.1)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->gradio) (1.6.3)
Requirement already satisfied: monotonic>=1.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from analytics-python->gradio) (1.6)
Requirement already satisfied: backoff==1.10.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from analytics-python->gradio) (1.10.0)
Requirement already satisfied: six>=1.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from analytics-python->gradio) (1.15.0)
Requirement already satisfied: python-dateutil>2.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from analytics-python->gradio) (2.8.1)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests->gradio) (2.0.12)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests->gradio) (2021.5.30)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests->gradio) (1.25.11)
Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests->gradio) (2.10)
Requirement already satisfied: pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from fastapi->gradio) (1.9.0)
Requirement already satisfied: starlette==0.14.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from fastapi->gradio) (0.14.2)
Collecting mdurl~=0.1
  Downloading mdurl-0.1.1-py3-none-any.whl (10 kB)
Collecting mdit-py-plugins
  Downloading mdit_py_plugins-0.3.0-py3-none-any.whl (43 kB)
     |████████████████████████████████| 43 kB 706 kB/s
Collecting linkify-it-py~=1.0
  Downloading linkify_it_py-1.0.3-py3-none-any.whl (19 kB)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from matplotlib->gradio) (2.4.7)
Requirement already satisfied: cycler>=0.10 in c:\users\user_\appdata\roaming\python\python38\site-packages (from matplotlib->gradio) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from matplotlib->gradio) (1.3.1)
Requirement already satisfied: pytz>=2017.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pandas->gradio) (2021.3)
Requirement already satisfied: cryptography>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from paramiko->gradio) (36.0.1)
Collecting pynacl>=1.0.1
  Downloading PyNaCl-1.5.0-cp36-abi3-win_amd64.whl (212 kB)
     |████████████████████████████████| 212 kB 2.2 MB/s
Requirement already satisfied: bcrypt>=3.1.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from paramiko->gradio) (3.2.0)
Requirement already satisfied: click>=7.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from uvicorn->gradio) (8.0.4)
Requirement already satisfied: h11>=0.8 in c:\users\user_\appdata\roaming\python\python38\site-packages (from uvicorn->gradio) (0.12.0)
Requirement already satisfied: asgiref>=3.4.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from uvicorn->gradio) (3.4.1)
Requirement already satisfied: cffi>=1.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from bcrypt>=3.1.3->paramiko->gradio) (1.14.5)
Requirement already satisfied: colorama in c:\users\user_\appdata\roaming\python\python38\site-packages (from click>=7.0->uvicorn->gradio) (0.4.4)
Collecting uc-micro-py
  Downloading uc_micro_py-1.0.1-py3-none-any.whl (6.2 kB)
Requirement already satisfied: pycparser in c:\users\user_\appdata\roaming\python\python38\site-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko->gradio) (2.20)
Building wheels for collected packages: ffmpy
  Building wheel for ffmpy (setup.py) ... done
  Created wheel for ffmpy: filename=ffmpy-0.3.0-py3-none-any.whl size=4710 sha256=f1e2d76f6ced8e8f3af3db94ff36e826ff6424900cf691b2569738664b9d8bf3
  Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\ff\5b\59\913b443e7369dc04b61f607a746b6f7d83fb65e2e19fcc958d
Successfully built ffmpy
Installing collected packages: mdurl, uc-micro-py, markdown-it-py, pynacl, mdit-py-plugins, linkify-it-py, pydub, paramiko, orjson, ffmpy, gradio
Successfully installed ffmpy-0.3.0 gradio-2.9.1 linkify-it-py-1.0.3 markdown-it-py-2.0.1 mdit-py-plugins-0.3.0 mdurl-0.1.1 orjson-3.6.7 paramiko-2.10.3 pydub-0.25.1 pynacl-1.5.0 uc-micro-py-1.0.1

Enterキーを押すと、インストールが開始され、「Successfully installed」と表示されます。これが表示されれば、gradioが正常にインストールされたことになります。

なお、今回はgradioのバージョン2.9.1をインストールしました。

コメント

タイトルとURLをコピーしました