@@ -311,10 +311,19 @@ def webui():
311
311
if cmd_controlnet_models_path is not None :
312
312
cn_models_dir = cmd_controlnet_models_path
313
313
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
+
314
319
if 'endpoint_name' in os .environ :
315
- items = []
316
320
api_endpoint = os .environ ['api_endpoint' ]
317
321
endpoint_name = os .environ ['endpoint_name' ]
322
+
323
+ items = []
324
+ params = {
325
+ 'module' : 'Stable-diffusion'
326
+ }
318
327
for file in os .listdir (sd_models_dir ):
319
328
if os .path .isfile (os .path .join (sd_models_dir , file )) and (file .endswith ('.ckpt' ) or file .endswith ('.safetensors' )):
320
329
hash = modules .sd_models .model_hash (os .path .join (sd_models_dir , file ))
@@ -329,17 +338,11 @@ def webui():
329
338
inputs = {
330
339
'items' : items
331
340
}
332
- params = {
333
- 'module' : 'Stable-diffusion'
334
- }
335
341
if api_endpoint .startswith ('http://' ) or api_endpoint .startswith ('https://' ):
336
342
response = requests .post (url = f'{ api_endpoint } /sd/models' , json = inputs , params = params )
337
343
print (response )
338
344
339
345
items = []
340
- inputs = {
341
- 'items' : items
342
- }
343
346
params = {
344
347
'module' : 'ControlNet'
345
348
}
@@ -352,10 +355,33 @@ def webui():
352
355
item ['title' ] = '{0} [{1}]' .format (os .path .splitext (file )[0 ], hash )
353
356
item ['endpoint_name' ] = endpoint_name
354
357
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 )
355
364
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
+ }
356
381
if api_endpoint .startswith ('http://' ) or api_endpoint .startswith ('https://' ):
357
382
response = requests .post (url = f'{ api_endpoint } /sd/models' , json = inputs , params = params )
358
383
print (response )
384
+
359
385
ui_extra_networks .add_pages_to_demo (app )
360
386
361
387
modules .script_callbacks .app_started_callback (shared .demo , app )
0 commit comments