Replace anything that's not a 'person' in your photo with a new Background Image. Uses PyTorch, Deeplabv3, ResNet101 Requires CUDA!
- Install Python 3.6
- Create Virtual Environment
python -m venv env
- Activate the Environment
"env/Scripts/activate"
- Install Requirements
pip install -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.html
- Run the Server
flask run --host 0.0.0.0
- Visit on Mobile Device http://your.ip.address:5000
This keeps all the dependencies for this project separate from other Python projects you may work on.
On Windows, run:
python -m venv env
, which will create a virtual environment in a folder named 'env'.
You then 'activate' this environment by running this in a command prompt: "env/Scripts/activate"
, which runs the activate.bat script. You need the double quotes for Windows to understand the command. Once you run this, your prompt should update to show (env)
instead of C:\FolderName
or wherever you saved the project.
The requirements have been saved into the requirements.txt file, so you can install this file with this command:
pip install -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.html
The -f argument points pip towards the right place to download the torch and torchvision dependencies. This command fails for me without this argument.
If you have issues with PyTorch, you can install it for a specific Python + Cuda version using the instructions here.
I do it this way: flask run --host 0.0.0.0
, which will start the server in a way that other machines on your local network can access the host.
Get your ip and visit it in a browser on port 5000. It will be something like http://192.168.1.15:5000
Change the BGPortrait.jpg and BGLandscape.jpg files in the /media folder to use your own background images.
Loading Icon and Backgrounds from loading.io Image Segmentation based on this colab notebook from the Pytorch team.