kevinwang676 commited on
Commit
7ee1db1
·
1 Parent(s): 3acfb1e

Delete quick_demo.ipynb

Browse files
Files changed (1) hide show
  1. quick_demo.ipynb +0 -213
quick_demo.ipynb DELETED
@@ -1,213 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "attachments": {},
5
- "cell_type": "markdown",
6
- "metadata": {
7
- "id": "M74Gs_TjYl_B"
8
- },
9
- "source": [
10
- "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Winfredy/SadTalker/blob/main/quick_demo.ipynb)"
11
- ]
12
- },
13
- {
14
- "attachments": {},
15
- "cell_type": "markdown",
16
- "metadata": {
17
- "id": "view-in-github"
18
- },
19
- "source": [
20
- "### SadTalker:Learning Realistic 3D Motion Coefficients for Stylized Audio-Driven Single Image Talking Face Animation \n",
21
- "\n",
22
- "[arxiv](https://arxiv.org/abs/2211.12194) | [project](https://sadtalker.github.io) | [Github](https://github.com/Winfredy/SadTalker)\n",
23
- "\n",
24
- "Wenxuan Zhang, Xiaodong Cun, Xuan Wang, Yong Zhang, Xi Shen, Yu Guo, Ying Shan, Fei Wang.\n",
25
- "\n",
26
- "Xi'an Jiaotong University, Tencent AI Lab, Ant Group\n",
27
- "\n",
28
- "CVPR 2023\n",
29
- "\n",
30
- "TL;DR: A realistic and stylized talking head video generation method from a single image and audio\n"
31
- ]
32
- },
33
- {
34
- "attachments": {},
35
- "cell_type": "markdown",
36
- "metadata": {
37
- "id": "kA89DV-sKS4i"
38
- },
39
- "source": [
40
- "Installation (around 5 mins)"
41
- ]
42
- },
43
- {
44
- "cell_type": "code",
45
- "execution_count": null,
46
- "metadata": {
47
- "id": "qJ4CplXsYl_E"
48
- },
49
- "outputs": [],
50
- "source": [
51
- "### make sure that CUDA is available in Edit -> Nootbook settings -> GPU\n",
52
- "!nvidia-smi --query-gpu=name,memory.total,memory.free --format=csv,noheader"
53
- ]
54
- },
55
- {
56
- "cell_type": "code",
57
- "execution_count": null,
58
- "metadata": {
59
- "id": "Mdq6j4E5KQAR"
60
- },
61
- "outputs": [],
62
- "source": [
63
- "!update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.8 2 \n",
64
- "!update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.9 1 \n",
65
- "!python --version \n",
66
- "!apt-get update\n",
67
- "!apt install software-properties-common\n",
68
- "!sudo dpkg --remove --force-remove-reinstreq python3-pip python3-setuptools python3-wheel\n",
69
- "!apt-get install python3-pip\n",
70
- "\n",
71
- "print('Git clone project and install requirements...')\n",
72
- "!git clone https://github.com/Winfredy/SadTalker &> /dev/null\n",
73
- "%cd SadTalker \n",
74
- "!export PYTHONPATH=/content/SadTalker:$PYTHONPATH \n",
75
- "!python3.8 -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113\n",
76
- "!apt update\n",
77
- "!apt install ffmpeg &> /dev/null \n",
78
- "!python3.8 -m pip install -r requirements.txt"
79
- ]
80
- },
81
- {
82
- "attachments": {},
83
- "cell_type": "markdown",
84
- "metadata": {
85
- "id": "DddcKB_nKsnk"
86
- },
87
- "source": [
88
- "Download models (1 mins)"
89
- ]
90
- },
91
- {
92
- "cell_type": "code",
93
- "execution_count": null,
94
- "metadata": {
95
- "id": "eDw3_UN8K2xa"
96
- },
97
- "outputs": [],
98
- "source": [
99
- "print('Download pre-trained models...')\n",
100
- "!rm -rf checkpoints\n",
101
- "!bash scripts/download_models.sh"
102
- ]
103
- },
104
- {
105
- "cell_type": "code",
106
- "execution_count": null,
107
- "metadata": {
108
- "id": "kK7DYeo7Yl_H"
109
- },
110
- "outputs": [],
111
- "source": [
112
- "# borrow from makeittalk\n",
113
- "import ipywidgets as widgets\n",
114
- "import glob\n",
115
- "import matplotlib.pyplot as plt\n",
116
- "print(\"Choose the image name to animate: (saved in folder 'examples/')\")\n",
117
- "img_list = glob.glob1('examples/source_image', '*.png')\n",
118
- "img_list.sort()\n",
119
- "img_list = [item.split('.')[0] for item in img_list]\n",
120
- "default_head_name = widgets.Dropdown(options=img_list, value='full3')\n",
121
- "def on_change(change):\n",
122
- " if change['type'] == 'change' and change['name'] == 'value':\n",
123
- " plt.imshow(plt.imread('examples/source_image/{}.png'.format(default_head_name.value)))\n",
124
- " plt.axis('off')\n",
125
- " plt.show()\n",
126
- "default_head_name.observe(on_change)\n",
127
- "display(default_head_name)\n",
128
- "plt.imshow(plt.imread('examples/source_image/{}.png'.format(default_head_name.value)))\n",
129
- "plt.axis('off')\n",
130
- "plt.show()"
131
- ]
132
- },
133
- {
134
- "attachments": {},
135
- "cell_type": "markdown",
136
- "metadata": {
137
- "id": "-khNZcnGK4UK"
138
- },
139
- "source": [
140
- "Animation"
141
- ]
142
- },
143
- {
144
- "cell_type": "code",
145
- "execution_count": null,
146
- "metadata": {
147
- "id": "ToBlDusjK5sS"
148
- },
149
- "outputs": [],
150
- "source": [
151
- "# selected audio from exmaple/driven_audio\n",
152
- "img = 'examples/source_image/{}.png'.format(default_head_name.value)\n",
153
- "print(img)\n",
154
- "!python3.8 inference.py --driven_audio ./examples/driven_audio/RD_Radio31_000.wav \\\n",
155
- " --source_image {img} \\\n",
156
- " --result_dir ./results --still --preprocess full --enhancer gfpgan"
157
- ]
158
- },
159
- {
160
- "cell_type": "code",
161
- "execution_count": null,
162
- "metadata": {
163
- "id": "fAjwGmKKYl_I"
164
- },
165
- "outputs": [],
166
- "source": [
167
- "# visualize code from makeittalk\n",
168
- "from IPython.display import HTML\n",
169
- "from base64 import b64encode\n",
170
- "import os, sys\n",
171
- "\n",
172
- "# get the last from results\n",
173
- "\n",
174
- "results = sorted(os.listdir('./results/'))\n",
175
- "\n",
176
- "mp4_name = glob.glob('./results/*.mp4')[0]\n",
177
- "\n",
178
- "mp4 = open('{}'.format(mp4_name),'rb').read()\n",
179
- "data_url = \"data:video/mp4;base64,\" + b64encode(mp4).decode()\n",
180
- "\n",
181
- "print('Display animation: {}'.format(mp4_name), file=sys.stderr)\n",
182
- "display(HTML(\"\"\"\n",
183
- " <video width=256 controls>\n",
184
- " <source src=\"%s\" type=\"video/mp4\">\n",
185
- " </video>\n",
186
- " \"\"\" % data_url))\n"
187
- ]
188
- }
189
- ],
190
- "metadata": {
191
- "accelerator": "GPU",
192
- "colab": {
193
- "provenance": []
194
- },
195
- "gpuClass": "standard",
196
- "kernelspec": {
197
- "display_name": "base",
198
- "language": "python",
199
- "name": "python3"
200
- },
201
- "language_info": {
202
- "name": "python",
203
- "version": "3.9.7"
204
- },
205
- "vscode": {
206
- "interpreter": {
207
- "hash": "db5031b3636a3f037ea48eb287fd3d023feb9033aefc2a9652a92e470fb0851b"
208
- }
209
- }
210
- },
211
- "nbformat": 4,
212
- "nbformat_minor": 0
213
- }