2024年4月14日
目次
Stable Diffusion web UI は、
“python launch.py –api”とコマンドオプションをつけて起動すると、
APIモードを使用することができまふ。
このAPIモードは、FastAPIで構築されておりまふ。
(ちなみに普段のWeb UI モードは、Gradio で構築されておりまふ。)
APIモードのルーティングとリクエスト・レスポンスをまとめてみまふた(‘◇’)
Request Method | POST |
Request Body | { “enable_hr”: false, “denoising_strength”: 0, “firstphase_width”: 0, “firstphase_height”: 0, “hr_scale”: 2, “hr_upscaler”: “string”, “hr_second_pass_steps”: 0, “hr_resize_x”: 0, “hr_resize_y”: 0, “prompt”: “”, “styles”: [ “string” ], “seed”: -1, “subseed”: -1, “subseed_strength”: 0, “seed_resize_from_h”: -1, “seed_resize_from_w”: -1, “sampler_name”: “string”, “batch_size”: 1, “n_iter”: 1, “steps”: 50, “cfg_scale”: 7, “width”: 512, “height”: 512, “restore_faces”: false, “tiling”: false, “negative_prompt”: “string”, “eta”: 0, “s_churn”: 0, “s_tmax”: 0, “s_tmin”: 0, “s_noise”: 1, “override_settings”: {}, “override_settings_restore_afterwards”: true, “script_args”: [], “sampler_index”: “Euler”, “script_name”: “string” } |
Responses Code 200 | { “images”: [ “string” ], “parameters”: {}, “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | { “init_images”: [ “string” ], “resize_mode”: 0, “denoising_strength”: 0.75, “image_cfg_scale”: 0, “mask”: “string”, “mask_blur”: 4, “inpainting_fill”: 0, “inpaint_full_res”: true, “inpaint_full_res_padding”: 0, “inpainting_mask_invert”: 0, “initial_noise_multiplier”: 0, “prompt”: “”, “styles”: [ “string” ], “seed”: -1, “subseed”: -1, “subseed_strength”: 0, “seed_resize_from_h”: -1, “seed_resize_from_w”: -1, “sampler_name”: “string”, “batch_size”: 1, “n_iter”: 1, “steps”: 50, “cfg_scale”: 7, “width”: 512, “height”: 512, “restore_faces”: false, “tiling”: false, “negative_prompt”: “string”, “eta”: 0, “s_churn”: 0, “s_tmax”: 0, “s_tmin”: 0, “s_noise”: 1, “override_settings”: {}, “override_settings_restore_afterwards”: true, “script_args”: [], “sampler_index”: “Euler”, “include_init_images”: false, “script_name”: “string” } |
Responses Code 200 | { “images”: [ “string” ], “parameters”: {}, “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | { “resize_mode”: 0, “show_extras_results”: true, “gfpgan_visibility”: 0, “codeformer_visibility”: 0, “codeformer_weight”: 0, “upscaling_resize”: 2, “upscaling_resize_w”: 512, “upscaling_resize_h”: 512, “upscaling_crop”: true, “upscaler_1”: “None”, “upscaler_2”: “None”, “extras_upscaler_2_visibility”: 0, “upscale_first”: false, “image”: “” } |
Responses Code 200 | { “html_info”: “string”, “image”: “string” } |
{ “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | “resize_mode”: 0, “show_extras_results”: true, “gfpgan_visibility”: 0, “codeformer_visibility”: 0, “codeformer_weight”: 0, “upscaling_resize”: 2, “upscaling_resize_w”: 512, “upscaling_resize_h”: 512, “upscaling_crop”: true, “upscaler_1”: “None”, “upscaler_2”: “None”, “extras_upscaler_2_visibility”: 0, “upscale_first”: false, “imageList”: [ { “data”: “string”, “name”: “string” } ] } |
Responses Code 200 | { “html_info”: “string”, “images”: [ “string” ] } |
{ “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | { “image”: “string” } |
Responses Code 200 | { “info”: “string”, “items”: {} } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | GET |
Responses Code 200 | { “progress”: 0, “eta_relative”: 0, “state”: {}, “current_image”: “string”, “textinfo”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | { “image”: “”, “model”: “clip” } |
Responses Code 200 | “string” |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Responses Code 200 | “string” |
Request Method | POST |
Responses Code 200 | “string” |
Request Method | GET |
Responses Code 200 | { “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, “n_rows”: -1, “enable_pnginfo”: true, “save_txt”: false, “save_images_before_face_restoration”: false, “save_images_before_highres_fix”: false, “save_images_before_color_correction”: false, “jpeg_quality”: 80, “export_for_4chan”: true, “img_downscale_threshold”: 4, “target_side_length”: 4000, “use_original_name_batch”: true, “use_upscaler_name_as_suffix”: false, “save_selected_only”: true, “do_not_add_watermark”: 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”, “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, “ESRGAN_tile”: 192, “ESRGAN_tile_overlap”: 8, “realesrgan_enabled_models”: [ “R-ESRGAN 4x+”, “R-ESRGAN 4x+ Anime6B” ], “upscaler_for_img2img”: “Unknown Type: null”, “face_restoration_model”: “CodeFormer”, “code_former_weight”: 0.5, “face_restoration_unload”: false, “show_warnings”: false, “memmon_poll_rate”: 8, “samples_log_stdout”: false, “multiple_tqdm”: true, “print_hypernet_extra”: 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, “training_write_csv_every”: 500, “training_xattention_optimizations”: false, “training_enable_tensorboard”: false, “training_tensorboard_save_images”: false, “training_tensorboard_flush_every”: 120, “sd_model_checkpoint”: “string”, “sd_checkpoint_cache”: 0, “sd_vae_checkpoint_cache”: 0, “sd_vae”: “Automatic”, “sd_vae_as_default”: true, “inpainting_mask_weight”: 1, “initial_noise_multiplier”: 1, “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, “CLIP_stop_at_last_layers”: 1, “upcast_attn”: 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, “interrogate_keep_models_in_memory”: false, “interrogate_return_ranks”: false, “interrogate_clip_num_beams”: 1, “interrogate_clip_min_length”: 24, “interrogate_clip_max_length”: 48, “interrogate_clip_dict_limit”: 1500, “interrogate_clip_skip_categories”: [], “interrogate_deepbooru_score_threshold”: 0.5, “deepbooru_sort_alpha”: true, “deepbooru_use_spaces”: false, “deepbooru_escape”: true, “deepbooru_filter_tags”: “”, “extra_networks_default_view”: “cards”, “extra_networks_default_multiplier”: 1, “sd_hypernetwork”: “None”, “return_grid”: true, “do_not_show_images”: false, “add_model_hash_to_info”: true, “add_model_name_to_info”: true, “disable_weights_auto_swap”: true, “send_seed”: true, “send_size”: true, “font”: “”, “js_modal_lightbox”: true, “js_modal_lightbox_initially_zoomed”: true, “show_progress_in_title”: true, “samplers_in_dropdown”: true, “dimensions_and_batch_together”: true, “keyedit_precision_attention”: 0.1, “keyedit_precision_extra”: 0.05, “quicksettings”: “sd_model_checkpoint”, “ui_reorder”: “inpaint, sampler, checkboxes, hires_fix, dimensions, cfg, seed, batch, override_settings, scripts”, “ui_extra_networks_tab_reorder”: “”, “localization”: “None”, “show_progressbar”: true, “live_previews_enable”: true, “show_progress_grid”: true, “show_progress_every_n_steps”: 10, “show_progress_type”: “Approx NN”, “live_preview_content”: “Prompt”, “live_preview_refresh_period”: 1000, “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, “always_discard_next_to_last_sigma”: false, “postprocessing_enable_in_main_ui”: [], “postprocessing_operation_order”: [], “upscaling_max_images_in_cache”: 5, “disabled_extensions”: [], “sd_checkpoint_hash”: “”, “sd_lora”: “None”, “lora_apply_to_outputs”: false } |
Request Method | POST |
Request Body | {} |
Responses Code 200 | “string” |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | GET |
Request Body | |
Responses Code 200 | { “data_dir”: “D:\projects-d\stable-diffusion-webui”, “config”: “D:\projects-d\stable-diffusion-webui\configs\v1-inference.yaml”, “ckpt”: “D:\projects-d\stable-diffusion-webui\model.ckpt”, “ckpt_dir”: “string”, “vae_dir”: “string”, “gfpgan_dir”: “./GFPGAN”, “gfpgan_model”: “string”, “no_half”: false, “no_half_vae”: false, “no_progressbar_hiding”: false, “max_batch_count”: 16, “embeddings_dir”: “D:\projects-d\stable-diffusion-webui\embeddings”, “textual_inversion_templates_dir”: “D:\projects-d\stable-diffusion-webui\textual_inversion_templates”, “hypernetwork_dir”: “D:\projects-d\stable-diffusion-webui\models\hypernetworks”, “localizations_dir”: “D:\projects-d\stable-diffusion-webui\localizations”, “allow_code”: false, “medvram”: false, “lowvram”: false, “lowram”: false, “always_batch_cond_uncond”: false, “unload_gfpgan”: false, “precision”: “autocast”, “upcast_sampling”: false, “share”: false, “ngrok”: “string”, “ngrok_region”: “us”, “enable_insecure_extension_access”: false, “codeformer_models_path”: “D:\projects-d\stable-diffusion-webui\models\Codeformer”, “gfpgan_models_path”: “D:\projects-d\stable-diffusion-webui\models\GFPGAN”, “esrgan_models_path”: “D:\projects-d\stable-diffusion-webui\models\ESRGAN”, “bsrgan_models_path”: “D:\projects-d\stable-diffusion-webui\models\BSRGAN”, “realesrgan_models_path”: “D:\projects-d\stable-diffusion-webui\models\RealESRGAN”, “clip_models_path”: “string”, “xformers”: false, “force_enable_xformers”: false, “xformers_flash_attention”: false, “deepdanbooru”: false, “opt_split_attention”: false, “opt_sub_quad_attention”: false, “sub_quad_q_chunk_size”: 1024, “sub_quad_kv_chunk_size”: “string”, “sub_quad_chunk_threshold”: “string”, “opt_split_attention_invokeai”: false, “opt_split_attention_v1”: false, “disable_opt_split_attention”: false, “disable_nan_check”: false, “use_cpu”: [], “listen”: false, “port”: “string”, “show_negative_prompt”: false, “ui_config_file”: “D:\projects-d\stable-diffusion-webui\ui-config.json”, “hide_ui_dir_config”: false, “freeze_settings”: false, “ui_settings_file”: “D:\projects-d\stable-diffusion-webui\config.json”, “gradio_debug”: false, “gradio_auth”: “string”, “gradio_auth_path”: “string”, “gradio_img2img_tool”: “string”, “gradio_inpaint_tool”: “string”, “opt_channelslast”: false, “styles_file”: “D:\projects-d\stable-diffusion-webui\styles.csv”, “autolaunch”: false, “theme”: “string”, “use_textbox_seed”: false, “disable_console_progressbars”: false, “enable_console_prompts”: false, “vae_path”: “string”, “disable_safe_unpickle”: false, “api”: false, “api_auth”: “string”, “api_log”: false, “nowebui”: false, “ui_debug_mode”: false, “device_id”: “string”, “administrator”: false, “cors_allow_origins”: “string”, “cors_allow_origins_regex”: “string”, “tls_keyfile”: “string”, “tls_certfile”: “string”, “server_name”: “string”, “gradio_queue”: false, “skip_version_check”: false, “no_hashing”: false, “no_download_sd_model”: false, “controlnet_dir”: “string”, “no_half_controlnet”: “string”, “ldsr_models_path”: “D:\projects-d\stable-diffusion-webui\models\LDSR”, “lora_dir”: “D:\projects-d\stable-diffusion-webui\models\Lora”, “scunet_models_path”: “D:\projects-d\stable-diffusion-webui\models\ScuNET”, “swinir_models_path”: “D:\projects-d\stable-diffusion-webui\models\SwinIR” } |
Request Method | GET |
Responses Code 200 | [ { “name”: “string”, “aliases”: [ “string” ], “options”: { “additionalProp1”: “string”, “additionalProp2”: “string”, “additionalProp3”: “string” } } ] |
Request Method | GET |
Responses Code 200 | [ { “name”: “string”, “model_name”: “string”, “model_path”: “string”, “model_url”: “string”, “scale”: 0 } ] |
Request Method | GET |
Responses Code 200 | [ { “title”: “string”, “model_name”: “string”, “hash”: “string”, “sha256”: “string”, “filename”: “string”, “config”: “string” } ] |
Request Method | GET |
Responses Code 200 | [ { “name”: “string”, “path”: “string” } ] |
Request Method | GET |
Responses Code 200 | [ { “name”: “string”, “cmd_dir”: “string” } ] |
Request Method | GET |
Responses Code 200 | [ { “name”: “string”, “path”: “string”, “scale”: 0 } ] |
Request Method | GET |
Responses Code 200 | [ { “name”: “string”, “prompt”: “string”, “negative_prompt”: “string” } ] |
Request Method | GET |
Responses Code 200 | { “loaded”: { “additionalProp1”: { “step”: 0, “sd_checkpoint”: “string”, “sd_checkpoint_name”: “string”, “shape”: 0, “vectors”: 0 }, “additionalProp2”: { “step”: 0, “sd_checkpoint”: “string”, “sd_checkpoint_name”: “string”, “shape”: 0, “vectors”: 0 }, “additionalProp3”: { “step”: 0, “sd_checkpoint”: “string”, “sd_checkpoint_name”: “string”, “shape”: 0, “vectors”: 0 } }, “skipped”: { “additionalProp1”: { “step”: 0, “sd_checkpoint”: “string”, “sd_checkpoint_name”: “string”, “shape”: 0, “vectors”: 0 }, “additionalProp2”: { “step”: 0, “sd_checkpoint”: “string”, “sd_checkpoint_name”: “string”, “shape”: 0, “vectors”: 0 }, “additionalProp3”: { “step”: 0, “sd_checkpoint”: “string”, “sd_checkpoint_name”: “string”, “shape”: 0, “vectors”: 0 } } } |
Request Method | POST |
Responses Code 200 | “string” |
Request Method | POST |
Request Body | {} |
Responses Code 200 | { “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | {} |
Responses Code 200 | { “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | {} |
Responses Code 200 | { “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | {} |
Responses Code 200 | { “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | {} |
Responses Code 200 | { “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | GET |
Responses Code 200 | { “ram”: {}, “cuda”: {} } |
Request Method | POST |
Request Body | { “enable_hr”: false, “denoising_strength”: 0, “firstphase_width”: 0, “firstphase_height”: 0, “hr_scale”: 2, “hr_upscaler”: “string”, “hr_second_pass_steps”: 0, “hr_resize_x”: 0, “hr_resize_y”: 0, “prompt”: “”, “styles”: [ “string” ], “seed”: -1, “subseed”: -1, “subseed_strength”: 0, “seed_resize_from_h”: -1, “seed_resize_from_w”: -1, “sampler_name”: “string”, “batch_size”: 1, “n_iter”: 1, “steps”: 50, “cfg_scale”: 7, “width”: 512, “height”: 512, “restore_faces”: false, “tiling”: false, “negative_prompt”: “string”, “eta”: 0, “s_churn”: 0, “s_tmax”: 0, “s_tmin”: 0, “s_noise”: 1, “override_settings”: {}, “override_settings_restore_afterwards”: true, “script_args”: [], “sampler_index”: “Euler”, “script_name”: “string”, “controlnet_units”: [ { “input_image”: “”, “mask”: “”, “module”: “none”, “model”: “None”, “weight”: 1, “resize_mode”: “Scale to Fit (Inner Fit)”, “lowvram”: false, “processor_res”: 64, “threshold_a”: 64, “threshold_b”: 64, “guidance”: 1, “guidance_start”: 0, “guidance_end”: 1, “guessmode”: true } ] } |
Responses Code 200 | { “images”: [ “string” ], “parameters”: {}, “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | POST |
Request Body | { “init_images”: [ “string” ], “resize_mode”: 0, “denoising_strength”: 0.75, “image_cfg_scale”: 0, “mask”: “string”, “mask_blur”: 4, “inpainting_fill”: 0, “inpaint_full_res”: true, “inpaint_full_res_padding”: 0, “inpainting_mask_invert”: 0, “initial_noise_multiplier”: 0, “prompt”: “”, “styles”: [ “string” ], “seed”: -1, “subseed”: -1, “subseed_strength”: 0, “seed_resize_from_h”: -1, “seed_resize_from_w”: -1, “sampler_name”: “string”, “batch_size”: 1, “n_iter”: 1, “steps”: 50, “cfg_scale”: 7, “width”: 512, “height”: 512, “restore_faces”: false, “tiling”: false, “negative_prompt”: “string”, “eta”: 0, “s_churn”: 0, “s_tmax”: 0, “s_tmin”: 0, “s_noise”: 1, “override_settings”: {}, “override_settings_restore_afterwards”: true, “script_args”: [], “sampler_index”: “Euler”, “include_init_images”: false, “script_name”: “string”, “controlnet_units”: [ { “input_image”: “”, “mask”: “”, “module”: “none”, “model”: “None”, “weight”: 1, “resize_mode”: “Scale to Fit (Inner Fit)”, “lowvram”: false, “processor_res”: 64, “threshold_a”: 64, “threshold_b”: 64, “guidance”: 1, “guidance_start”: 0, “guidance_end”: 1, “guessmode”: true } ] } |
Responses Code 200 | { “images”: [ “string” ], “parameters”: {}, “info”: “string” } |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
Request Method | GET |
Responses Code 200 | “string” |
Request Method | GET |
Responses Code 200 | “string” |
Request Method | POST |
Request Body | { “controlnet_module”: “None”, “controlnet_input_images”: [], “controlnet_processor_res”: 512, “controlnet_threshold_a”: 64, “controlnet_threshold_b”: 64 } |
Responses Code 200 | “string” |
Responses Code 422 | { “detail”: [ { “loc”: [ “string”, 0 ], “msg”: “string”, “type”: “string” } ] } |
APIモードにすれば、フロントエンドをVue.jsやReactで開発することができまふ、
おいらは、Nuxt3を用いて遊んでまふ(‘ω’)ノ