Transformers
Inference Endpoints
File size: 32,798 Bytes
f353d9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
# -*- coding: utf-8 -*-
"""V-Stable-diffusion (7).ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/15g1UiV6zBR7pa83BVSCXm5UQdc3-uO-h

<CENTER><font color="#FFD700">V Stable Diffusion</font> <center/>

<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif" width="800" height="18">
<center>    
*Bagi yang mau support saya bisa menuju Saweria, KO-FI dan Trakteer dibawah ini*
<center>
*For those who want to support me, you can go to Saweria, KO-FI and Trakteer below*
<center/>
<center><a href="https://saweria.co/VorstCavry"><img alt="Saweria" src="https://img.shields.io/badge/Saweria-7B3F00?style=for-the-badge&logo=ko-fi&logoColor=white"/></a> <a href="https://ko-fi.com/vorstcavry"><img alt="KO-FI" src="https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white "/></a> <a href="https://trakteer.id/vorstcavry/tip"><img alt="YOUTUBE" src="https://img.shields.io/badge/trakteer-F16061?style=for-the-badge&logo=buy-me-a-coffee&logoColor=white"/></a><a> <a href="https://www.youtube.com/@remajapekalongan"><img alt="YOUTUBE" src="https://img.shields.io/badge/YouTube-%23FF0000?style=for-the-badge&logo=YouTube&logoColor=white"/></a>
<a href="https://www.paypal.com/paypalme/vorstcavry?country.x=ID&locale.x=id_ID"><img alt="PAYPAL" src="https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white"/></a>
<a href="https://www.instagram.com/vorst_cavry/"><img alt="INSTAGRAM" src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white"/></a> <a href="https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fvorstcavry"><img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fvorstcavry&label=VISITORS&countColor=%23263759&labelStyle=none" /></a><center/>

### Conda
"""

import os
import time
import json
import base64
import shutil
import subprocess
import threading
import sys
import random
import string
from IPython.display import display, HTML
from IPython.display import clear_output
from IPython.utils import capture
from pydantic import BaseModel

def run_command(command, message):
    print(f"{message}")
    subprocess.run(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
    print(f"done")
print("\033[92mMenginstall gradio_client\033[0m")
run_command('pip install -q gradio_client==0.2.7', 'install gradio_client...')
clear_output(wait=True)
print("\033[92mMenginstall colablib\033[0m")
run_command('pip install -q git+https://github.com/Linaqruf/colablib', 'install colablib...')
clear_output(wait=True)
print("\033[92mMenginstall Upgrade urllib\033[0m")
run_command('pip install -q --upgrade urllib3 chardet charset_normalizer requests', 'install upgrade urllib3 chardet charset_normalizer requests...')
clear_output(wait=True)
print("\033[92mMenginstall gradio\033[0m")
run_command('pip install -U gradio', 'install gradio...')
clear_output(wait=True)

from colablib.utils.py_utils import get_filename
from typing import List, Optional
from colablib.colored_print import cprint, print_line
from colablib.utils import py_utils, config_utils, package_utils
from colablib.utils.config_utils import pastebin_reader as read
from colablib.utils.ubuntu_utils import ubuntu_deps
from colablib.sd_models.downloader import aria2_download, download, get_modelname
from colablib.utils.ubuntu_utils import unionfuse
from colablib.utils.config_utils import read_config
from colablib.utils.git_utils import clone_repo
from colablib.utils.git_utils import update_repo, batch_update, validate_repo, reset_repo, patch_repo
from colablib.colored_print import cprint as cp
from urllib.parse import urlparse


def run_command(command, message):
    print(f"{message}")
    subprocess.run(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
    print(f"done")
cp("Menginstall Conda", color='flat_green')
run_command('conda install -q -y conda', 'installing Conda...')
clear_output(wait=True)
cp("Menginstall Python", color='flat_green')
run_command('conda install -q -y python=3.10.12', 'installing Python 3.10.12...')
clear_output(wait=True)
cp("Menginstall Python glib", color='flat_green')
run_command('conda install -q -y -c conda-forge glib', 'installing glib...')
clear_output(wait=True)
cp("Menginstall aria2", color='flat_green')
run_command('conda install -q -y -c conda-forge aria2', 'installing aria2...')
clear_output(wait=True)
cp("MengUpdate Conda", color='flat_green')
run_command('conda update -q -y -n base -c defaults conda', 'updating Conda...')
clear_output(wait=True)
cp("Menginstall opencv-python;", color='flat_green')
run_command('pip install -q opencv-python', 'installing opencv-python...')
clear_output(wait=True)
cp("Menginstall httpx", color='flat_green')
run_command('pip install -q httpx==0.24.1', 'installing httpx...')
clear_output(wait=True)
cp("Menginstall torch", color='flat_green')
run_command('pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118 -U', 'installing torch...')
clear_output(wait=True)
cp("Menginstall xformers", color='flat_green')
run_command('pip install -q xformers==0.0.20 triton==2.0.0 -U', 'installing xformers...')
clear_output(wait=True)
cp("Menginstall GroundingDINO", color='flat_green')
run_command('pip install -q https://github.com/Bing-su/GroundingDINO/releases/download/0.1.0-2.0.1/groundingdino-0.1.0+torch2.0.1.cu118-cp310-cp310-linux_x86_64.whl -U', 'installing GroundingDINO..')
clear_output(wait=True)
cp("Selesai Menginstall", color='flat_green')
clear_output(wait=True)
cp("Selesai Menginstall, Lanjutkan Ke Proses Selanjutnya", color='flat_green')

"""### CONTOH TAMPILAN UI/UX STABLE DIFFUSION"""

#@title <font size="5"><font color="#FFFF5F">**Preview Tema :**</font>
#@markdown  untuk melihat preview semua tema yang bisa dipakai klik tombol [ < ] atau [ > ]

#https://www.w3schools.com/w3css/w3css_slideshow.asp
import IPython
IPython.display.HTML(

'''

<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
.mySlides {display:none;}
</style>
<body>

<div class="w3-content w3-display-container">

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/wCW7tXK/AUTOMATIC1111.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/MNXrf1F/CATPPUCIN.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/KX77dNp/DEVDARK.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/cwG2yGS/DOKI-Jupiter.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/fqTX9Bp/LINAQRUF.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/NrTPNbr/Nocypt-Miku.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/7ggWwwS/KITCHEN.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/2j2DQxD/LOBEHUB.png" style="width:100%">
</div>

<div class="w3-display-container mySlides">
  <img src="https://i.ibb.co/TMxwBR2/ANAPNOE.png" style="width:100%">
</div>


<button class="w3-button w3-display-left w3-black" onclick="plusDivs(-1)">&#10094;</button>
<button class="w3-button w3-display-right w3-black" onclick="plusDivs(1)">&#10095;</button>

</div>

<script>
var slideIndex = 1;
showDivs(slideIndex);

function plusDivs(n) {
  showDivs(slideIndex += n);
}

function showDivs(n) {
  var i;
  var x = document.getElementsByClassName("mySlides");
  if (n > x.length) {slideIndex = 1}
  if (n < 1) {slideIndex = x.length}
  for (i = 0; i < x.length; i++) {
     x[i].style.display = "none";
  }
  x[slideIndex-1].style.display = "block";
}
</script>

</body>
</html>

''')

"""### Clone SD"""

# Commented out IPython magic to ensure Python compatibility.
from IPython.display import clear_output

#@markdown <font size="3"><font color="#00F090">**Pilih Tema:**</font>
#@markdown > Tema `Anapnoe`, `Lobehub` dan `Kitchen` cocok untuk pengguna Mobile.
tema = "automatic1111" #@param ["automatic1111","catppuccin", "doki-jupiter", "linaqruf", "nocrypt-miku", "devdark", "anapnoe", "lobehub", "kitchen"]

def git_clone(url, folder_path):
    os.makedirs(folder_path, exist_ok=True)
    subprocess.run(['git', 'clone', url, folder_path])

def git_checkout(commit_hash, folder_path):
    os.chdir(folder_path)
    subprocess.run(['git', 'checkout', commit_hash])

def delete_directory(path):
    try:
        os.system(f"rm -rf {path}")
    except Exception as e:
        print(f"nothing: {str(e)}")


if (tema == "automatic1111") :
  url = 'https://tinyurl.com/Vorst-Cavry-Auto1111'
  folder_path = '/home/studio-lab-user/vorst-cavry'
  git_clone(url, folder_path)
  clear_output(wait=True)
  cp("Menggunakan Tema Automatic1111", color='flat_green')
elif (tema == "catppuccin") :
  url = 'https://tinyurl.com/Vorst-Cavry-Auto1111'
  folder_path = '/home/studio-lab-user/vorst-cavry'
  git_clone(url, folder_path)
  clear_output(wait=True)
  repo_url = 'https://tinyurl.com/CATPPUCCIN-Repo'
  destination_folder = '/home/studio-lab-user/vorst-cavry/extensions/catppuccin-theme'
  git_clone(repo_url, destination_folder)
  clear_output(wait=True)
  cp("Menggunakan Tema Catppuccin", color='flat_green')
elif (tema == "doki-jupiter") :
  url = 'https://tinyurl.com/Vorst-Cavry-Auto1111'
  folder_path = '/home/studio-lab-user/vorst-cavry'
  git_clone(url, folder_path)
  clear_output(wait=True)
  repo_url = 'https://github.com/vorstcavry/doki-theme'
  destination_folder = '/home/studio-lab-user/vorst-cavry/extensions/doki-theme'
  git_clone(repo_url, destination_folder)
  clear_output(wait=True)
  cp("Menggunakan Tema Doki", color='flat_green')
elif (tema == "linaqruf") :
  url = 'https://tinyurl.com/Vorst-Cavry-Auto1111'
  folder_path = '/home/studio-lab-user/vorst-cavry'
  git_clone(url, folder_path)
  clear_output(wait=True)
  url = 'https://huggingface.co/vorstcavry/test/resolve/main/ui-config.json'
  output_directory = os.path.join(repo_dir)
  download_with_aria2(url, output_directory)
  url = 'https://huggingface.co/vorstcavry/test/resolve/main/config.json'
  output_directory = os.path.join(repo_dir)
  download_with_aria2(url, output_directory)
  clear_output(wait=True)
  cp("Menggunakan Tema Linaqruf", color='flat_green')
elif (tema == "nocrypt-miku") :
  url = 'https://tinyurl.com/Vorst-Cavry-Auto1111'
  folder_path = '/home/studio-lab-user/vorst-cavry'
  git_clone(url, folder_path)
  clear_output(wait=True)
#   %cd ~/vorst-cavry
  !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/vorstcavry/ui/resolve/main/ui.zip?download=true -o ui.zip
  !unzip -o ui.zip
  !rm ui.zip
  clear_output(wait=True)
  cp("Menggunakan Tema Nocrypt Miku", color='flat_green')
elif (tema == "devdark") :
  url = 'https://tinyurl.com/Vorst-Cavry-Auto1111'
  folder_path = '/home/studio-lab-user/vorst-cavry'
  git_clone(url, folder_path)
  clear_output(wait=True)
  repo_url = 'https://tinyurl.com/Devdark-Theme'
  destination_folder = '/home/studio-lab-user/vorst-cavry/extensions/devdark-theme'
  git_clone(repo_url, destination_folder)
  clear_output(wait=True)
  cp("Menggunakan Tema Devdark", color='flat_green')
elif (tema == "anapnoe") :
  repo_url = 'https://tinyurl.com/Anapnoe-ux-Repo'
  destination_folder = '/home/studio-lab-user/vorst-cavry'
  git_clone(repo_url, destination_folder)
  clear_output(wait=True)
  cp("Menggunakan Tema Anepnoe", color='flat_green')

cp("Mempersiapkan Timmer", color='flat_green')
repo_url = 'https://github.com/vorstcavry/ncpt_colab_timer'
destination_folder = '/home/studio-lab-user/vorst-cavry/extensions/ncpt_colab_timer'
git_clone(repo_url, destination_folder)
repo_url = 'https://github.com/vorstcavry/ncpt_colab_timer'
destination_folder = '/home/studio-lab-user/vorst-cavry/static'
git_clone(repo_url, destination_folder)



import time
try:
  start_sagemaker
except:
  start_sagemaker = int(time.time())-5
!echo -n {start_sagemaker} > /home/studio-lab-user/vorst-cavry/static/colabTimer.txt

cp("Mempersiapkan Folder tambahan", color='flat_green')
!ln -vs /tmp ~/tmp
!ln -vs /tmp/outputs /home/studio-lab-user/vorst-cavry/outputs
!ln -vs /tmp/models /home/studio-lab-user/vorst-cavry/models/Stable-diffusion/tmp_models
!mkdir ~/vorst-cavry/models/Lora
!ln -vs /tmp/Lora /home/studio-lab-user/vorst-cavry/models/Lora/tmp_Lora
!rm -r /home/studio-lab-user/.cache
cp("Selesai Mempersiapkan folder tambahan", color='flat_green')

"""### *Extensions*"""

# Commented out IPython magic to ensure Python compatibility.
# extensions
# %cd ~/vorst-cavry/extensions
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://github.com/etherealxx/batchlinks-webui
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://github.com/vorstcavry/images-browser
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://github.com/DominikDoom/a1111-sd-webui-tagcomplete
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://github.com/Iyashinouta/sd-model-downloader
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://github.com/NoCrypt/sd_hf_out
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://tinyurl.com/additional-networks-s
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://github.com/NoCrypt/inpaint-nav
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://github.com/BlafKing/sd-civitai-browser-plus
cp("Mempersiapkan Extension", color='flat_green')
clear_output(wait=True)
cp("Mempersiapkan Extension", color='flat_green')
!git clone --depth 1 https://tinyurl.com/aspect-ratio-v
clear_output(wait=True)
#!git clone
#!git clone
#!git clone
#!git clone
#!git clone
#!git clone
#!git clone
cp("Selesai Mempersiapkan Extension", color='flat_green')

"""#### *ControlNET* (optional)"""

# Commented out IPython magic to ensure Python compatibility.
# persistent
# %cd ~/vorst-cavry/extensions
cp("Mempersiapkan ControlNET", color='flat_green')
!git clone -b v1.1.416 https://tinyurl.com/controlnet-s
clear_output(wait=True)
!rm -rd ~/vorst-cavry/extensions/sd-webui-controlnet/models
cp("Mempersiapkan CntrolNET", color='flat_green')
!git clone --depth 1 https://github.com/fkunn1326/openpose-editor
clear_output(wait=True)
#git clone --depth 1 https://github.com/nonnonstop/sd-webui-3d-open-pose-editor
!git clone --depth 1 https://github.com/hnmr293/posex
!git clone --depth 1 https://github.com/IDEA-Research/DWPose

!ln -vs /tmp/controlnet_models /home/studio-lab-user/vorst-cavry/extensions/sd-webui-controlnet/models
clear_output(wait=True)
cp("Selesai Mempersiapkan ControlNET", color='flat_green')

# Commented out IPython magic to ensure Python compatibility.
# tmp
!mkdir -p /tmp/controlnet_models
clear_output(wait=True)
# %cd ~/vorst-cavry/extensions/sd-webui-controlnet/models
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors             -o control_v11e_sd15_ip2p_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors          -o control_v11e_sd15_shuffle_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors            -o control_v11p_sd15_canny_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors          -o control_v11f1p_sd15_depth_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors          -o control_v11p_sd15_inpaint_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors          -o control_v11p_sd15_lineart_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors             -o control_v11p_sd15_mlsd_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors        -o control_v11p_sd15_normalbae_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors         -o control_v11p_sd15_openpose_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors         -o control_v11p_sd15_scribble_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors              -o control_v11p_sd15_seg_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors         -o control_v11p_sd15_softedge_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors  -o control_v11p_sd15s2_lineart_anime_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors           -o control_v11f1e_sd15_tile_fp16.safetensors
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml                        -o control_v11e_sd15_ip2p_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml                     -o control_v11e_sd15_shuffle_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml                       -o control_v11p_sd15_canny_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml                     -o control_v11f1p_sd15_depth_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml                     -o control_v11p_sd15_inpaint_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml                     -o control_v11p_sd15_lineart_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml                        -o control_v11p_sd15_mlsd_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml                   -o control_v11p_sd15_normalbae_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml                    -o control_v11p_sd15_openpose_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml                    -o control_v11p_sd15_scribble_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml                         -o control_v11p_sd15_seg_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml                    -o control_v11p_sd15_softedge_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml             -o control_v11p_sd15s2_lineart_anime_fp16.yaml
clear_output(wait=True)
cp("Mempersiapkan Bahan ControlNET", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml                      -o control_v11f1e_sd15_tile_fp16.yaml
clear_output(wait=True)
cp("Selesai Mempersiapkan Bahan ControlNET", color='flat_green')
#import os
#from tqdm import tqdm

#packages = [
##            "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_canny_fp16.safetensors -d /home/studio-lab-user/vorst-cavry/models/ControlNet -o control_v11p_sd15_canny.safetensors",
#            "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors -d /home/studio-lab-user/vorst-cavry/models/ControlNet -o control_v11p_sd15_inpaint.safetensors",
#            "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_lineart_fp16.safetensors -d /home/studio-lab-user/vorst-cavry/models/ControlNet -o control_v11f1p_sd15_depth.safetensors",
#            "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_openpose_fp16.safetensors -d /home/studio-lab-user/vorst-cavry/models/ControlNet -o control_v11p_sd15_openpose.safetensors",
#            "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors -d /home/studio-lab-user/vorst-cavry/models/ControlNet -o control_v11p_sd15s2_lineart_anime.safetensors"
#]
#for install in tqdm(packages, desc=print("Install controlnet...")):
#    os.system(install)

"""### *Embeddings - Upscaler - VAE*"""

# Commented out IPython magic to ensure Python compatibility.
# embeddings
# %cd ~/vorst-cavry/embeddings
cp("Mempersiapkan embeddings", color='flat_green')
!git clone https://github.com/vorstcavry/embeddings /home/studio-lab-user/vorst-cavry/embeddings/negative
clear_output(wait=True)
cp("Selesai Mempersiapkan embeddings", color='flat_green')
# Upscaler
!mkdir ~/vorst-cavry/models/ESRGAN
# %cd ~/vorst-cavry/models/ESRGAN
cp("Mempersiapkan Upscaler", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/utnah/esrgan/resolve/main/8x_NMKD-Faces_160000_G.pth?download=true -o 8x_NMKD-Faces_160000_G.pth
clear_output(wait=True)
cp("Mempersiapkan Upscaler", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/utnah/esrgan/resolve/main/4x-AnimeSharp.pth?download=true          -o 4x-AnimeSharp.pth
clear_output(wait=True)
cp("Mempersiapkan Upscaler", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth         -o 4x_RealisticRescaler_100000_G.pth
clear_output(wait=True)
cp("Mempersiapkan Upscaler", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth                         -o 8x_RealESRGAN.pth
clear_output(wait=True)
cp("Selesai Mempersiapkan Upscaler", color='flat_green')
# VAE
# %cd ~/vorst-cavry/models/VAE
cp("Mempersiapkan VAE", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors                                                -o vae-ft-mse-840000-ema-pruned.safetensors
#aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/kl-f8-anime2_fp16.safetensors    -o kl-f8-anime2_fp16.safetensors
#aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/blessed2_fp16.safetensors        -o blessed2_fp16.safetensors
#aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/ClearVAE_V2.3_fp16.safetensors   -o ClearVAE_V2.3_fp16.safetensors
#aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/anything_fp16.safetensors        -o anything_fp16.safetensors
clear_output(wait=True)
cp("Selesai Mempersiapkan VAE", color='flat_green')
clear_output(wait=True)
cp("Selesai Mempersiapkan Bahan Tambahan", color='flat_green')

"""### *Checkpoint*"""

# Commented out IPython magic to ensure Python compatibility.
# persistent
# %cd ~/vorst-cavry/models/Stable-diffusion

#!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/77744  -o Meichidark_Mix_V2.safetensors

# Commented out IPython magic to ensure Python compatibility.
# tmp
!mkdir -p /tmp/models
clear_output(wait=True)
# %cd ~/vorst-cavry/models/Stable-diffusion/tmp_models
cp("Mempersiapkan Model", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/vorstcavry/mymodel/resolve/main/Cavry_V2.safetensors -o Cavry_V2.safetensors
clear_output(wait=True)
cp("Mempersiapkan Model", color='flat_green')
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/vorstcavry/mymodel/resolve/main/Cavry_V2.preview.png -o Cavry_V2.preview.png
clear_output(wait=True)
cp("Selesai Mempersiapkan Model", color='flat_green')

"""### *Lora*"""

# Commented out IPython magic to ensure Python compatibility.
# persistent
# %cd ~/vorst-cavry/models/Lora

!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/87153   -o add_detail.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/171989  -o detail_slider_v4.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/62833   -o Detail_Tweaker.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/86247   -o flat2.safetensors

# Commented out IPython magic to ensure Python compatibility.
# tmp
!mkdir -p /tmp/Lora
# %cd ~/vorst-cavry/models/Lora/tmp_Lora
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/87153   -o add_detail.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/171989  -o detail_slider_v4.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/62833   -o Detail_Tweaker.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/86247   -o flat2.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/146600  -o breastsizeslideroffset.safetensors

"""## *WEB UI*
- Output images are temporary
"""

# Commented out IPython magic to ensure Python compatibility.
cp("Memilih Versi Stable Difusion", color='flat_green')
repo = "update" #@param ["update", "standar", "default"]


def git_checkout(commit_hash, folder_path):
    os.chdir(folder_path)
    subprocess.run(['git', 'checkout', commit_hash])

if (repo == "update"):
#   %cd /home/studio-lab-user/vorst-cavry
  !git pull
  !git reset --hard
  !sed -i -e 's/\["sd_model_checkpoint"\]/\["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"\]/g' /home/studio-lab-user/vorst-cavry/modules/shared_options.py
  clear_output(wait=True)
  cp("Menggunakan Versi Terbaru", color='flat_green')
elif (repo == "standar"):
#   %cd /home/studio-lab-user/vorst-cavry
  folder_path = '/home/studio-lab-user/vorst-cavry'
  commit_hash = 'baf6946e06249c5af9851c60171692c44ef633e0'
  git_checkout(commit_hash, folder_path)
  !sed -i -e '''/from modules import launch_utils/a\import os''' /home/studio-lab-user/vorst-cavry/launch.py
  !sed -i -e '''/        prepare_environment()/a\        os.system\(f\"""sed -i -e ''\"s/dict()))/dict())).cuda()/g\"'' /home/studio-lab-user/vorst-cavry/repositories/stable-diffusion-stability-ai/ldm/util.py""")''' /home/studio-lab-user/vorst-cavry/launch.py
  !sed -i -e 's/\["sd_model_checkpoint"\]/\["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"\]/g' /home/studio-lab-user/vorst-cavry/modules/shared.py
  clear_output(wait=True)
  cp("Menggunakan Versi 1.5", color='flat_green')
elif (repo == "default"):
  !sed -i -e 's/\["sd_model_checkpoint"\]/\["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"\]/g' /home/studio-lab-user/vorst-cavry/modules/shared_options.py
  clear_output(wait=True)
  cp("Menggunakan Stable Diffusion 1.6", color='flat_green')