|
22 | 22 | from modules.ui_gradio_extensions import reload_javascript
|
23 | 23 | from modules.util import get_current_log_path, get_previous_log_path
|
24 | 24 | from modules.auth import auth_enabled, check_auth
|
25 |
| -from os.path import exists |
| 25 | +from os.path import exists, join |
26 | 26 |
|
27 | 27 |
|
28 | 28 | GALLERY_ID_INPUT = 0
|
@@ -256,6 +256,21 @@ def load_prompt_handler(_file, *args):
|
256 | 256 | print('load_prompt_handler, e: ' + str(e))
|
257 | 257 | return ctrls
|
258 | 258 |
|
| 259 | +def load_last_prompt_handler(*args): |
| 260 | + ctrls = list(args) |
| 261 | + path = join(modules.path.temp_outputs_path, 'last.json') |
| 262 | + if exists(path): |
| 263 | + with open(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 | + |
259 | 274 |
|
260 | 275 | def load_input_images_handler(files):
|
261 | 276 | return list(map(lambda x: x.name, files)), gr.update(selected=GALLERY_ID_INPUT), gr.update(value=len(files))
|
@@ -378,6 +393,7 @@ def clear_default_image():
|
378 | 393 | same_seed_for_all = gr.Checkbox(label='Same seed for all images', value=settings['same_seed_for_all'])
|
379 | 394 | image_seed = gr.Textbox(label='Seed', value=settings['seed'], max_lines=1, visible=not settings['seed_random'])
|
380 | 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