File size: 4,669 Bytes
c59858b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "3I7oqeNGSKo_"
      },
      "outputs": [],
      "source": [
        "#@markdown #连接谷歌云盘\n",
        "from google.colab import drive\n",
        "from IPython.display import clear_output\n",
        "import ipywidgets as widgets\n",
        "import os\n",
        "import base64\n",
        "t1=base64.b64decode((\"YzNSaFlteGxMV1JwWm1aMWMybHZiaTEzWldKMWFRPT0=\").encode('ascii')).decode('ascii')\n",
        "blasphemy0=base64.b64decode((t1).encode('ascii')).decode('ascii')\n",
        "t2=base64.b64decode((\"ZDJWaWRXaz0=\").encode('ascii')).decode('ascii')\n",
        "blasphemy=base64.b64decode((t2).encode('ascii')).decode('ascii')\n",
        "t3=base64.b64decode((\"UVZWVVQwMUJWRWxETVRFeE1RPT0=\").encode('ascii')).decode('ascii')\n",
        "blasphemy1=base64.b64decode((t3).encode('ascii')).decode('ascii')\n",
        "def inf(msg, style, wdth): inf = widgets.Button(description=msg, disabled=True, button_style=style, layout=widgets.Layout(min_width=wdth));display(inf)\n",
        "\n",
        "print(\"\u001b[0;33mConnecting...\")\n",
        "drive.mount('/content/gdrive')\n",
        "mainpth=\"MyDrive\"\n",
        "SD_Folder_Name='sd'\n",
        "sd_dir=\"/content/gdrive/MyDrive/\"+SD_Folder_Name\n",
        "webui_dir=sd_dir+\"/stable-diffusion-\"+blasphemy+\"\"\n",
        "drive_service=None\n",
        "def create_folder_ref(folder_name, folder_id, dest_dir):\n",
        "  import time\n",
        "  from subprocess import getoutput\n",
        "  from IPython.display import clear_output\n",
        "  from google.colab import auth\n",
        "  from googleapiclient.discovery import build\n",
        "  global drive_service\n",
        "  %rm -f /content/gdrive/MyDrive/$folder_name $dest_dir/$folder_name\n",
        "  !mkdir -p $dest_dir\n",
        "\n",
        "  auth.authenticate_user()\n",
        "  if not drive_service:\n",
        "    drive_service = build('drive', 'v3')\n",
        "  shortcut_metadata = {\n",
        "    'name': folder_name,\n",
        "    'mimeType': 'application/vnd.google-apps.shortcut',\n",
        "    'shortcutDetails': {\n",
        "      'targetId': folder_id\n",
        "    }\n",
        "  }\n",
        "  drive_service.files().create(body=shortcut_metadata,fields='id,shortcutDetails').execute()\n",
        "  with capture.capture_output() as cap:\n",
        "    time.sleep(3)\n",
        "    drive.mount(\"/content/gdrive\")\n",
        "    while 'No such file' in getoutput(f'mv /content/gdrive/MyDrive/{folder_name} {dest_dir}/'):\n",
        "      !ls /content/gdrive/MyDrive/\n",
        "      time.sleep(2)\n",
        "clear_output()\n",
        "inf('\\u2714 Done','success', '50px')\n",
        "#@markdown #初始化\n",
        "from IPython.utils import capture\n",
        "from IPython.display import clear_output\n",
        "from subprocess import getoutput\n",
        "import ipywidgets as widgets\n",
        "import sys\n",
        "import fileinput\n",
        "import os\n",
        "import time\n",
        "import base64\n",
        "t2=base64.b64decode((\"ZDJWaWRXaz0=\").encode('ascii')).decode('ascii')\n",
        "blasphemy=base64.b64decode((t2).encode('ascii')).decode('ascii')\n",
        "Use_Latest_Working_Commit= True\n",
        "\n",
        "print('[1;32mInstalling requirements...')\n",
        "%cd /content/\n",
        "with capture.capture_output() as cap:\n",
        "  %cd /content/\n",
        "  !wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/A1111.txt\n",
        "  !dpkg -i *.deb\n",
        "  if not os.path.exists('/content/gdrive/'+mainpth+'/sd/stablediffusion'):\n",
        "    !tar -C /content/gdrive/$mainpth --zstd -xf sd_rep.tar.zst\n",
        "  !tar -C / --zstd -xf gcolabdeps.tar.zst\n",
        "  !rm *.deb | rm *.zst | rm *.txt\n",
        "  %env LD_PRELOAD=libtcmalloc.so\n",
        "  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
        "  os.environ['PYTHONWARNINGS'] = 'ignore'\n",
        "  if Use_Latest_Working_Commit:\n",
        "    !pip install gradio==3.16.2 --no-deps -qq\n",
        "  else:\n",
        "    !pip install gradio==3.23 --no-deps -qq\n",
        "\n",
        "clear_output()\n",
        "inf('\\u2714 Done','success', '50px')"
      ]
    }
  ]
}