waveydaveygravy commited on
Commit
b7f48dd
1 Parent(s): 1c60214

Upload working_swap.ipynb

Browse files
Files changed (1) hide show
  1. working_swap.ipynb +162 -0
working_swap.ipynb ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "gpuType": "T4"
8
+ },
9
+ "kernelspec": {
10
+ "name": "python3",
11
+ "display_name": "Python 3"
12
+ },
13
+ "language_info": {
14
+ "name": "python"
15
+ },
16
+ "accelerator": "GPU"
17
+ },
18
+ "cells": [
19
+ {
20
+ "cell_type": "code",
21
+ "source": [
22
+ "#!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"
23
+ ],
24
+ "metadata": {
25
+ "id": "WLmnhmI0vy07"
26
+ },
27
+ "execution_count": null,
28
+ "outputs": []
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "source": [
33
+ "# either download from here and install requ\n",
34
+ "#!wget https://huggingface.co/waveydaveygravy/swap-mukham/resolve/main/swapm.zip"
35
+ ],
36
+ "metadata": {
37
+ "id": "5b_4n8AuWJko"
38
+ },
39
+ "execution_count": 9,
40
+ "outputs": []
41
+ },
42
+ {
43
+ "cell_type": "code",
44
+ "execution_count": null,
45
+ "metadata": {
46
+ "id": "dQiXW8_sRLRX"
47
+ },
48
+ "outputs": [],
49
+ "source": [
50
+ "!pip install virtualenv\n",
51
+ "\n",
52
+ "!virtualenv swap\n",
53
+ "\n",
54
+ "!source /swap/bin/activate\n",
55
+ "\n",
56
+ "%cd /content/swap\n",
57
+ "!git clone https://github.com/G-force78/Swap-Mukham.git\n",
58
+ "#or !wget from here and move into contents then continue\n",
59
+ "%cd /content/swap/Swap-Mukham\n",
60
+ "\n",
61
+ "!pip install -r requirements.txt\n",
62
+ "\n",
63
+ "!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"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "source": [
69
+ "!wget https://huggingface.co/datasets/OwlMaster/gg2/resolve/main/inswapper_128.onnx -O /content/swap/Swap-Mukham/assets/pretrained_models/inswapper_128.onnx\n",
70
+ "\n",
71
+ "!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",
72
+ "\n",
73
+ "!gdown https://drive.google.com/uc?id=154JgKpzCPW82qINcVieuPH3fZ2e0P812 -O /content/swap/Swap-Mukham/assets/pretrained_models/\n",
74
+ "\n",
75
+ "!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",
76
+ "\n",
77
+ "!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",
78
+ "\n",
79
+ "!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",
80
+ "\n",
81
+ "!wget https://huggingface.co/bluefoxcreation/Codeformer-ONNX/resolve/main/codeformer.onnx -O /content/swap/Swap-Mukham/assets/pretrained_models/codeformer.onnx\n",
82
+ "\n",
83
+ "!wget https://huggingface.co/bluefoxcreation/open-nsfw/resolve/main/open-nsfw.onnx -O /content/swap/Swap-Mukham/assets/pretrained_models/open-nsfw.onnx"
84
+ ],
85
+ "metadata": {
86
+ "id": "xJesLPCwRXjW"
87
+ },
88
+ "execution_count": null,
89
+ "outputs": []
90
+ },
91
+ {
92
+ "cell_type": "code",
93
+ "execution_count": null,
94
+ "metadata": {
95
+ "id": "Z8BBgh8Byr2n"
96
+ },
97
+ "outputs": [],
98
+ "source": [
99
+ "from google.colab import files\n",
100
+ "uploaded = files.upload()"
101
+ ]
102
+ },
103
+ {
104
+ "cell_type": "code",
105
+ "source": [
106
+ "!python3 /content/swap/Swap-Mukham/app.py --colab --cuda --batch_size 32"
107
+ ],
108
+ "metadata": {
109
+ "id": "X6f46G46ReyW"
110
+ },
111
+ "execution_count": null,
112
+ "outputs": []
113
+ },
114
+ {
115
+ "cell_type": "code",
116
+ "execution_count": 7,
117
+ "metadata": {
118
+ "id": "FaF3RdKdaFa8"
119
+ },
120
+ "outputs": [],
121
+ "source": [
122
+ "#@title Login to HuggingFace 🤗\n",
123
+ "\n",
124
+ "#@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",
125
+ "# https://huggingface.co/settings/tokens\n",
126
+ "!mkdir -p ~/.huggingface\n",
127
+ "HUGGINGFACE_TOKEN = \"\" #@param {type:\"string\"}\n",
128
+ "!echo -n \"{HUGGINGFACE_TOKEN}\" > ~/.huggingface/token"
129
+ ]
130
+ },
131
+ {
132
+ "cell_type": "code",
133
+ "execution_count": null,
134
+ "metadata": {
135
+ "id": "aEJZoFQ2YHIb"
136
+ },
137
+ "outputs": [],
138
+ "source": [
139
+ "#@title upload to Huggingface\n",
140
+ "from huggingface_hub import HfApi\n",
141
+ "api = HfApi()\n",
142
+ "api.upload_file(\n",
143
+ " path_or_fileobj=\"\",\n",
144
+ " path_in_repo=\"\",\n",
145
+ " repo_id=\"\",\n",
146
+ " repo_type=\"model\",\n",
147
+ ")"
148
+ ]
149
+ },
150
+ {
151
+ "cell_type": "code",
152
+ "source": [
153
+ "!zip -r name whateveruwanttozip"
154
+ ],
155
+ "metadata": {
156
+ "id": "fiVq-xqKRfX_"
157
+ },
158
+ "execution_count": null,
159
+ "outputs": []
160
+ }
161
+ ]
162
+ }