@@ -257,6 +257,20 @@ def load_prompt_handler(_file, *args):
257
257
return ctrls
258
258
259
259
260
+ def load_last_prompt_handler (* args ):
261
+ ctrls = list (args )
262
+ if exists (modules .path .last_prompt_path ):
263
+ with open (modules .path .last_prompt_path , encoding = 'utf-8' ) as json_file :
264
+ try :
265
+ json_obj = json .load (json_file )
266
+ metadata_to_ctrls (json_obj , ctrls )
267
+ except Exception as e :
268
+ print ('load_last_prompt_handler, e: ' + str (e ))
269
+ finally :
270
+ json_file .close ()
271
+ return ctrls
272
+
273
+
260
274
def load_input_images_handler (files ):
261
275
return list (map (lambda x : x .name , files )), gr .update (selected = GALLERY_ID_INPUT ), gr .update (value = len (files ))
262
276
@@ -377,7 +391,9 @@ def clear_default_image():
377
391
seed_random = gr .Checkbox (label = 'Random' , value = settings ['seed_random' ])
378
392
same_seed_for_all = gr .Checkbox (label = 'Same seed for all images' , value = settings ['same_seed_for_all' ])
379
393
image_seed = gr .Textbox (label = 'Seed' , value = settings ['seed' ], max_lines = 1 , visible = not settings ['seed_random' ])
380
- load_prompt_button = gr .UploadButton (label = 'Load Prompt' , file_count = 'single' , file_types = ['.json' , '.png' , '.jpg' ], elem_classes = 'type_small_row' , min_width = 0 )
394
+ with gr .Row ():
395
+ load_prompt_button = gr .UploadButton (label = 'Load Prompt' , file_count = 'single' , file_types = ['.json' , '.png' , '.jpg' ], elem_classes = 'type_small_row' , min_width = 0 )
396
+ load_last_prompt_button = gr .Button (label = 'Load Last Prompt' , value = 'Load Last Prompt' , elem_classes = 'type_small_row' , min_width = 0 )
381
397
382
398
def get_current_links ():
383
399
return '<a href="https://github.com/lllyasviel/Fooocus/discussions/117">📔 Fooocus Advanced</a>' \
@@ -589,6 +605,8 @@ def verify_input(img2img, canny, depth, gallery_in, gallery_rev, gallery_out):
589
605
ctrls += [save_metadata_json , save_metadata_image ] + img2img_ctrls + [same_seed_for_all , output_format ]
590
606
ctrls += canny_ctrls + depth_ctrls + [prompt_expansion ] + freeu_ctrls
591
607
load_prompt_button .upload (fn = load_prompt_handler , inputs = [load_prompt_button ] + ctrls + [seed_random ], outputs = ctrls + [seed_random ])
608
+ load_last_prompt_button .click (fn = load_last_prompt_handler , inputs = ctrls + [seed_random ], outputs = ctrls + [seed_random ])
609
+
592
610
ctrls += [input_image_checkbox , current_tab ]
593
611
ctrls += [uov_method , uov_input_image ]
594
612
ctrls += [outpaint_selections , inpaint_input_image ]
0 commit comments