Skip to content

momo-the-monster/new.co.pho

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NewCoPho | New Context Photos

Replace anything that's not a 'person' in your photo with a new Background Image. Uses PyTorch, Deeplabv3, ResNet101 Requires CUDA!

Examples

Windows Quickstart

  1. Install Python 3.6
  2. Create Virtual Environment python -m venv env
  3. Activate the Environment "env/Scripts/activate"
  4. Install Requirements pip install -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.html
  5. Run the Server
    flask run --host 0.0.0.0
  6. Visit on Mobile Device http://your.ip.address:5000

Quickstart Breakdown

Create Virtual Environment

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.

Install Requirements.

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.

Execution

Run the Server.

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.

Visit the page in a browser (mobile browsers best).

Get your ip and visit it in a browser on port 5000. It will be something like http://192.168.1.15:5000

Customization

Change the BGPortrait.jpg and BGLandscape.jpg files in the /media folder to use your own background images.

Credits

Loading Icon and Backgrounds from loading.io Image Segmentation based on this colab notebook from the Pytorch team.