Skip to content

Commit 78b3a69

Browse files
committed
update webui.py
1 parent 5b62b1b commit 78b3a69

File tree

3 files changed

+33
-270
lines changed

3 files changed

+33
-270
lines changed

extensions-builtin/Lora/.ipynb_checkpoints/lora-checkpoint.py

-207
This file was deleted.

extensions-builtin/Lora/scripts/.ipynb_checkpoints/lora_script-checkpoint.py

-56
This file was deleted.

webui.py

+33-7
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,19 @@ def webui():
311311
if cmd_controlnet_models_path is not None:
312312
cn_models_dir = cmd_controlnet_models_path
313313

314+
cmd_lora_models_path = cmd_opts.lora_dir
315+
lora_models_dir = os.path.join(shared.models_path, "Lora")
316+
if cmd_lora_models_path is not None:
317+
lora_models_dir = cmd_lora_models_path
318+
314319
if 'endpoint_name' in os.environ:
315-
items = []
316320
api_endpoint = os.environ['api_endpoint']
317321
endpoint_name = os.environ['endpoint_name']
322+
323+
items = []
324+
params = {
325+
'module': 'Stable-diffusion'
326+
}
318327
for file in os.listdir(sd_models_dir):
319328
if os.path.isfile(os.path.join(sd_models_dir, file)) and (file.endswith('.ckpt') or file.endswith('.safetensors')):
320329
hash = modules.sd_models.model_hash(os.path.join(sd_models_dir, file))
@@ -329,17 +338,11 @@ def webui():
329338
inputs = {
330339
'items': items
331340
}
332-
params = {
333-
'module': 'Stable-diffusion'
334-
}
335341
if api_endpoint.startswith('http://') or api_endpoint.startswith('https://'):
336342
response = requests.post(url=f'{api_endpoint}/sd/models', json=inputs, params=params)
337343
print(response)
338344

339345
items = []
340-
inputs = {
341-
'items': items
342-
}
343346
params = {
344347
'module': 'ControlNet'
345348
}
@@ -352,10 +355,33 @@ def webui():
352355
item['title'] = '{0} [{1}]'.format(os.path.splitext(file)[0], hash)
353356
item['endpoint_name'] = endpoint_name
354357
items.append(item)
358+
inputs = {
359+
'items': items
360+
}
361+
if api_endpoint.startswith('http://') or api_endpoint.startswith('https://'):
362+
response = requests.post(url=f'{api_endpoint}/sd/models', json=inputs, params=params)
363+
print(response)
355364

365+
items = []
366+
params = {
367+
'module': 'Lora'
368+
}
369+
for file in os.listdir(lora_models_dir):
370+
if os.path.isfile(os.path.join(lora_models_dir, file)) and \
371+
(file.endswith('.pt') or file.endswith('.ckpt') or file.endswith('.safetensors')):
372+
hash = modules.sd_models.model_hash(os.path.join(lora_models_dir, file))
373+
item = {}
374+
item['model_name'] = file
375+
item['title'] = '{0} [{1}]'.format(os.path.splitext(file)[0], hash)
376+
item['endpoint_name'] = endpoint_name
377+
items.append(item)
378+
inputs = {
379+
'items': items
380+
}
356381
if api_endpoint.startswith('http://') or api_endpoint.startswith('https://'):
357382
response = requests.post(url=f'{api_endpoint}/sd/models', json=inputs, params=params)
358383
print(response)
384+
359385
ui_extra_networks.add_pages_to_demo(app)
360386

361387
modules.script_callbacks.app_started_callback(shared.demo, app)

0 commit comments

Comments
 (0)