【Python】画像の背景を削除するライブラリ「rembg」のインストール

スポンサーリンク

画像の背景を削除するライブラリ「rembg」のインストールについて解説しています。

「rembg(https://github.com/danielgatis/rembg)」は画像の背景を削除することができます。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows11)

■rembgをインストールする

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

pip install rembg

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

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install rembg

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

Defaulting to user installation because normal site-packages is not writeable
Collecting rembg
Downloading rembg-2.0.49-py3-none-any.whl (26 kB)
Collecting scikit-image
Downloading scikit_image-0.21.0-cp38-cp38-win_amd64.whl (22.7 MB)
|████████████████████████████████| 22.7 MB 13 kB/s
Collecting tqdm
Using cached tqdm-4.65.0-py3-none-any.whl (77 kB)
Collecting numpy
Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB)
|████████████████████████████████| 14.9 MB 262 kB/s
Collecting pooch
Downloading pooch-1.7.0-py3-none-any.whl (60 kB)
|████████████████████████████████| 60 kB 351 kB/s
Collecting pillow
Downloading Pillow-10.0.0-cp38-cp38-win_amd64.whl (2.5 MB)
|████████████████████████████████| 2.5 MB 6.8 MB/s
Collecting opencv-python-headless
Downloading opencv_python_headless-4.8.0.74-cp37-abi3-win_amd64.whl (38.0 MB)
|████████████████████████████████| 38.0 MB 1.7 MB/s
Collecting pymatting
Downloading PyMatting-1.1.8-py3-none-any.whl (47 kB)
|████████████████████████████████| 47 kB 384 kB/s
Collecting scipy
Downloading scipy-1.10.1-cp38-cp38-win_amd64.whl (42.2 MB)
|████████████████████████████████| 42.2 MB 6.4 MB/s
Collecting onnxruntime
Downloading onnxruntime-1.15.1-cp38-cp38-win_amd64.whl (6.7 MB)
|████████████████████████████████| 6.7 MB 6.8 MB/s
Collecting packaging
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting flatbuffers
Downloading flatbuffers-23.5.26-py2.py3-none-any.whl (26 kB)
Collecting coloredlogs
Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)
|████████████████████████████████| 46 kB ...
Collecting protobuf
Downloading protobuf-4.23.4-cp38-cp38-win_amd64.whl (422 kB)
|████████████████████████████████| 422 kB 1.1 MB/s
Collecting sympy
Downloading sympy-1.12-py3-none-any.whl (5.7 MB)
|████████████████████████████████| 5.7 MB 6.8 MB/s
Collecting humanfriendly>=9.1
Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)
|████████████████████████████████| 86 kB 2.7 MB/s
Collecting pyreadline3
Downloading pyreadline3-3.4.1-py3-none-any.whl (95 kB)
|████████████████████████████████| 95 kB 6.4 MB/s
Collecting requests>=2.19.0
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting platformdirs>=2.5.0
Downloading platformdirs-3.8.1-py3-none-any.whl (16 kB)
Collecting charset-normalizer<4,>=2
Downloading charset_normalizer-3.2.0-cp38-cp38-win_amd64.whl (96 kB)
|████████████████████████████████| 96 kB ...
Collecting idna<4,>=2.5
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2023.5.7-py3-none-any.whl (156 kB)
Collecting urllib3<3,>=1.21.1
Using cached urllib3-2.0.3-py3-none-any.whl (123 kB)
Collecting numba!=0.49.0
Downloading numba-0.57.1-cp38-cp38-win_amd64.whl (2.6 MB)
|████████████████████████████████| 2.6 MB 6.8 MB/s
Collecting llvmlite<0.41,>=0.40.0dev0
Downloading llvmlite-0.40.1-cp38-cp38-win_amd64.whl (27.7 MB)
|████████████████████████████████| 27.7 MB 6.8 MB/s
Collecting importlib-metadata
Downloading importlib_metadata-6.8.0-py3-none-any.whl (22 kB)
Collecting zipp>=0.5
Using cached zipp-3.16.0-py3-none-any.whl (6.7 kB)
Collecting networkx>=2.8
Downloading networkx-3.1-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB ...
Collecting tifffile>=2022.8.12
Downloading tifffile-2023.7.4-py3-none-any.whl (220 kB)
|████████████████████████████████| 220 kB 6.4 MB/s
Collecting lazy_loader>=0.2
Downloading lazy_loader-0.3-py3-none-any.whl (9.1 kB)
Collecting PyWavelets>=1.1.1
Downloading PyWavelets-1.4.1-cp38-cp38-win_amd64.whl (4.2 MB)
|████████████████████████████████| 4.2 MB 6.4 MB/s
Collecting imageio>=2.27
Downloading imageio-2.31.1-py3-none-any.whl (313 kB)
|████████████████████████████████| 313 kB 6.4 MB/s
Collecting mpmath>=0.19
Downloading mpmath-1.3.0-py3-none-any.whl (536 kB)
|████████████████████████████████| 536 kB 6.4 MB/s
Collecting colorama
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Installing collected packages: zipp, pyreadline3, urllib3, pillow, numpy, mpmath, llvmlite, importlib-metadata, idna, humanfriendly, charset-normalizer, certifi, tifffile, sympy, scipy, requests, PyWavelets, protobuf, platformdirs, packaging, numba, networkx, lazy-loader, imageio, flatbuffers, coloredlogs, colorama, tqdm, scikit-image, pymatting, pooch, opencv-python-headless, onnxruntime, rembg
WARNING: The script f2py.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script humanfriendly.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script normalizer.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts lsm2bin.exe, tiff2fsspec.exe, tiffcomment.exe and tifffile.exe are installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script isympy.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts imageio_download_bin.exe and imageio_remove_bin.exe are installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script coloredlogs.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script tqdm.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script onnxruntime_test.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script rembg.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed PyWavelets-1.4.1 certifi-2023.5.7 charset-normalizer-3.2.0 colorama-0.4.6 coloredlogs-15.0.1 flatbuffers-23.5.26 humanfriendly-10.0 idna-3.4 imageio-2.31.1 importlib-metadata-6.8.0 lazy-loader-0.3 llvmlite-0.40.1 mpmath-1.3.0 networkx-3.1 numba-0.57.1 numpy-1.24.4 onnxruntime-1.15.1 opencv-python-headless-4.8.0.74 packaging-23.1 pillow-10.0.0 platformdirs-3.8.1 pooch-1.7.0 protobuf-4.23.4 pymatting-1.1.8 pyreadline3-3.4.1 rembg-2.0.49 requests-2.31.0 scikit-image-0.21.0 scipy-1.10.1 sympy-1.12 tifffile-2023.7.4 tqdm-4.65.0 urllib3-2.0.3 zipp-3.16.0
WARNING: You are using pip version 21.1.1; however, version 23.1.2 is available.
You should consider upgrading via the 'C:\Program Files\Python38\python.exe -m pip install --upgrade pip' command.

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、rembgが正常にインストールされたことになりますが、「WARNING」と表示されました。「WARNING」はエラーではなく警告で、インストールは行われているので、今回は一旦無視しています。

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

コメント

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