git clone https://github.com/ashleykleynhans/runpod-worker-inswapper.git
cd runpod-worker-inswapper
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
mkdir checkpoints
wget -O ./checkpoints/inswapper_128.onnx https://huggingface.co/ashleykleynhans/inswapper/resolve/main/inswapper_128.onnx && \
git lfs install
git clone https://huggingface.co/spaces/sczhou/CodeFormer
Use --rp_serve_api
command line argument to serve the API locally.
python3 -u rp_handler.py --rp_serve_api
NOTE: You need to keep the RunPod Handler API running in order to run the tests, so open a new terminal window to run the tests.
You can either overwrite the images in the data
directory with your
own source and target files, or alternatively, you can edit the
scripts in the tests
directory to reference the source and target
images somewhere else on your system.
If you have added your RUNPOD_API_KEY
and
RUNPOD_ENDPOINT_ID
to the .env
file within
this directory, you should first comment them
out before attempting to test locally. If
the .env file exists and the values are provided,
the tests will attempt to send the requests to
your RunPod endpoint instead of running locally.
- Ensure that the RunPod Handler API is still running.
- Change directory to the
tests
directory and run one of the scripts, for example:
cd tests
python3 all_1_source_into_all_1_target.py
- This will display the HTTP status code and the filename of the output image, for example:
Status code: 200
Saving image: 792a7e9f-9c36-4d35-b408-0d45d8e2bbcb.jpg
You can then open the output image (in this case
792a7e9f-9c36-4d35-b408-0d45d8e2bbcb.jpg
) to view the
results of the face swap.
You obviously need to edit the payload within the script to achieve the desired results.