ehristoforu commited on
Commit
701b566
1 Parent(s): c9b0991

Upload Super_Fast_SDXL.ipynb

Browse files
Files changed (1) hide show
  1. Super_Fast_SDXL.ipynb +594 -0
Super_Fast_SDXL.ipynb ADDED
@@ -0,0 +1,594 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "authorship_tag": "ABX9TyPKBKhp0febZwFeoBEUFB5r"
8
+ },
9
+ "kernelspec": {
10
+ "name": "python3",
11
+ "display_name": "Python 3"
12
+ },
13
+ "language_info": {
14
+ "name": "python"
15
+ },
16
+ "widgets": {
17
+ "application/vnd.jupyter.widget-state+json": {
18
+ "4bd64e113ca7427998bd22fa07c6a5b2": {
19
+ "model_module": "@jupyter-widgets/controls",
20
+ "model_name": "ButtonModel",
21
+ "model_module_version": "1.5.0",
22
+ "state": {
23
+ "_dom_classes": [],
24
+ "_model_module": "@jupyter-widgets/controls",
25
+ "_model_module_version": "1.5.0",
26
+ "_model_name": "ButtonModel",
27
+ "_view_count": null,
28
+ "_view_module": "@jupyter-widgets/controls",
29
+ "_view_module_version": "1.5.0",
30
+ "_view_name": "ButtonView",
31
+ "button_style": "success",
32
+ "description": "✔ Done",
33
+ "disabled": true,
34
+ "icon": "",
35
+ "layout": "IPY_MODEL_b67f1fa6fa7142d6b90c3a04600083d2",
36
+ "style": "IPY_MODEL_74cc9bb3b6124b8ab184ed5e16bd8cbb",
37
+ "tooltip": ""
38
+ }
39
+ },
40
+ "b67f1fa6fa7142d6b90c3a04600083d2": {
41
+ "model_module": "@jupyter-widgets/base",
42
+ "model_name": "LayoutModel",
43
+ "model_module_version": "1.2.0",
44
+ "state": {
45
+ "_model_module": "@jupyter-widgets/base",
46
+ "_model_module_version": "1.2.0",
47
+ "_model_name": "LayoutModel",
48
+ "_view_count": null,
49
+ "_view_module": "@jupyter-widgets/base",
50
+ "_view_module_version": "1.2.0",
51
+ "_view_name": "LayoutView",
52
+ "align_content": null,
53
+ "align_items": null,
54
+ "align_self": null,
55
+ "border": null,
56
+ "bottom": null,
57
+ "display": null,
58
+ "flex": null,
59
+ "flex_flow": null,
60
+ "grid_area": null,
61
+ "grid_auto_columns": null,
62
+ "grid_auto_flow": null,
63
+ "grid_auto_rows": null,
64
+ "grid_column": null,
65
+ "grid_gap": null,
66
+ "grid_row": null,
67
+ "grid_template_areas": null,
68
+ "grid_template_columns": null,
69
+ "grid_template_rows": null,
70
+ "height": null,
71
+ "justify_content": null,
72
+ "justify_items": null,
73
+ "left": null,
74
+ "margin": null,
75
+ "max_height": null,
76
+ "max_width": null,
77
+ "min_height": null,
78
+ "min_width": "50px",
79
+ "object_fit": null,
80
+ "object_position": null,
81
+ "order": null,
82
+ "overflow": null,
83
+ "overflow_x": null,
84
+ "overflow_y": null,
85
+ "padding": null,
86
+ "right": null,
87
+ "top": null,
88
+ "visibility": null,
89
+ "width": null
90
+ }
91
+ },
92
+ "74cc9bb3b6124b8ab184ed5e16bd8cbb": {
93
+ "model_module": "@jupyter-widgets/controls",
94
+ "model_name": "ButtonStyleModel",
95
+ "model_module_version": "1.5.0",
96
+ "state": {
97
+ "_model_module": "@jupyter-widgets/controls",
98
+ "_model_module_version": "1.5.0",
99
+ "_model_name": "ButtonStyleModel",
100
+ "_view_count": null,
101
+ "_view_module": "@jupyter-widgets/base",
102
+ "_view_module_version": "1.2.0",
103
+ "_view_name": "StyleView",
104
+ "button_color": null,
105
+ "font_weight": ""
106
+ }
107
+ }
108
+ }
109
+ }
110
+ },
111
+ "cells": [
112
+ {
113
+ "cell_type": "code",
114
+ "source": [
115
+ "#@markdown # Connect Google Drive\n",
116
+ "from google.colab import drive\n",
117
+ "from IPython.display import clear_output\n",
118
+ "import ipywidgets as widgets\n",
119
+ "import os\n",
120
+ "\n",
121
+ "def inf(msg, style, wdth): inf = widgets.Button(description=msg, disabled=True, button_style=style, layout=widgets.Layout(min_width=wdth));display(inf)\n",
122
+ "Shared_Drive = \"\" #@param {type:\"string\"}\n",
123
+ "#@markdown - Leave empty if you're not using a shared drive\n",
124
+ "\n",
125
+ "print(\"\u001b[0;33mConnecting...\")\n",
126
+ "drive.mount('/content/gdrive')\n",
127
+ "\n",
128
+ "if Shared_Drive!=\"\" and os.path.exists(\"/content/gdrive/Shareddrives\"):\n",
129
+ " mainpth=\"Shareddrives/\"+Shared_Drive\n",
130
+ "else:\n",
131
+ " mainpth=\"MyDrive\"\n",
132
+ "\n",
133
+ "clear_output()\n",
134
+ "inf('\\u2714 Done','success', '50px')\n",
135
+ "\n",
136
+ "#@markdown ---"
137
+ ],
138
+ "metadata": {
139
+ "colab": {
140
+ "base_uri": "https://localhost:8080/",
141
+ "height": 49,
142
+ "referenced_widgets": [
143
+ "4bd64e113ca7427998bd22fa07c6a5b2",
144
+ "b67f1fa6fa7142d6b90c3a04600083d2",
145
+ "74cc9bb3b6124b8ab184ed5e16bd8cbb"
146
+ ]
147
+ },
148
+ "id": "PsMA61hEqyny",
149
+ "outputId": "48da1305-ded8-439b-c904-d6fac6669d7b"
150
+ },
151
+ "execution_count": 1,
152
+ "outputs": [
153
+ {
154
+ "output_type": "display_data",
155
+ "data": {
156
+ "text/plain": [
157
+ "Button(button_style='success', description='✔ Done', disabled=True, layout=Layout(min_width='50px'), style=But…"
158
+ ],
159
+ "application/vnd.jupyter.widget-view+json": {
160
+ "version_major": 2,
161
+ "version_minor": 0,
162
+ "model_id": "4bd64e113ca7427998bd22fa07c6a5b2"
163
+ }
164
+ },
165
+ "metadata": {}
166
+ }
167
+ ]
168
+ },
169
+ {
170
+ "cell_type": "code",
171
+ "execution_count": 2,
172
+ "metadata": {
173
+ "colab": {
174
+ "base_uri": "https://localhost:8080/"
175
+ },
176
+ "id": "YXvRbuFFoPQT",
177
+ "outputId": "d9fc704d-9192-4845-cbd7-91c4fd07b0eb"
178
+ },
179
+ "outputs": [
180
+ {
181
+ "output_type": "stream",
182
+ "name": "stdout",
183
+ "text": [
184
+ "Collecting gradio\n",
185
+ " Downloading gradio-3.50.2-py3-none-any.whl (20.3 MB)\n",
186
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m20.3/20.3 MB\u001b[0m \u001b[31m54.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
187
+ "\u001b[?25hCollecting aiofiles<24.0,>=22.0 (from gradio)\n",
188
+ " Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)\n",
189
+ "Requirement already satisfied: altair<6.0,>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.2.2)\n",
190
+ "Collecting fastapi (from gradio)\n",
191
+ " Downloading fastapi-0.104.0-py3-none-any.whl (92 kB)\n",
192
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.9/92.9 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
193
+ "\u001b[?25hCollecting ffmpy (from gradio)\n",
194
+ " Downloading ffmpy-0.3.1.tar.gz (5.5 kB)\n",
195
+ " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
196
+ "Collecting gradio-client==0.6.1 (from gradio)\n",
197
+ " Downloading gradio_client-0.6.1-py3-none-any.whl (299 kB)\n",
198
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m299.2/299.2 kB\u001b[0m \u001b[31m28.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
199
+ "\u001b[?25hCollecting httpx (from gradio)\n",
200
+ " Downloading httpx-0.25.0-py3-none-any.whl (75 kB)\n",
201
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.7/75.7 kB\u001b[0m \u001b[31m9.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
202
+ "\u001b[?25hCollecting huggingface-hub>=0.14.0 (from gradio)\n",
203
+ " Downloading huggingface_hub-0.18.0-py3-none-any.whl (301 kB)\n",
204
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m302.0/302.0 kB\u001b[0m \u001b[31m26.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
205
+ "\u001b[?25hRequirement already satisfied: importlib-resources<7.0,>=1.3 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.1.0)\n",
206
+ "Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.2)\n",
207
+ "Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.3)\n",
208
+ "Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n",
209
+ "Requirement already satisfied: numpy~=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.23.5)\n",
210
+ "Collecting orjson~=3.0 (from gradio)\n",
211
+ " Downloading orjson-3.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (138 kB)\n",
212
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m138.7/138.7 kB\u001b[0m \u001b[31m12.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
213
+ "\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (23.2)\n",
214
+ "Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.5.3)\n",
215
+ "Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (9.4.0)\n",
216
+ "Requirement already satisfied: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.10.13)\n",
217
+ "Collecting pydub (from gradio)\n",
218
+ " Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",
219
+ "Collecting python-multipart (from gradio)\n",
220
+ " Downloading python_multipart-0.0.6-py3-none-any.whl (45 kB)\n",
221
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.7/45.7 kB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
222
+ "\u001b[?25hRequirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.1)\n",
223
+ "Requirement already satisfied: requests~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.31.0)\n",
224
+ "Collecting semantic-version~=2.0 (from gradio)\n",
225
+ " Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n",
226
+ "Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.5.0)\n",
227
+ "Collecting uvicorn>=0.14.0 (from gradio)\n",
228
+ " Downloading uvicorn-0.23.2-py3-none-any.whl (59 kB)\n",
229
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.5/59.5 kB\u001b[0m \u001b[31m6.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
230
+ "\u001b[?25hCollecting websockets<12.0,>=10.0 (from gradio)\n",
231
+ " Downloading websockets-11.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129 kB)\n",
232
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m129.9/129.9 kB\u001b[0m \u001b[31m13.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
233
+ "\u001b[?25hRequirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==0.6.1->gradio) (2023.6.0)\n",
234
+ "Requirement already satisfied: entrypoints in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (0.4)\n",
235
+ "Requirement already satisfied: jsonschema>=3.0 in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (4.19.1)\n",
236
+ "Requirement already satisfied: toolz in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (0.12.0)\n",
237
+ "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio) (3.12.4)\n",
238
+ "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio) (4.66.1)\n",
239
+ "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.1.1)\n",
240
+ "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (0.12.1)\n",
241
+ "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (4.43.1)\n",
242
+ "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.4.5)\n",
243
+ "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (3.1.1)\n",
244
+ "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (2.8.2)\n",
245
+ "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2023.3.post1)\n",
246
+ "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio) (3.3.0)\n",
247
+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio) (3.4)\n",
248
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio) (2.0.7)\n",
249
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio) (2023.7.22)\n",
250
+ "Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.10/dist-packages (from uvicorn>=0.14.0->gradio) (8.1.7)\n",
251
+ "Collecting h11>=0.8 (from uvicorn>=0.14.0->gradio)\n",
252
+ " Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n",
253
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m6.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
254
+ "\u001b[?25hRequirement already satisfied: anyio<4.0.0,>=3.7.1 in /usr/local/lib/python3.10/dist-packages (from fastapi->gradio) (3.7.1)\n",
255
+ "Collecting starlette<0.28.0,>=0.27.0 (from fastapi->gradio)\n",
256
+ " Downloading starlette-0.27.0-py3-none-any.whl (66 kB)\n",
257
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.0/67.0 kB\u001b[0m \u001b[31m7.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
258
+ "\u001b[?25hCollecting typing-extensions~=4.0 (from gradio)\n",
259
+ " Downloading typing_extensions-4.8.0-py3-none-any.whl (31 kB)\n",
260
+ "Collecting httpcore<0.19.0,>=0.18.0 (from httpx->gradio)\n",
261
+ " Downloading httpcore-0.18.0-py3-none-any.whl (76 kB)\n",
262
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.0/76.0 kB\u001b[0m \u001b[31m9.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
263
+ "\u001b[?25hRequirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (1.3.0)\n",
264
+ "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<4.0.0,>=3.7.1->fastapi->gradio) (1.1.3)\n",
265
+ "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (23.1.0)\n",
266
+ "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (2023.7.1)\n",
267
+ "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.30.2)\n",
268
+ "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.10.6)\n",
269
+ "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n",
270
+ "Building wheels for collected packages: ffmpy\n",
271
+ " Building wheel for ffmpy (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
272
+ " Created wheel for ffmpy: filename=ffmpy-0.3.1-py3-none-any.whl size=5579 sha256=20e3a3d081fba3e6b2fd3d72da1820db62227a8909bbe93f2cb55db32817eb91\n",
273
+ " Stored in directory: /root/.cache/pip/wheels/01/a6/d1/1c0828c304a4283b2c1639a09ad86f83d7c487ef34c6b4a1bf\n",
274
+ "Successfully built ffmpy\n",
275
+ "Installing collected packages: pydub, ffmpy, websockets, typing-extensions, semantic-version, python-multipart, orjson, h11, aiofiles, uvicorn, starlette, huggingface-hub, httpcore, httpx, fastapi, gradio-client, gradio\n",
276
+ " Attempting uninstall: typing-extensions\n",
277
+ " Found existing installation: typing_extensions 4.5.0\n",
278
+ " Uninstalling typing_extensions-4.5.0:\n",
279
+ " Successfully uninstalled typing_extensions-4.5.0\n",
280
+ "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
281
+ "lida 0.0.10 requires kaleido, which is not installed.\n",
282
+ "tensorflow-probability 0.22.0 requires typing-extensions<4.6.0, but you have typing-extensions 4.8.0 which is incompatible.\u001b[0m\u001b[31m\n",
283
+ "\u001b[0mSuccessfully installed aiofiles-23.2.1 fastapi-0.104.0 ffmpy-0.3.1 gradio-3.50.2 gradio-client-0.6.1 h11-0.14.0 httpcore-0.18.0 httpx-0.25.0 huggingface-hub-0.18.0 orjson-3.9.9 pydub-0.25.1 python-multipart-0.0.6 semantic-version-2.10.0 starlette-0.27.0 typing-extensions-4.8.0 uvicorn-0.23.2 websockets-11.0.3\n",
284
+ "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (2.31.0)\n",
285
+ "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests) (3.3.0)\n",
286
+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests) (3.4)\n",
287
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests) (2.0.7)\n",
288
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests) (2023.7.22)\n",
289
+ "Requirement already satisfied: pillow in /usr/local/lib/python3.10/dist-packages (9.4.0)\n"
290
+ ]
291
+ }
292
+ ],
293
+ "source": [
294
+ "#@markdown # Install Requirements\n",
295
+ "\n",
296
+ "!pip install gradio\n",
297
+ "!pip install requests\n",
298
+ "!pip install pillow"
299
+ ]
300
+ },
301
+ {
302
+ "cell_type": "code",
303
+ "source": [
304
+ "#@markdown # Run Interface\n",
305
+ "\n",
306
+ "import gradio as gr\n",
307
+ "import requests\n",
308
+ "import io\n",
309
+ "import random\n",
310
+ "import os\n",
311
+ "from PIL import Image\n",
312
+ "\n",
313
+ "HF_READ_TOKEN = \"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\" #@param {type:\"string\"}\n",
314
+ "API_URL = \"https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0\"\n",
315
+ "headers = {\"Authorization\": f\"Bearer {HF_READ_TOKEN}\"}\n",
316
+ "\n",
317
+ "def query(prompt, is_negative=False, image_style=\"None style\", steps=50, cfg_scale=7, seed=None):\n",
318
+ " if image_style == \"None style\":\n",
319
+ " payload = {\n",
320
+ " \"inputs\": prompt + \", 8k\",\n",
321
+ " \"is_negative\": is_negative,\n",
322
+ " \"steps\": steps,\n",
323
+ " \"cfg_scale\": cfg_scale,\n",
324
+ " \"seed\": seed if seed is not None else random.randint(-1, 2147483647)\n",
325
+ " }\n",
326
+ " elif image_style == \"Cinematic\":\n",
327
+ " payload = {\n",
328
+ " \"inputs\": prompt+\", realistic, detailed, textured, skin, hair, eyes, by Alex Huguet, Mike Hill, Ian Spriggs, JaeCheol Park, Marek Denko\",\n",
329
+ " \"is_negative\": is_negative+\", abstract, cartoon, stylized\",\n",
330
+ " \"steps\": steps,\n",
331
+ " \"cfg_scale\": cfg_scale,\n",
332
+ " \"seed\": seed if seed is not None else random.randint(-1, 2147483647)\n",
333
+ " }\n",
334
+ " elif image_style == \"Digital Art\":\n",
335
+ " payload = {\n",
336
+ " \"inputs\": prompt + \", faded , vintage , nostalgic , by Jose Villa , Elizabeth Messina , Ryan Brenizer , Jonas Peterson , Jasmine Star\",\n",
337
+ " \"is_negative\": is_negative + \", sharp , modern , bright\",\n",
338
+ " \"steps\": steps,\n",
339
+ " \"cfg_scale\": cfg_scale,\n",
340
+ " \"seed\": seed if seed is not None else random.randint(-1, 2147483647)\n",
341
+ " }\n",
342
+ " elif image_style == \"Portrait\":\n",
343
+ " payload = {\n",
344
+ " \"inputs\": prompt + \", soft light, sharp, exposure blend, medium shot, bokeh, (hdr:1.4), high contrast, (cinematic, teal and orange:0.85), (muted colors, dim colors, soothing tones:1.3), low saturation, (hyperdetailed:1.2), (noir:0.4), (natural skin texture, hyperrealism, soft light, sharp:1.2)\",\n",
345
+ " \"is_negative\": is_negative,\n",
346
+ " \"steps\": steps,\n",
347
+ " \"cfg_scale\": cfg_scale,\n",
348
+ " \"seed\": seed if seed is not None else random.randint(-1, 2147483647)\n",
349
+ " }\n",
350
+ " # Вставьте ваш код для запроса к модели и получения изображения\n",
351
+ " image_bytes = requests.post(API_URL, headers=headers, json=payload).content\n",
352
+ " image = Image.open(io.BytesIO(image_bytes))\n",
353
+ " return image\n",
354
+ "\n",
355
+ "\n",
356
+ "css = \"\"\"\n",
357
+ " .gradio-container {\n",
358
+ " font-family: 'IBM Plex Sans', sans-serif;\n",
359
+ " }\n",
360
+ " .gr-button {\n",
361
+ " color: white;\n",
362
+ " border-color: black;\n",
363
+ " background: black;\n",
364
+ " }\n",
365
+ " input[type='range'] {\n",
366
+ " accent-color: black;\n",
367
+ " }\n",
368
+ " .dark input[type='range'] {\n",
369
+ " accent-color: #dfdfdf;\n",
370
+ " }\n",
371
+ " .gradio-container {\n",
372
+ " max-width: 730px !important;\n",
373
+ " margin: auto;\n",
374
+ " padding-top: 1.5rem;\n",
375
+ " }\n",
376
+ " #gallery {\n",
377
+ " min-height: 22rem;\n",
378
+ " margin-bottom: 15px;\n",
379
+ " margin-left: auto;\n",
380
+ " margin-right: auto;\n",
381
+ " border-bottom-right-radius: .5rem !important;\n",
382
+ " border-bottom-left-radius: .5rem !important;\n",
383
+ " }\n",
384
+ " #gallery>div>.h-full {\n",
385
+ " min-height: 20rem;\n",
386
+ " }\n",
387
+ " .details:hover {\n",
388
+ " text-decoration: underline;\n",
389
+ " }\n",
390
+ " .gr-button {\n",
391
+ " white-space: nowrap;\n",
392
+ " }\n",
393
+ " .gr-button:focus {\n",
394
+ " border-color: rgb(147 197 253 / var(--tw-border-opacity));\n",
395
+ " outline: none;\n",
396
+ " box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);\n",
397
+ " --tw-border-opacity: 1;\n",
398
+ " --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n",
399
+ " --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);\n",
400
+ " --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));\n",
401
+ " --tw-ring-opacity: .5;\n",
402
+ " }\n",
403
+ " #advanced-btn {\n",
404
+ " font-size: .7rem !important;\n",
405
+ " line-height: 19px;\n",
406
+ " margin-top: 12px;\n",
407
+ " margin-bottom: 12px;\n",
408
+ " padding: 2px 8px;\n",
409
+ " border-radius: 14px !important;\n",
410
+ " }\n",
411
+ " #advanced-options {\n",
412
+ " display: none;\n",
413
+ " margin-bottom: 20px;\n",
414
+ " }\n",
415
+ " .footer {\n",
416
+ " margin-bottom: 45px;\n",
417
+ " margin-top: 35px;\n",
418
+ " text-align: center;\n",
419
+ " border-bottom: 1px solid #e5e5e5;\n",
420
+ " }\n",
421
+ " .footer>p {\n",
422
+ " font-size: .8rem;\n",
423
+ " display: inline-block;\n",
424
+ " padding: 0 10px;\n",
425
+ " transform: translateY(10px);\n",
426
+ " background: white;\n",
427
+ " }\n",
428
+ " .dark .footer {\n",
429
+ " border-color: #303030;\n",
430
+ " }\n",
431
+ " .dark .footer>p {\n",
432
+ " background: #0b0f19;\n",
433
+ " }\n",
434
+ " .acknowledgments h4{\n",
435
+ " margin: 1.25em 0 .25em 0;\n",
436
+ " font-weight: bold;\n",
437
+ " font-size: 115%;\n",
438
+ " }\n",
439
+ " .animate-spin {\n",
440
+ " animation: spin 1s linear infinite;\n",
441
+ " }\n",
442
+ " @keyframes spin {\n",
443
+ " from {\n",
444
+ " transform: rotate(0deg);\n",
445
+ " }\n",
446
+ " to {\n",
447
+ " transform: rotate(360deg);\n",
448
+ " }\n",
449
+ " }\n",
450
+ " #share-btn-container {padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; max-width: 13rem; margin-left: auto;}\n",
451
+ " div#share-btn-container > div {flex-direction: row;background: black;align-items: center}\n",
452
+ " #share-btn-container:hover {background-color: #060606}\n",
453
+ " #share-btn {all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.5rem !important; padding-bottom: 0.5rem !important;right:0;}\n",
454
+ " #share-btn * {all: unset}\n",
455
+ " #share-btn-container div:nth-child(-n+2){width: auto !important;min-height: 0px !important;}\n",
456
+ " #share-btn-container .wrap {display: none !important}\n",
457
+ " #share-btn-container.hidden {display: none!important}\n",
458
+ "\n",
459
+ " .gr-form{\n",
460
+ " flex: 1 1 50%; border-top-right-radius: 0; border-bottom-right-radius: 0;\n",
461
+ " }\n",
462
+ " #prompt-container{\n",
463
+ " gap: 0;\n",
464
+ " }\n",
465
+ " #prompt-container .form{\n",
466
+ " border-top-right-radius: 0;\n",
467
+ " border-bottom-right-radius: 0;\n",
468
+ " }\n",
469
+ " #gen-button{\n",
470
+ " border-top-left-radius:0;\n",
471
+ " border-bottom-left-radius:0;\n",
472
+ " }\n",
473
+ " #prompt-text-input, #negative-prompt-text-input{padding: .45rem 0.625rem}\n",
474
+ " #component-16{border-top-width: 1px!important;margin-top: 1em}\n",
475
+ " .image_duplication{position: absolute; width: 100px; left: 50px}\n",
476
+ " .tabitem{border: 0 !important}\n",
477
+ "\"\"\"\n",
478
+ "\n",
479
+ "with gr.Blocks(css=css) as sdxl:\n",
480
+ " gr.HTML(\n",
481
+ " \"\"\"\n",
482
+ " <div style=\"text-align: center; margin: 0 auto;\">\n",
483
+ " <div\n",
484
+ " style=\"\n",
485
+ " display: inline-flex;\n",
486
+ " align-items: center;\n",
487
+ " gap: 0.8rem;\n",
488
+ " font-size: 1.75rem;\n",
489
+ " \"\n",
490
+ " >\n",
491
+ " <svg\n",
492
+ " width=\"0.65em\"\n",
493
+ " height=\"0.65em\"\n",
494
+ " viewBox=\"0 0 115 115\"\n",
495
+ " fill=\"none\"\n",
496
+ " xmlns=\"http://www.w3.org/2000/svg\"\n",
497
+ " >\n",
498
+ " <rect width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
499
+ " <rect y=\"69\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
500
+ " <rect x=\"23\" width=\"23\" height=\"23\" fill=\"#AEAEAE\"></rect>\n",
501
+ " <rect x=\"23\" y=\"69\" width=\"23\" height=\"23\" fill=\"#AEAEAE\"></rect>\n",
502
+ " <rect x=\"46\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
503
+ " <rect x=\"46\" y=\"69\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
504
+ " <rect x=\"69\" width=\"23\" height=\"23\" fill=\"black\"></rect>\n",
505
+ " <rect x=\"69\" y=\"69\" width=\"23\" height=\"23\" fill=\"black\"></rect>\n",
506
+ " <rect x=\"92\" width=\"23\" height=\"23\" fill=\"#D9D9D9\"></rect>\n",
507
+ " <rect x=\"92\" y=\"69\" width=\"23\" height=\"23\" fill=\"#AEAEAE\"></rect>\n",
508
+ " <rect x=\"115\" y=\"46\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
509
+ " <rect x=\"115\" y=\"115\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
510
+ " <rect x=\"115\" y=\"69\" width=\"23\" height=\"23\" fill=\"#D9D9D9\"></rect>\n",
511
+ " <rect x=\"92\" y=\"46\" width=\"23\" height=\"23\" fill=\"#AEAEAE\"></rect>\n",
512
+ " <rect x=\"92\" y=\"115\" width=\"23\" height=\"23\" fill=\"#AEAEAE\"></rect>\n",
513
+ " <rect x=\"92\" y=\"69\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
514
+ " <rect x=\"69\" y=\"46\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
515
+ " <rect x=\"69\" y=\"115\" width=\"23\" height=\"23\" fill=\"white\"></rect>\n",
516
+ " <rect x=\"69\" y=\"69\" width=\"23\" height=\"23\" fill=\"#D9D9D9\"></rect>\n",
517
+ " <rect x=\"46\" y=\"46\" width=\"23\" height=\"23\" fill=\"black\"></rect>\n",
518
+ " <rect x=\"46\" y=\"115\" width=\"23\" height=\"23\" fill=\"black\"></rect>\n",
519
+ " <rect x=\"46\" y=\"69\" width=\"23\" height=\"23\" fill=\"black\"></rect>\n",
520
+ " <rect x=\"23\" y=\"46\" width=\"23\" height=\"23\" fill=\"#D9D9D9\"></rect>\n",
521
+ " <rect x=\"23\" y=\"115\" width=\"23\" height=\"23\" fill=\"#AEAEAE\"></rect>\n",
522
+ " <rect x=\"23\" y=\"69\" width=\"23\" height=\"23\" fill=\"black\"></rect>\n",
523
+ " </svg>\n",
524
+ " <h1 style=\"font-weight: 900; margin-bottom: 7px;margin-top:5px\">\n",
525
+ " 🎨 Super-Fast SDXL on <a href=\"https://colab.research.google.com/\">Colab</a>\n",
526
+ " </h1>\n",
527
+ " </div>\n",
528
+ " <p style=\"margin-bottom: 10px; font-size: 94%; line-height: 23px;\">\n",
529
+ " SDXL is a high quality text-to-image model from Stability AI. This demo is running on <a style=\"text-decoration: underline;\" href=\"https://huggingface.co/docs/api-inference/quicktour\">HuggingFace Inference API ⚡</a>, to achieve efficient and cost-effective inference of 1024×1024 images. <a href=\"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0\" target=\"_blank\">What model?</a>\n",
530
+ " </p>\n",
531
+ " </div>\n",
532
+ " \"\"\"\n",
533
+ " )\n",
534
+ "\n",
535
+ " with gr.Row():\n",
536
+ " with gr.Column(scale=1):\n",
537
+ " text_prompt = gr.Textbox(label=\"Prompt\", placeholder=\"a cute cat\", lines=1, elem_id=\"prompt-text-input\")\n",
538
+ " negative_prompt = gr.Textbox(label=\"Negative Prompt\", value=\"text, blurry, fuzziness\", lines=1, elem_id=\"negative-prompt-text-input\")\n",
539
+ " image_style = gr.Dropdown(label=\"Style\", choices=[\"None style\", \"Cinematic\", \"Digital Art\", \"Portrait\"], value=\"None style\", allow_custom_value=False)\n",
540
+ " text_button = gr.Button(\"Generate\", variant='primary', elem_id=\"gen-button\")\n",
541
+ " with gr.Row():\n",
542
+ " with gr.Column(scale=1):\n",
543
+ " image_output = gr.Image(type=\"pil\", label=\"Output Image\", elem_id=\"gallery\")\n",
544
+ "\n",
545
+ " text_button.click(query, inputs=[text_prompt, negative_prompt, image_style], outputs=image_output)\n",
546
+ "\n",
547
+ "sdxl.launch(show_api=False)\n"
548
+ ],
549
+ "metadata": {
550
+ "colab": {
551
+ "base_uri": "https://localhost:8080/",
552
+ "height": 626
553
+ },
554
+ "id": "aI3p1Z6BotJ6",
555
+ "outputId": "45eb0abc-813e-4962-9d6b-72271b27c982"
556
+ },
557
+ "execution_count": 4,
558
+ "outputs": [
559
+ {
560
+ "output_type": "stream",
561
+ "name": "stdout",
562
+ "text": [
563
+ "Setting queue=True in a Colab notebook requires sharing enabled. Setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).\n",
564
+ "\n",
565
+ "Colab notebook detected. To show errors in colab notebook, set debug=True in launch()\n",
566
+ "Running on public URL: https://37a6d604a362850b45.gradio.live\n",
567
+ "\n",
568
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
569
+ ]
570
+ },
571
+ {
572
+ "output_type": "display_data",
573
+ "data": {
574
+ "text/plain": [
575
+ "<IPython.core.display.HTML object>"
576
+ ],
577
+ "text/html": [
578
+ "<div><iframe src=\"https://37a6d604a362850b45.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
579
+ ]
580
+ },
581
+ "metadata": {}
582
+ },
583
+ {
584
+ "output_type": "execute_result",
585
+ "data": {
586
+ "text/plain": []
587
+ },
588
+ "metadata": {},
589
+ "execution_count": 4
590
+ }
591
+ ]
592
+ }
593
+ ]
594
+ }