GuizzyQC / sd_api_pictures_tag_injection

Based on @Brawlence's extension
24 stars 6 forks source link

KeyError: 'sd_model_checkpoint' #5

Closed SoftwareLogico closed 1 year ago

SoftwareLogico commented 1 year ago

it seems the api changed recently the same error happens with the vanilla one.

i just install today because I formatted my PC so I guess the new version of auto1111 is the issue.

Traceback (most recent call last): File "/venv/lib/python3.10/site-packages/gradio/routes.py", line 427, in run_predict output = await app.get_blocks().process_api( File "/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1323, in process_api result = await self.call_function( File "/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1051, in call_function prediction = await anyio.to_thread.run_sync( File "/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, *args) File "/src/extensions/sd_api_pictures_tag_injection/script.py", line 521, in get_checkpoints params['sd_checkpoint'] = options_json['sd_model_checkpoint'] KeyError: 'sd_model_checkpoint'

here's the json

{ "samples_save": true, "samples_format": "png", "samples_filename_pattern": "", "save_images_add_number": true, "grid_save": true, "grid_format": "png", "grid_extended_filename": false, "grid_only_if_multiple": true, "grid_prevent_empty_spots": false, "grid_zip_filename_pattern": "", "n_rows": -1.0, "font": "", "grid_text_active_color": "#000000", "grid_text_inactive_color": "#999999", "grid_background_color": "#ffffff", "enable_pnginfo": true, "save_txt": false, "save_images_before_face_restoration": false, "save_images_before_highres_fix": false, "save_images_before_color_correction": false, "save_mask": false, "save_mask_composite": false, "jpeg_quality": 80.0, "webp_lossless": false, "export_for_4chan": true, "img_downscale_threshold": 4.0, "target_side_length": 4000.0, "img_max_size_mp": 200.0, "use_original_name_batch": true, "use_upscaler_name_as_suffix": false, "save_selected_only": true, "save_init_img": false, "temp_dir": "", "clean_temp_dir_at_start": false, "outdir_samples": "", "outdir_txt2img_samples": "outputs/txt2img-images", "outdir_img2img_samples": "outputs/img2img-images", "outdir_extras_samples": "outputs/extras-images", "outdir_grids": "", "outdir_txt2img_grids": "outputs/txt2img-grids", "outdir_img2img_grids": "outputs/img2img-grids", "outdir_save": "log/images", "outdir_init_images": "outputs/init-images", "save_to_dirs": true, "grid_save_to_dirs": true, "use_save_to_dirs_for_ui": false, "directories_filename_pattern": "[date]", "directories_max_prompt_words": 8.0, "ESRGAN_tile": 192.0, "ESRGAN_tile_overlap": 8.0, "realesrgan_enabled_models": [ "R-ESRGAN 4x+", "R-ESRGAN 4x+ Anime6B" ], "face_restoration_model": "CodeFormer", "code_former_weight": 0.5, "face_restoration_unload": false, "show_warnings": false, "memmon_poll_rate": 8.0, "samples_log_stdout": false, "multiple_tqdm": true, "print_hypernet_extra": false, "list_hidden_files": true, "disable_mmap_load_safetensors": false, "unload_models_when_training": false, "pin_memory": false, "save_optimizer_state": false, "save_training_settings_to_txt": true, "dataset_filename_word_regex": "", "dataset_filename_join_string": " ", "training_image_repeats_per_epoch": 1.0, "training_write_csv_every": 500.0, "training_xattention_optimizations": false, "training_enable_tensorboard": false, "training_tensorboard_save_images": false, "training_tensorboard_flush_every": 120.0, "sd_checkpoint_cache": 0.0, "sd_vae_checkpoint_cache": 0.0, "sd_vae": "Automatic", "sd_vae_as_default": true, "sd_unet": "Automatic", "inpainting_mask_weight": 1.0, "initial_noise_multiplier": 1.0, "img2img_color_correction": false, "img2img_fix_steps": false, "img2img_background_color": "#ffffff", "enable_quantization": false, "enable_emphasis": true, "enable_batch_seeds": true, "comma_padding_backtrack": 20.0, "CLIP_stop_at_last_layers": 1.0, "upcast_attn": false, "auto_vae_precision": true, "randn_source": "GPU", "sdxl_crop_top": 0.0, "sdxl_crop_left": 0.0, "sdxl_refiner_low_aesthetic_score": 2.5, "sdxl_refiner_high_aesthetic_score": 6.0, "cross_attention_optimization": "Automatic", "s_min_uncond": 0.0, "token_merging_ratio": 0.0, "token_merging_ratio_img2img": 0.0, "token_merging_ratio_hr": 0.0, "pad_cond_uncond": false, "experimental_persistent_cond_cache": false, "use_old_emphasis_implementation": false, "use_old_karras_scheduler_sigmas": false, "no_dpmpp_sde_batch_determinism": false, "use_old_hires_fix_width_height": false, "dont_fix_second_order_samplers_schedule": false, "hires_fix_use_firstpass_conds": false, "interrogate_keep_models_in_memory": false, "interrogate_return_ranks": false, "interrogate_clip_num_beams": 1.0, "interrogate_clip_min_length": 24.0, "interrogate_clip_max_length": 48.0, "interrogate_clip_dict_limit": 1500.0, "interrogate_clip_skip_categories": [], "interrogate_deepbooru_score_threshold": 0.5, "deepbooru_sort_alpha": true, "deepbooru_use_spaces": true, "deepbooru_escape": true, "deepbooru_filter_tags": "", "extra_networks_show_hidden_directories": true, "extra_networks_hidden_models": "When searched", "extra_networks_default_multiplier": 1.0, "extra_networks_card_width": 0.0, "extra_networks_card_height": 0.0, "extra_networks_card_text_scale": 1.0, "extra_networks_card_show_desc": true, "extra_networks_add_text_separator": " ", "ui_extra_networks_tab_reorder": "", "textual_inversion_print_at_load": false, "textual_inversion_add_hashes_to_infotext": true, "sd_hypernetwork": "None", "localization": "None", "gradio_theme": "Default", "img2img_editor_height": 720.0, "return_grid": true, "return_mask": false, "return_mask_composite": false, "do_not_show_images": false, "send_seed": true, "send_size": true, "js_modal_lightbox": true, "js_modal_lightbox_initially_zoomed": true, "js_modal_lightbox_gamepad": false, "js_modal_lightbox_gamepad_repeat": 250.0, "show_progress_in_title": true, "samplers_in_dropdown": true, "dimensions_and_batch_together": true, "keyedit_precision_attention": 0.1, "keyedit_precision_extra": 0.05, "keyedit_delimiters": ".,\/!?%^*;:{}=`~()", "keyedit_move": true, "quicksettings_list": [ "sd_model_checkpoint" ], "ui_tab_order": [], "hidden_tabs": [], "ui_reorder_list": [], "hires_fix_show_sampler": false, "hires_fix_show_prompts": false, "disable_token_counters": false, "add_model_hash_to_info": true, "add_model_name_to_info": true, "add_user_name_to_info": false, "add_version_to_infotext": true, "disable_weights_auto_swap": true, "infotext_styles": "Apply if any", "show_progressbar": true, "live_previews_enable": false, "live_previews_image_format": "png", "show_progress_grid": true, "show_progress_every_n_steps": 10.0, "show_progress_type": "Approx NN", "live_preview_content": "Prompt", "live_preview_refresh_period": 1000.0, "hide_samplers": [], "eta_ddim": 0.0, "eta_ancestral": 1.0, "ddim_discretize": "uniform", "s_churn": 0.0, "s_tmin": 0.0, "s_noise": 1.0, "k_sched_type": "Automatic", "sigma_min": 0.0, "sigma_max": 0.0, "rho": 0.0, "eta_noise_seed_delta": 0.0, "always_discard_next_to_last_sigma": false, "uni_pc_variant": "bh1", "uni_pc_skip_type": "time_uniform", "uni_pc_order": 3.0, "uni_pc_lower_order_final": true, "postprocessing_enable_in_main_ui": [], "postprocessing_operation_order": [], "upscaling_max_images_in_cache": 5.0, "disabled_extensions": [ "sd-model-downloader", "sd-model-preview-xd" ], "disable_all_extensions": "none", "restore_config_state_file": "", "sd_checkpoint_hash": "1868ab268917e815a27d89f4dcc6ff1b6f894a8194a8f28c6b78f0d3b6a31e42" }

GuizzyQC commented 1 year ago

it seems the api changed recently the same error happens with the vanilla one.

i just install today because I formatted my PC so I guess the new version of auto1111 is the issue.

Yes, I've had this issue too. Auto1111 has merged a fix into dev but he tends to push to main branch by releases, so it might take a little while before it makes it there. The fix is there: https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/deed8439d5979714c2d49d8a8bb45e9940fdf81a and I have confirmed it works. Until it's merged to main, you can apply the fix yourself by changing a couple of lines (or pulling the dev branch).

SoftwareLogico commented 1 year ago

it seems the api changed recently the same error happens with the vanilla one. i just install today because I formatted my PC so I guess the new version of auto1111 is the issue.

Yes, I've had this issue too. Auto1111 has merged a fix into dev but he tends to push to main branch by releases, so it might take a little while before it makes it there. The fix is there: AUTOMATIC1111/stable-diffusion-webui@deed843 and I have confirmed it works. Until it's merged to main, you can apply the fix yourself by changing a couple of lines (or pulling the dev branch).

I just fixed it like this

`ef get_checkpoints(): global params

try:
    model_url = f'{params["address"]}/sdapi/v1/sd-models'
    models = requests.get(url=model_url)
    options_url = f'{params["address"]}/sdapi/v1/options'
    options = requests.get(url=options_url)
    options_json = options.json()

    if 'sd_model_checkpoint' in options_json:
        params['sd_checkpoint'] = options_json['sd_model_checkpoint']
    else:
        params['sd_checkpoint'] = "Select Value" # Or whatever default value you choose

    params['checkpoint_list'] = [result["title"] for result in models.json()]
except Exception as e:
    print("Error:", e)
    params['sd_checkpoint'] = ""
    params['checkpoint_list'] = []

return gr.update(choices=params['checkpoint_list'], value=params['sd_checkpoint'])`

and it worked but you have to select the model

GuizzyQC commented 1 year ago

Well, I guess I shouldn't doubt Auto1111. He merged the fix overnight, must not have been more than minutes than after I said it might take a while: https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/68f336bd994bed5442ad95bad6b6ad5564a5409a