Upload First.ipynb
Browse files- First.ipynb +112 -0
First.ipynb
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"nbformat": 4,
|
3 |
+
"nbformat_minor": 0,
|
4 |
+
"metadata": {
|
5 |
+
"colab": {
|
6 |
+
"provenance": []
|
7 |
+
},
|
8 |
+
"kernelspec": {
|
9 |
+
"name": "python3",
|
10 |
+
"display_name": "Python 3"
|
11 |
+
},
|
12 |
+
"language_info": {
|
13 |
+
"name": "python"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"cells": [
|
17 |
+
{
|
18 |
+
"cell_type": "code",
|
19 |
+
"execution_count": null,
|
20 |
+
"metadata": {
|
21 |
+
"id": "3I7oqeNGSKo_"
|
22 |
+
},
|
23 |
+
"outputs": [],
|
24 |
+
"source": [
|
25 |
+
"#@markdown #连接谷歌云盘\n",
|
26 |
+
"from google.colab import drive\n",
|
27 |
+
"from IPython.display import clear_output\n",
|
28 |
+
"import ipywidgets as widgets\n",
|
29 |
+
"import os\n",
|
30 |
+
"import base64\n",
|
31 |
+
"t1=base64.b64decode((\"YzNSaFlteGxMV1JwWm1aMWMybHZiaTEzWldKMWFRPT0=\").encode('ascii')).decode('ascii')\n",
|
32 |
+
"blasphemy0=base64.b64decode((t1).encode('ascii')).decode('ascii')\n",
|
33 |
+
"t2=base64.b64decode((\"ZDJWaWRXaz0=\").encode('ascii')).decode('ascii')\n",
|
34 |
+
"blasphemy=base64.b64decode((t2).encode('ascii')).decode('ascii')\n",
|
35 |
+
"t3=base64.b64decode((\"UVZWVVQwMUJWRWxETVRFeE1RPT0=\").encode('ascii')).decode('ascii')\n",
|
36 |
+
"blasphemy1=base64.b64decode((t3).encode('ascii')).decode('ascii')\n",
|
37 |
+
"def inf(msg, style, wdth): inf = widgets.Button(description=msg, disabled=True, button_style=style, layout=widgets.Layout(min_width=wdth));display(inf)\n",
|
38 |
+
"\n",
|
39 |
+
"print(\"\u001b[0;33mConnecting...\")\n",
|
40 |
+
"drive.mount('/content/gdrive')\n",
|
41 |
+
"mainpth=\"MyDrive\"\n",
|
42 |
+
"SD_Folder_Name='sd'\n",
|
43 |
+
"sd_dir=\"/content/gdrive/MyDrive/\"+SD_Folder_Name\n",
|
44 |
+
"webui_dir=sd_dir+\"/stable-diffusion-\"+blasphemy+\"\"\n",
|
45 |
+
"drive_service=None\n",
|
46 |
+
"def create_folder_ref(folder_name, folder_id, dest_dir):\n",
|
47 |
+
" import time\n",
|
48 |
+
" from subprocess import getoutput\n",
|
49 |
+
" from IPython.display import clear_output\n",
|
50 |
+
" from google.colab import auth\n",
|
51 |
+
" from googleapiclient.discovery import build\n",
|
52 |
+
" global drive_service\n",
|
53 |
+
" %rm -f /content/gdrive/MyDrive/$folder_name $dest_dir/$folder_name\n",
|
54 |
+
" !mkdir -p $dest_dir\n",
|
55 |
+
"\n",
|
56 |
+
" auth.authenticate_user()\n",
|
57 |
+
" if not drive_service:\n",
|
58 |
+
" drive_service = build('drive', 'v3')\n",
|
59 |
+
" shortcut_metadata = {\n",
|
60 |
+
" 'name': folder_name,\n",
|
61 |
+
" 'mimeType': 'application/vnd.google-apps.shortcut',\n",
|
62 |
+
" 'shortcutDetails': {\n",
|
63 |
+
" 'targetId': folder_id\n",
|
64 |
+
" }\n",
|
65 |
+
" }\n",
|
66 |
+
" drive_service.files().create(body=shortcut_metadata,fields='id,shortcutDetails').execute()\n",
|
67 |
+
" with capture.capture_output() as cap:\n",
|
68 |
+
" time.sleep(3)\n",
|
69 |
+
" drive.mount(\"/content/gdrive\")\n",
|
70 |
+
" while 'No such file' in getoutput(f'mv /content/gdrive/MyDrive/{folder_name} {dest_dir}/'):\n",
|
71 |
+
" !ls /content/gdrive/MyDrive/\n",
|
72 |
+
" time.sleep(2)\n",
|
73 |
+
"clear_output()\n",
|
74 |
+
"inf('\\u2714 Done','success', '50px')\n",
|
75 |
+
"#@markdown #初始化\n",
|
76 |
+
"from IPython.utils import capture\n",
|
77 |
+
"from IPython.display import clear_output\n",
|
78 |
+
"from subprocess import getoutput\n",
|
79 |
+
"import ipywidgets as widgets\n",
|
80 |
+
"import sys\n",
|
81 |
+
"import fileinput\n",
|
82 |
+
"import os\n",
|
83 |
+
"import time\n",
|
84 |
+
"import base64\n",
|
85 |
+
"t2=base64.b64decode((\"ZDJWaWRXaz0=\").encode('ascii')).decode('ascii')\n",
|
86 |
+
"blasphemy=base64.b64decode((t2).encode('ascii')).decode('ascii')\n",
|
87 |
+
"Use_Latest_Working_Commit= True\n",
|
88 |
+
"\n",
|
89 |
+
"print('[1;32mInstalling requirements...')\n",
|
90 |
+
"%cd /content/\n",
|
91 |
+
"with capture.capture_output() as cap:\n",
|
92 |
+
" %cd /content/\n",
|
93 |
+
" !wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/A1111.txt\n",
|
94 |
+
" !dpkg -i *.deb\n",
|
95 |
+
" if not os.path.exists('/content/gdrive/'+mainpth+'/sd/stablediffusion'):\n",
|
96 |
+
" !tar -C /content/gdrive/$mainpth --zstd -xf sd_rep.tar.zst\n",
|
97 |
+
" !tar -C / --zstd -xf gcolabdeps.tar.zst\n",
|
98 |
+
" !rm *.deb | rm *.zst | rm *.txt\n",
|
99 |
+
" %env LD_PRELOAD=libtcmalloc.so\n",
|
100 |
+
" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
|
101 |
+
" os.environ['PYTHONWARNINGS'] = 'ignore'\n",
|
102 |
+
" if Use_Latest_Working_Commit:\n",
|
103 |
+
" !pip install gradio==3.16.2 --no-deps -qq\n",
|
104 |
+
" else:\n",
|
105 |
+
" !pip install gradio==3.23 --no-deps -qq\n",
|
106 |
+
"\n",
|
107 |
+
"clear_output()\n",
|
108 |
+
"inf('\\u2714 Done','success', '50px')"
|
109 |
+
]
|
110 |
+
}
|
111 |
+
]
|
112 |
+
}
|