Spaces:
Build error
Build error
File size: 6,178 Bytes
fa8453f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/harisreedhar/Swap-Mukham/blob/main/swap_mukham_colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bypvIQG5RHl9"
},
"source": [
"# 🗿 **Swap-Mukham**\n",
"*Face swap app based on insightface inswapper.*\n",
"- [Github](https://github.com/harisreedhar/Swap-Mukham)\n",
"- [Disclaimer](https://github.com/harisreedhar/Swap-Mukham#disclaimer)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "csC_DX5zWLEU"
},
"source": [
"# Clone Repository"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "klcx2cKDKX5x"
},
"outputs": [],
"source": [
"#@title\n",
"! git clone https://github.com/harisreedhar/Swap-Mukham"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bebBDddfWTXf"
},
"source": [
"# Install Requirements"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "VgTpg7EsTN3o"
},
"outputs": [],
"source": [
"#@title\n",
"%cd Swap-Mukham/\n",
"print(\"Installing requirements...\")\n",
"!pip install -r requirements.txt -q\n",
"!pip install gdown\n",
"print(\"Installing requirements done.\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "T9L6tgD0Wats"
},
"source": [
"# Download Models"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "17MZO9OvUQAk"
},
"outputs": [],
"source": [
"#@title\n",
"inswapper_model = \"https://huggingface.co/deepinsight/inswapper/resolve/main/inswapper_128.onnx\" #@param {type:\"string\"}\n",
"gfpgan_model = \"https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth\" #@param {type:\"string\"}\n",
"face_parser_model = \"https://drive.google.com/uc?id=154JgKpzCPW82qINcVieuPH3fZ2e0P812\" #@param {type:\"string\"}\n",
"real_esrgan_2x_model = \"https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x2.pth\" #@param {type:\"string\"}\n",
"real_esrgan_4x_model = \"https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth\" #@param {type:\"string\"}\n",
"real_esrgan_8x_model = \"https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x8.pth\" #@param {type:\"string\"}\n",
"codeformer_model = \"https://huggingface.co/bluefoxcreation/Codeformer-ONNX/resolve/main/codeformer.onnx\" #@param {type:\"string\"}\n",
"nsfw_det_model = \"https://huggingface.co/bluefoxcreation/open-nsfw/resolve/main/open-nsfw.onnx\" #@param {type:\"string\"}\n",
"import gdown\n",
"import urllib.request\n",
"print(\"Downloading swapper model...\")\n",
"urllib.request.urlretrieve(inswapper_model, \"/content/Swap-Mukham/assets/pretrained_models/inswapper_128.onnx\")\n",
"print(\"Downloading gfpgan model...\")\n",
"urllib.request.urlretrieve(gfpgan_model, \"/content/Swap-Mukham/assets/pretrained_models/GFPGANv1.4.pth\")\n",
"print(\"Downloading face parsing model...\")\n",
"gdown.download(face_parser_model, \"/content/Swap-Mukham/assets/pretrained_models/79999_iter.pth\")\n",
"print(\"Downloading realesrgan 2x model...\")\n",
"urllib.request.urlretrieve(real_esrgan_2x_model, \"/content/Swap-Mukham/assets/pretrained_models/RealESRGAN_x2.pth\")\n",
"print(\"Downloading realesrgan 4x model...\")\n",
"urllib.request.urlretrieve(real_esrgan_4x_model, \"/content/Swap-Mukham/assets/pretrained_models/RealESRGAN_x4.pth\")\n",
"print(\"Downloading realesrgan 8x model...\")\n",
"urllib.request.urlretrieve(real_esrgan_8x_model, \"/content/Swap-Mukham/assets/pretrained_models/RealESRGAN_x8.pth\")\n",
"print(\"Downloading codeformer...\")\n",
"urllib.request.urlretrieve(codeformer_model, \"/content/Swap-Mukham/assets/pretrained_models/codeformer.onnx\")\n",
"print(\"Downloading NSFW detector model...\")\n",
"urllib.request.urlretrieve(nsfw_det_model, \"/content/Swap-Mukham/assets/pretrained_models/open-nsfw.onnx\")\n",
"print(\"Downloading models done.\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "uEcCUw0Co6bE"
},
"source": [
"# Mount Google drive (optional)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4KssYYippDMw"
},
"outputs": [],
"source": [
"from google.colab import auth, drive\n",
"auth.authenticate_user()\n",
"drive.mount('/content/drive')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-Tn68Ayqdrlk"
},
"source": [
"# Run App\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6dpBjbfVOrrc"
},
"outputs": [],
"source": [
"#@title\n",
"default_output_path = \"/content/Swap-Mukham\" #@param {type:\"string\"}\n",
"\n",
"command = f\"python app.py --cuda --colab --out_dir {default_output_path}\"\n",
"!{command}"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"gpuType": "T4",
"include_colab_link": true,
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|