|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
MODEL_URL="https://huggingface.co/ofter/4x-UltraSharp/resolve/main/inswapper_128.onnx" |
|
MODEL_PATH="../inswapper_128.onnx" |
|
if [ ! -f "$MODEL_PATH" ]; then |
|
echo "Downloading inswapper_128.onnx model..." |
|
wget -O "$MODEL_PATH" "$MODEL_URL" |
|
if [ $? -ne 0 ]; then |
|
echo "Error: Failed to download the model. Please check your internet connection." |
|
exit 1 |
|
fi |
|
echo "Model downloaded successfully!" |
|
else |
|
echo "Model already exists at $MODEL_PATH." |
|
fi |
|
|
|
|
|
|
|
|
|
echo "Stopping any running 'refacer' containers..." |
|
docker stop -t 0 refacer 2>/dev/null || echo "No running container found." |
|
|
|
|
|
|
|
|
|
echo "Building the Docker image 'refacer' using Dockerfile.nvidia..." |
|
docker build -t refacer -f Dockerfile.nvidia . |
|
if [ $? -ne 0 ]; then |
|
echo "Error: Docker image build failed." |
|
exit 1 |
|
fi |
|
echo "Docker image built successfully." |
|
|
|
|
|
|
|
|
|
echo "Starting the Docker container with NVIDIA GPU support..." |
|
docker run --rm --name refacer \ |
|
-v $(pwd)/..:/refacer \ |
|
-p 7860:7860 \ |
|
--gpus all \ |
|
refacer python3 app.py --server_name 0.0.0.0 & |
|
|
|
|
|
echo "Waiting for the Refacer server to start..." |
|
sleep 5 |
|
|
|
|
|
|
|
|
|
echo "Opening Refacer UI in your browser..." |
|
if command -v google-chrome >/dev/null 2>&1; then |
|
google-chrome --new-window "http://127.0.0.1:7860" & |
|
elif command -v xdg-open >/dev/null 2>&1; then |
|
xdg-open "http://127.0.0.1:7860" & |
|
elif command -v open >/dev/null 2>&1; then |
|
open "http://127.0.0.1:7860" & |
|
else |
|
echo "Please open your browser and navigate to: http://127.0.0.1:7860" |
|
fi |
|
|