Commit
•
c2de314
1
Parent(s):
0be13db
Update Scripts/mainpaperspaceA1111.py
Browse files
Scripts/mainpaperspaceA1111.py
CHANGED
@@ -8,6 +8,7 @@ import ipywidgets as widgets
|
|
8 |
from torch.hub import download_url_to_file
|
9 |
from urllib.parse import urlparse
|
10 |
import re
|
|
|
11 |
|
12 |
|
13 |
|
@@ -287,6 +288,54 @@ def sd(User, Password, Use_localtunnel, model):
|
|
287 |
|
288 |
return configf
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
def done():
|
292 |
done = widgets.Button(
|
|
|
8 |
from torch.hub import download_url_to_file
|
9 |
from urllib.parse import urlparse
|
10 |
import re
|
11 |
+
from pyngrok import ngrok, conf
|
12 |
|
13 |
|
14 |
|
|
|
288 |
|
289 |
return configf
|
290 |
|
291 |
+
|
292 |
+
|
293 |
+
def sdui(User, Password, Ngrok_token, model):
|
294 |
+
|
295 |
+
auth=f"--gradio-auth {User}:{Password}"
|
296 |
+
if User =="" or Password=="":
|
297 |
+
auth=""
|
298 |
+
|
299 |
+
share=''
|
300 |
+
call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
|
301 |
+
|
302 |
+
if Ngrok_token!="":
|
303 |
+
ngrok.kill()
|
304 |
+
srv=ngrok.connect(7860, pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token) , bind_tls=True).public_url
|
305 |
+
|
306 |
+
for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
|
307 |
+
if line.strip().startswith('self.server_name ='):
|
308 |
+
line = f' self.server_name = "{srv[8:]}"\n'
|
309 |
+
if line.strip().startswith('self.protocol = "https"'):
|
310 |
+
line = ' self.protocol = "https"\n'
|
311 |
+
if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
|
312 |
+
line = ''
|
313 |
+
if line.strip().startswith('else "http"'):
|
314 |
+
line = ''
|
315 |
+
sys.stdout.write(line)
|
316 |
+
|
317 |
+
else:
|
318 |
+
share='--share'
|
319 |
+
|
320 |
+
os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
|
321 |
+
call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
|
322 |
+
call("sed -i 's@ui.create_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /notebooks/sd/stable-diffusion-webui/webui.py", shell=True)
|
323 |
+
call("sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/notebooks/sd/stablediffusion@' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
|
324 |
+
call("sed -i 's@\"quicksettings\": OptionInfo(.*@\"quicksettings\": OptionInfo(\"sd_model_checkpoint, sd_vae, CLIP_stop_at_last_layers, inpainting_mask_weight, initial_noise_multiplier\", \"Quicksettings list\"),@' /notebooks/sd/stable-diffusion-webui/modules/shared.py", shell=True)
|
325 |
+
os.chdir('/notebooks/sd/stable-diffusion-webui')
|
326 |
+
clear_output()
|
327 |
+
|
328 |
+
|
329 |
+
if os.path.isfile(model):
|
330 |
+
mdlpth="--ckpt "+model
|
331 |
+
else:
|
332 |
+
mdlpth="--ckpt-dir "+model
|
333 |
+
|
334 |
+
|
335 |
+
configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --skip-version-check "+auth+" "+share+" "+mdlpth
|
336 |
+
|
337 |
+
return configf
|
338 |
+
|
339 |
|
340 |
def done():
|
341 |
done = widgets.Button(
|