Skip to content

[Feature Request][API]: I would like to easily change the checkpoint from the API #3703

Description

@siriux

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What would your feature do ?

I would like to be able to get a list of the available checkpoints from the API, and then change the current checkpoint also from the API in a simple and clear way more inline with the new /sdapi/v1/txt2img and /sdapi/v1/img2img APIs.

Currently this is possible by copying the same request the interface does (using /api/predict/) but the parameters to provide are not simple or clear.

This is an example:

{"data":[{"value":"sd-v1-5.ckpt [81761151]","__type__":"update"},"{\"samples_save\": false, \"samples_format\": \"png\", \"samples_filename_pattern\": \"\", \"save_images_add_number\": true, \"grid_save\": false, \"grid_format\": \"png\", \"grid_extended_filename\": false, \"grid_only_if_multiple\": false, \"grid_prevent_empty_spots\": false, \"n_rows\": -1, \"enable_pnginfo\": true, \"save_txt\": true, \"save_images_before_face_restoration\": true, \"jpeg_quality\": 80, \"export_for_4chan\": false, \"use_original_name_batch\": false, \"save_selected_only\": true, \"do_not_add_watermark\": true, \"outdir_samples\": \"outputs/\", \"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\": \"outputs/\", \"save_to_dirs\": false, \"grid_save_to_dirs\": false, \"use_save_to_dirs_for_ui\": false, \"directories_filename_pattern\": \"\", \"directories_max_prompt_words\": 8, \"ESRGAN_tile\": 192, \"ESRGAN_tile_overlap\": 8, \"realesrgan_enabled_models\": [\"R-ESRGAN x4+\", \"R-ESRGAN x4+ Anime6B\"], \"SWIN_tile\": 192, \"SWIN_tile_overlap\": 8, \"ldsr_steps\": 100, \"upscaler_for_img2img\": null, \"use_scale_latent_for_hires_fix\": false, \"face_restoration_model\": \"CodeFormer\", \"code_former_weight\": 0.5, \"face_restoration_unload\": false, \"memmon_poll_rate\": 8, \"samples_log_stdout\": false, \"multiple_tqdm\": true, \"unload_models_when_training\": false, \"dataset_filename_word_regex\": \"\", \"dataset_filename_join_string\": \" \", \"training_image_repeats_per_epoch\": 1, \"training_write_csv_every\": 500.0, \"sd_model_checkpoint\": \"sd-v1-5.ckpt [81761151]\", \"sd_checkpoint_cache\": 0, \"sd_hypernetwork\": \"None\", \"sd_hypernetwork_strength\": 1, \"img2img_color_correction\": false, \"save_images_before_color_correction\": false, \"img2img_fix_steps\": false, \"enable_quantization\": false, \"enable_emphasis\": true, \"use_old_emphasis_implementation\": false, \"enable_batch_seeds\": true, \"comma_padding_backtrack\": 20, \"filter_nsfw\": false, \"CLIP_stop_at_last_layers\": 1, \"random_artist_categories\": [], \"interrogate_keep_models_in_memory\": false, \"interrogate_use_builtin_artists\": true, \"interrogate_return_ranks\": false, \"interrogate_clip_num_beams\": 1, \"interrogate_clip_min_length\": 24, \"interrogate_clip_max_length\": 48, \"interrogate_clip_dict_limit\": 1500.0, \"interrogate_deepbooru_score_threshold\": 0.5, \"deepbooru_sort_alpha\": true, \"deepbooru_use_spaces\": false, \"deepbooru_escape\": true, \"show_progressbar\": true, \"show_progress_every_n_steps\": 10, \"show_progress_grid\": true, \"return_grid\": true, \"do_not_show_images\": false, \"add_model_hash_to_info\": true, \"add_model_name_to_info\": false, \"disable_weights_auto_swap\": false, \"font\": \"\", \"js_modal_lightbox\": true, \"js_modal_lightbox_initially_zoomed\": true, \"show_progress_in_title\": true, \"quicksettings\": \"sd_model_checkpoint\", \"localization\": \"None\", \"hide_samplers\": [], \"eta_ddim\": 0, \"eta_ancestral\": 1, \"ddim_discretize\": \"uniform\", \"s_churn\": 0, \"s_tmin\": 0, \"s_noise\": 1, \"eta_noise_seed_delta\": 0}"],"is_generating":false,"duration":0.003006458282470703,"average_duration":0.003006458282470703}

Proposed workflow

  1. Use the GET method /sdapi/v1/availablecheckpoints to get the list of available checkpoints
  2. Use the POST method /sdapi/v1/checkpoint to set the current checkpoint

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions