Carlos2312 commited on
Commit
490f759
·
verified ·
1 Parent(s): b2d39bc

Update modelos.py

Browse files
Files changed (1) hide show
  1. modelos.py +82 -41
modelos.py CHANGED
@@ -3,14 +3,18 @@ from ipywidgets import widgets, Layout
3
  import os
4
  from nenen88 import download, say, tempe
5
 
6
- paths = ["/home/studio-lab-user/forge/asd/cn-1_5.css",
7
- "/home/studio-lab-user/asd/asd/cn-1_5.css"]
8
 
9
- file_path = next((path for path in paths if os.path.exists(path)), None)
10
- if file_path:
11
- with open(file_path, "r") as oppai:
12
- susu = oppai.read()
13
- display(HTML(f"<style>{susu}</style>"))
 
 
 
 
14
 
15
  url_list = {
16
  "FastPonyMerge_version75 (Pony)": [
@@ -78,55 +82,92 @@ url_list = {
78
  "SourceOfTheGoddess_003LCM (1.5)": [
79
  "https://huggingface.co/Carlos2312/models/resolve/main/sourceOfTheGoddess_003LCM.safetensors sourceOfTheGoddess_003LCM.safetensors"]}
80
 
81
- half_list_1 = dict(list(url_list.items())[:len(url_list)//2])
82
- half_list_2 = dict(list(url_list.items())[len(url_list)//2:])
 
83
 
84
- def create_checkbox_group(url_dict):
85
- return widgets.VBox([widgets.Checkbox(value=False, description=name, style={'description_width': '0px'}) for name in url_dict])
 
 
86
 
87
- cb1 = create_checkbox_group(half_list_1)
88
- cb2 = create_checkbox_group(half_list_2)
89
- cbc = widgets.HBox([cb1, cb2], layout=widgets.Layout(align_items='flex-start'))
 
90
 
91
  db = widgets.Button(description="Download")
92
- sab = widgets.Button(description="Select All")
93
- usab = widgets.Button(description="Unselect All")
94
- bs = widgets.Button(description="")
 
 
 
95
 
96
- def toggle_checkboxes(state):
97
  for checkbox in cb1.children + cb2.children:
98
- checkbox.value = state
99
 
100
- sab.on_click(lambda b: toggle_checkboxes(True))
101
- usab.on_click(lambda b: toggle_checkboxes(False))
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  bl = widgets.HBox([sab, usab, db, bs])
104
- boks2 = widgets.VBox([bl, cbc], layout=Layout(display='flex', flex_flow='column', width='630px', height='455px', align_items='center', padding='10px'))
 
 
 
 
 
 
105
  boks2.add_class("boks2")
106
-
107
  def d_b_click(b):
108
- surl = [url for checkbox, key in zip(cb1.children + cb2.children, url_list.keys()) if checkbox.value for url in url_list[key]]
109
-
 
 
 
110
  widgets.Widget.close(boks2)
111
  dbo.clear_output()
112
 
113
- display(HTML("<div class='gradient-cn2'>forge</div>"))
 
114
 
115
- dir_paths = ["/home/studio-lab-user/forge/models/Stable-diffusion/tmp_ckpt",
116
- "/home/studio-lab-user/asd/models/Stable-diffusion/tmp_ckpt"]
117
-
118
- directory_path = next((path for path in dir_paths if os.path.exists(path)), None)
119
-
120
- if directory_path:
121
- with dbo:
122
- say("【{red} Downloading{cyan} Models{magenta} Models{yellow} 】{red}")
123
- os.chdir(directory_path)
124
- for url in surl:
125
- download(url)
126
- say("【{red} Done{d} 】{red}")
127
 
128
- db.on_click(d_b_click)
 
 
 
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  tempe()
131
- display(boks2)
132
- display(widgets.Output())
 
3
  import os
4
  from nenen88 import download, say, tempe
5
 
6
+ bura = "/home/studio-lab-user/forge/asd/cn-1_5.css"
7
+ bura2 = "/home/studio-lab-user/asd/asd/cn-1_5.css"
8
 
9
+ # Check if the file exists at the first location
10
+ if os.path.exists(bura):
11
+ file_path = bura
12
+ else:
13
+ file_path = bura2
14
+
15
+ with open(file_path, "r") as oppai:
16
+ susu = oppai.read()
17
+ display(HTML(f"<style>{susu}</style>"))
18
 
19
  url_list = {
20
  "FastPonyMerge_version75 (Pony)": [
 
82
  "SourceOfTheGoddess_003LCM (1.5)": [
83
  "https://huggingface.co/Carlos2312/models/resolve/main/sourceOfTheGoddess_003LCM.safetensors sourceOfTheGoddess_003LCM.safetensors"]}
84
 
85
+ list_half = len(url_list) // 2
86
+ half_list_1 = dict(list(url_list.items())[:list_half])
87
+ half_list_2 = dict(list(url_list.items())[list_half:])
88
 
89
+ cb1 = widgets.VBox(
90
+ [widgets.Checkbox(value=False, description=name, style={'description_width': '0px'})
91
+ for name in half_list_1])
92
+ cb1.add_class("checkbox-group1")
93
 
94
+ cb2 = widgets.VBox(
95
+ [widgets.Checkbox(value=False, description=name, style={'description_width': '0px'})
96
+ for name in half_list_2])
97
+ cb2.add_class("checkbox-group2")
98
 
99
  db = widgets.Button(description="Download")
100
+ db.add_class("download-button")
101
+ dbo = widgets.Output()
102
+ cbc = widgets.HBox([cb1, cb2], layout=widgets.Layout(align_items='flex-start'))
103
+
104
+ gariz3 = """<div class="gradient-cn2">forge</div>"""
105
+ garis3 = widgets.Output()
106
 
107
+ def sa_cb(b):
108
  for checkbox in cb1.children + cb2.children:
109
+ checkbox.value = True
110
 
111
+ def usa_cb(b):
112
+ for checkbox in cb1.children + cb2.children:
113
+ checkbox.value = False
114
+
115
+ sab = widgets.Button(description="Select All")
116
+ sab.add_class("select-all-button")
117
+ sab.on_click(sa_cb)
118
+
119
+ usab = widgets.Button(description="Unselect All")
120
+ usab.add_class("unselect-all-button")
121
+ usab.on_click(usa_cb)
122
+
123
+ bs = widgets.Button(description="")
124
+ bs.add_class("border-style")
125
 
126
  bl = widgets.HBox([sab, usab, db, bs])
127
+ boks2 = widgets.VBox([bl, cbc], layout=Layout(
128
+ display='flex',
129
+ flex_flow='column',
130
+ width='630px',
131
+ height='455px',
132
+ align_items='center',
133
+ padding='10px'))
134
  boks2.add_class("boks2")
135
+
136
  def d_b_click(b):
137
+ surl = []
138
+ for checkbox, key in zip(cb1.children + cb2.children, list(url_list.keys())):
139
+ if checkbox.value:
140
+ surl.extend(url_list[key])
141
+
142
  widgets.Widget.close(boks2)
143
  dbo.clear_output()
144
 
145
+ with garis3:
146
+ display(HTML(gariz3))
147
 
148
+ # Define the two directory paths
149
+ dir_path_1 = "/home/studio-lab-user/forge/models/Stable-diffusion/tmp_ckpt"
150
+ dir_path_2 = "/home/studio-lab-user/asd/models/Stable-diffusion/tmp_ckpt"
 
 
 
 
 
 
 
 
 
151
 
152
+ # Check if the directory exists at the first location
153
+ if os.path.exists(dir_path_1):
154
+ directory_path = dir_path_1
155
+ else:
156
+ directory_path = dir_path_2
157
 
158
+ # Change the current directory to the selected directory
159
+ with dbo:
160
+ say("【{red} Downloading{cyan} Models{magenta} Models{yellow} 】{red}")
161
+ os.chdir(directory_path)
162
+
163
+ for url in surl:
164
+ download(url)
165
+
166
+ with garis3:
167
+ garis3.clear_output()
168
+
169
+ say("【{red} Done{d} 】{red}")
170
+
171
  tempe()
172
+ display(boks2, dbo, garis3)
173
+ db.on_click(d_b_click)