File size: 5,374 Bytes
b7f48dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "gpuType": "T4"
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "code",
      "source": [
        "#!pip install https://github.com/karaokenerds/python-audio-separator/releases/download/v0.12.1/onnxruntime_gpu-1.17.0-cp310-cp310-linux_x86_64.whl"
      ],
      "metadata": {
        "id": "WLmnhmI0vy07"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# either download from here and install requ\n",
        "#!wget https://huggingface.co/waveydaveygravy/swap-mukham/resolve/main/swapm.zip"
      ],
      "metadata": {
        "id": "5b_4n8AuWJko"
      },
      "execution_count": 9,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "dQiXW8_sRLRX"
      },
      "outputs": [],
      "source": [
        "!pip install virtualenv\n",
        "\n",
        "!virtualenv swap\n",
        "\n",
        "!source /swap/bin/activate\n",
        "\n",
        "%cd /content/swap\n",
        "!git clone https://github.com/G-force78/Swap-Mukham.git\n",
        "#or !wget from here and move into contents then continue\n",
        "%cd /content/swap/Swap-Mukham\n",
        "\n",
        "!pip install -r requirements.txt\n",
        "\n",
        "!pip install https://github.com/karaokenerds/python-audio-separator/releases/download/v0.12.1/onnxruntime_gpu-1.17.0-cp310-cp310-linux_x86_64.whl"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "!wget https://huggingface.co/datasets/OwlMaster/gg2/resolve/main/inswapper_128.onnx -O /content/swap/Swap-Mukham/assets/pretrained_models/inswapper_128.onnx\n",
        "\n",
        "!wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -O /content/swap/Swap-Mukham/assets/pretrained_models/GFPGANv1.4.pth\n",
        "\n",
        "!gdown https://drive.google.com/uc?id=154JgKpzCPW82qINcVieuPH3fZ2e0P812 -O /content/swap/Swap-Mukham/assets/pretrained_models/\n",
        "\n",
        "!wget https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x2.pth -O /content/swap/Swap-Mukham/assets/pretrained_models/RealESRGAN_x2.pth\n",
        "\n",
        "!wget https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth -O /content/swap/Swap-Mukham/assets/pretrained_models/RealESRGAN_x4.pth\n",
        "\n",
        "!wget https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x8.pth -O /content/swap/Swap-Mukham/assets/pretrained_models/RealESRGAN_x8.pth\n",
        "\n",
        "!wget https://huggingface.co/bluefoxcreation/Codeformer-ONNX/resolve/main/codeformer.onnx -O /content/swap/Swap-Mukham/assets/pretrained_models/codeformer.onnx\n",
        "\n",
        "!wget https://huggingface.co/bluefoxcreation/open-nsfw/resolve/main/open-nsfw.onnx -O /content/swap/Swap-Mukham/assets/pretrained_models/open-nsfw.onnx"
      ],
      "metadata": {
        "id": "xJesLPCwRXjW"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Z8BBgh8Byr2n"
      },
      "outputs": [],
      "source": [
        "from google.colab import files\n",
        "uploaded = files.upload()"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "!python3 /content/swap/Swap-Mukham/app.py --colab --cuda --batch_size 32"
      ],
      "metadata": {
        "id": "X6f46G46ReyW"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "id": "FaF3RdKdaFa8"
      },
      "outputs": [],
      "source": [
        "#@title Login to HuggingFace 🤗\n",
        "\n",
        "#@markdown You need to accept the model license before downloading or using the Stable Diffusion weights. Please, visit the [model card](https://huggingface.co/runwayml/stable-diffusion-v1-5), read the license and tick the checkbox if you agree. You have to be a registered user in 🤗 Hugging Face Hub, and you'll also need to use an access token for the code to work.\n",
        "# https://huggingface.co/settings/tokens\n",
        "!mkdir -p ~/.huggingface\n",
        "HUGGINGFACE_TOKEN = \"\" #@param {type:\"string\"}\n",
        "!echo -n \"{HUGGINGFACE_TOKEN}\" > ~/.huggingface/token"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "aEJZoFQ2YHIb"
      },
      "outputs": [],
      "source": [
        "#@title upload to Huggingface\n",
        "from huggingface_hub import HfApi\n",
        "api = HfApi()\n",
        "api.upload_file(\n",
        "    path_or_fileobj=\"\",\n",
        "    path_in_repo=\"\",\n",
        "    repo_id=\"\",\n",
        "    repo_type=\"model\",\n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "!zip -r name whateveruwanttozip"
      ],
      "metadata": {
        "id": "fiVq-xqKRfX_"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}