Skip to content

Commit

Permalink
move pyvirtualcam dependency to extra requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
taehun-kim2 committed Oct 19, 2023
1 parent c303927 commit 24fc382
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Image | Video | Webcam
* Our package is currently not working properly on small images without `--fast` argument. Sorry for the inconvenience and we'll fix this issue with better algorithm coming out shortly.
* [2023.09.22] For the issue with small images without `--fast` argument, please download [This Checkpoint](https://drive.google.com/file/d/13YER0ri0RZkTdGQqWiwK795i39FrXNKL/view?usp=sharing). After some user feedback (create issue or contact me), I'll decide to substitute the current checkpoint to the newer one or train again with different approach.
* [2023.09.25] The above checkpoint is now available with `--mode base-nightly` argument. `--fast` argument is deprecated. Use `--mode [MODE]` instead. `--mode` argument supports `base`, `fast` and `base-nightly`. Note that `base-nightly` can be changed without any notice.
* [2023.10.19] Webcam support is not stable currently. We remove the dependency for the latest release. Install with extra dependency option `pip install transparent-background[webcam]` if you want to use webcam input.

## :inbox_tray: Installation

Expand All @@ -35,7 +36,7 @@ package | version (>=)
`tqdm` | `4.64.1`
`kornia` | `0.5.4`
`gdown` | `4.5.4`
`pyvirtualcam` | `0.6.0`
`pyvirtualcam` (optional) | `0.6.0`

Note: If you have any problem with [`pyvirtualcam`](https://pypi.org/project/pyvirtualcam/), please visit their github repository or pypi homepage. Due to the backend workflow for Windows and macOS, we only support Linux for webcam input.
### Dependencies (webcam input)
Expand Down Expand Up @@ -72,6 +73,7 @@ Follow the steps below.
```bash
# via pypi
$ pip install transparent-background
$ pip install transparent-background[webcam] # with webcam dependency

# via github
$ pip install git+https://github.com/plemeri/transparent-background.git
Expand Down
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="transparent-background",
version="1.2.7",
version="1.2.8",
author="Taehun Kim",
author_email="taehoon1018@postech.ac.kr",
description="Make images with transparent background",
Expand All @@ -21,7 +21,10 @@
"Operating System :: OS Independent",
],
python_requires='>=3.8',
install_requires=['torch>=1.7.1', 'torchvision>=0.8.2', 'opencv-python>=4.6.0.66', 'timm>=0.6.11', 'tqdm>=4.64.1', 'kornia>=0.5.4', 'gdown>=4.5.4', 'pyvirtualcam>=0.6.0', 'easydict>=1.10', 'pyyaml>=6.0'],
install_requires=['torch>=1.7.1', 'torchvision>=0.8.2', 'opencv-python>=4.6.0.66', 'timm>=0.6.11', 'tqdm>=4.64.1', 'kornia>=0.5.4', 'gdown>=4.5.4', 'easydict>=1.10', 'pyyaml>=6.0'],
extras_require={
'webcam': ['pyvirtualcam>=0.6.0']
},
entry_points={
"console_scripts": [
"transparent-background=transparent_background:console",
Expand Down
14 changes: 9 additions & 5 deletions transparent_background/Remover.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import shutil
import warnings
import pyvirtualcam
import importlib

import numpy as np
import torch.nn.functional as F
Expand Down Expand Up @@ -217,10 +217,14 @@ def console():
if args.source.isnumeric() is True:
save_dir = None
_format = "Webcam"
try:
vcam = pyvirtualcam.Camera(width=640, height=480, fps=30)
except:
vcam = None
if importlib.util.find_spec('pyvirtualcam') is not None:
try:
import pyvirtualcam
vcam = pyvirtualcam.Camera(width=640, height=480, fps=30)
except:
vcam = None
else:
raise ImportError("pyvirtualcam not found. Install with \"pip install transparent-background[webcam]\"")

elif os.path.isdir(args.source):
save_dir = os.path.join(os.getcwd(), args.source.split(os.sep)[-1])
Expand Down

0 comments on commit 24fc382

Please sign in to comment.