(context, **kwargs)
| 55 | |
| 56 | |
| 57 | def set_options(context, **kwargs): |
| 58 | changed_opts = {} |
| 59 | |
| 60 | opts_mapping = { |
| 61 | "stream_image_progress": ("live_previews_enable", bool), |
| 62 | "stream_image_progress_interval": ("show_progress_every_n_steps", int), |
| 63 | "clip_skip": ("CLIP_stop_at_last_layers", int), |
| 64 | "clip_skip_sdxl": ("sdxl_clip_l_skip", bool), |
| 65 | "output_format": ("samples_format", str), |
| 66 | } |
| 67 | |
| 68 | for ed_key, webui_key in opts_mapping.items(): |
| 69 | webui_key, webui_type = webui_key |
| 70 | |
| 71 | if ed_key in kwargs and (webui_opts is None or webui_opts.get(webui_key, False) != webui_type(kwargs[ed_key])): |
| 72 | changed_opts[webui_key] = webui_type(kwargs[ed_key]) |
| 73 | |
| 74 | if changed_opts: |
| 75 | changed_opts["sd_model_checkpoint"] = curr_models["stable-diffusion"] |
| 76 | |
| 77 | print(f"Got options: {kwargs}. Sending options: {changed_opts}") |
| 78 | |
| 79 | try: |
| 80 | res = webui_post("/sdapi/v1/options", json=changed_opts) |
| 81 | if res.status_code != 200: |
| 82 | raise Exception(res.text) |
| 83 | |
| 84 | webui_opts.update(changed_opts) |
| 85 | except Exception as e: |
| 86 | print(f"Error setting options: {e}") |
| 87 | |
| 88 | |
| 89 | def ping(timeout=1): |
nothing calls this directly
no test coverage detected