136
136
username = ''
137
137
api_endpoint = os .environ ['api_endpoint' ]
138
138
industrial_model = ''
139
- endpoint_name = ''
140
- endpoint_names = []
141
139
default_options = {}
142
140
143
141
def reload_hypernetworks ():
@@ -268,7 +266,49 @@ def options_section(section_identifier, options_dict):
268
266
269
267
options_templates = {}
270
268
269
+ def refresh_sagemaker_endpoints ():
270
+ global industrial_model , api_endpoint , default_options
271
+
272
+ if industrial_model == '' :
273
+ response = requests .get (url = f'{ api_endpoint } /sd/industrialmodel' )
274
+ if response .status_code == 200 :
275
+ industrial_model = response .text
276
+ else :
277
+ model_name = 'stable-diffusion-webui'
278
+ model_description = model_name
279
+ inputs = {
280
+ 'model_algorithm' : 'stable-diffusion-webui' ,
281
+ 'model_name' : model_name ,
282
+ 'model_description' : model_description ,
283
+ 'model_extra' : '{"visible": "false"}' ,
284
+ 'model_samples' : '' ,
285
+ 'file_content' : {
286
+ 'data' : [(lambda x : int (x ))(x ) for x in open (os .path .join (script_path , 'logo.ico' ), 'rb' ).read ()]
287
+ }
288
+ }
289
+
290
+ response = requests .post (url = f'{ api_endpoint } /industrialmodel' , json = inputs )
291
+ if response .status_code == 200 :
292
+ body = json .loads (response .text )
293
+ industrial_model = body ['id' ]
294
+
295
+ default_options = self .data
296
+
297
+ sagemaker_endpoints = []
298
+
299
+ if industrial_model != '' :
300
+ params = {
301
+ 'industrial_model' : industrial_model
302
+ }
303
+ response = requests .get (url = f'{ api_endpoint } /endpoint' , params = params )
304
+ if response .status_code == 200 :
305
+ for endpoint_item in json .loads (response .text ):
306
+ sagemaker_endpoints .append (endpoint_item ['EndpointName' ])
307
+
308
+ return sagemaker_endpoints
309
+
271
310
options_templates .update (options_section (('sd' , "Stable Diffusion" ), {
311
+ "sagemaker_endpoint" : OptionInfo (None , "SaegMaker endpoint" , gr .Dropdown , lambda : {"choices" : refresh_sagemaker_endpoints ()}, refresh = refresh_sagemaker_endpoints ),
272
312
"sd_model_checkpoint" : OptionInfo (None , "Stable Diffusion checkpoint" , gr .Dropdown , lambda : {"choices" : modules .sd_models .checkpoint_tiles ()}, refresh = sd_models .list_models ),
273
313
"sd_checkpoint_cache" : OptionInfo (0 , "Checkpoints to cache in RAM" , gr .Slider , {"minimum" : 0 , "maximum" : 10 , "step" : 1 }),
274
314
"sd_vae" : OptionInfo ("auto" , "SD VAE" , gr .Dropdown , lambda : {"choices" : list (sd_vae .vae_list )}, refresh = sd_vae .refresh_vae_list ),
@@ -393,7 +433,7 @@ def options_section(section_identifier, options_dict):
393
433
"js_modal_lightbox" : OptionInfo (True , "Enable full page image viewer" ),
394
434
"js_modal_lightbox_initially_zoomed" : OptionInfo (True , "Show images zoomed in by default in full page image viewer" ),
395
435
"show_progress_in_title" : OptionInfo (True , "Show generation progress in window title." ),
396
- 'quicksettings' : OptionInfo ("sd_model_checkpoint " , "Quicksettings list" ),
436
+ 'quicksettings' : OptionInfo ("sagemaker_endpoint " , "Quicksettings list" ),
397
437
'localization' : OptionInfo ("None" , "Localization (requires restart)" , gr .Dropdown , lambda : {"choices" : ["None" ] + list (localization .localizations .keys ())}, refresh = lambda : localization .list_localizations (cmd_opts .localizations_dir )),
398
438
}))
399
439
@@ -480,34 +520,6 @@ def load(self, filename):
480
520
if bad_settings > 0 :
481
521
print (f"The program is likely to not work with bad settings.\n Settings file: { filename } \n Either fix the file, or delete it and restart." , file = sys .stderr )
482
522
483
- if cmd_opts .pureui :
484
- global api_endpoint , industrial_model , default_options
485
-
486
- #opts.show_progressbar = False
487
- response = requests .get (url = f'{ api_endpoint } /sd/industrialmodel' )
488
- if response .status_code == 200 :
489
- industrial_model = response .text
490
- else :
491
- model_name = 'stable-diffusion-webui'
492
- model_description = model_name
493
- inputs = {
494
- 'model_algorithm' : 'stable-diffusion-webui' ,
495
- 'model_name' : model_name ,
496
- 'model_description' : model_description ,
497
- 'model_extra' : '{"visible": "false"}' ,
498
- 'model_samples' : '' ,
499
- 'file_content' : {
500
- 'data' : [(lambda x : int (x ))(x ) for x in open (os .path .join (script_path , 'logo.ico' ), 'rb' ).read ()]
501
- }
502
- }
503
-
504
- response = requests .post (url = f'{ api_endpoint } /industrialmodel' , json = inputs )
505
- if response .status_code == 200 :
506
- body = json .loads (response .text )
507
- industrial_model = body ['id' ]
508
-
509
- default_options = self .data
510
-
511
523
def onchange (self , key , func , call = True ):
512
524
item = self .data_labels .get (key )
513
525
item .onchange = func
@@ -587,18 +599,3 @@ def clear(self):
587
599
def listfiles (dirname ):
588
600
filenames = [os .path .join (dirname , x ) for x in sorted (os .listdir (dirname )) if not x .startswith ("." )]
589
601
return [file for file in filenames if os .path .isfile (file )]
590
-
591
- if cmd_opts .pureui :
592
- def init_endpoints ():
593
- global endpoint_name , endpoint_names , industrial_model , api_endpoint
594
-
595
- endpoints = []
596
- params = {
597
- 'industrial_model' : industrial_model
598
- }
599
- response = requests .get (url = f'{ api_endpoint } /endpoint' , params = params )
600
- if response .status_code == 200 :
601
- for endpoint_item in json .loads (response .text ):
602
- endpoints .append (endpoint_item ['EndpointName' ])
603
- endpoint_name = endpoints [0 ] if len (endpoints ) > 0 else ''
604
- endpoint_names = endpoints
0 commit comments