cloudwp commited on
Commit
b248e97
·
1 Parent(s): cf5d6f0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +72 -0
app.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #@markdown # Connect Google Drive
2
+ from google.colab import drive
3
+ from IPython.display import clear_output
4
+ import ipywidgets as widgets
5
+ import os
6
+
7
+ def inf(msg, style, wdth): inf = widgets.Button(description=msg, disabled=True, button_style=style, layout=widgets.Layout(min_width=wdth));display(inf)
8
+ Shared_Drive = "" #@param {type:"string"}
9
+ #@markdown - Leave empty if you're not using a shared drive
10
+
11
+ print("Connecting...")
12
+ drive.mount('/content/gdrive')
13
+
14
+ if Shared_Drive!="" and os.path.exists("/content/gdrive/Shareddrives"):
15
+ mainpth="Shareddrives/"+Shared_Drive
16
+ else:
17
+ mainpth="MyDrive"
18
+
19
+ clear_output()
20
+ inf('\u2714 Done','success', '50px')
21
+
22
+ #@markdown # Install/Update AUTOMATIC1111 repo
23
+ from IPython.utils import capture
24
+ from IPython.display import clear_output
25
+ from subprocess import getoutput
26
+ import ipywidgets as widgets
27
+ import sys
28
+ import fileinput
29
+ import os
30
+ import time
31
+ import base64
32
+
33
+ Use_Latest_Working_Commit= False #@param {type:"boolean"}
34
+
35
+ #@markdown - Use the pre-major A1111 update commit to avoid bugs while the repo is fixed
36
+
37
+ blasphemy=base64.b64decode(("d2VidWk=").encode('ascii')).decode('ascii')
38
+
39
+ if not os.path.exists("/content/gdrive"):
40
+ print('Gdrive not connected, using colab storage ...')
41
+ time.sleep(4)
42
+ mainpth="MyDrive"
43
+ !mkdir -p /content/gdrive/$mainpth
44
+ Shared_Drive=""
45
+
46
+ if Shared_Drive!="" and not os.path.exists("/content/gdrive/Shareddrives"):
47
+ print('Shared drive not detected, using default MyDrive')
48
+ mainpth="MyDrive"
49
+
50
+ with capture.capture_output() as cap:
51
+ def inf(msg, style, wdth): inf = widgets.Button(description=msg, disabled=True, button_style=style, layout=widgets.Layout(min_width=wdth));display(inf)
52
+ fgitclone = "git clone --depth 1"
53
+ %mkdir -p /content/gdrive/$mainpth/sd
54
+ %cd /content/gdrive/$mainpth/sd
55
+ !git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-$blasphemy
56
+ !mkdir -p /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/cache/
57
+ os.environ['TRANSFORMERS_CACHE']=f"/content/gdrive/{mainpth}/sd/stable-diffusion-"+blasphemy+"/cache"
58
+
59
+ with capture.capture_output() as cap:
60
+ %cd /content/gdrive/$mainpth/sd/stable-diffusion-$blasphemy/
61
+ !git reset --hard
62
+ time.sleep(1)
63
+ !rm webui.sh
64
+ !git pull
65
+ if Use_Latest_Working_Commit:
66
+ !git fetch --unshallow
67
+ !git checkout a9eab236d7e8afa4d6205127904a385b2c43bb24
68
+ !pip install gradio==3.16.2 --no-deps -qq
69
+ else:
70
+ !pip install gradio==3.23 --no-deps -qq
71
+ clear_output()
72
+ inf('\u2714 Done','success', '50px')