add /sdapi/v1/controlnets api endpoint

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-06-25 15:54:43 -04:00
parent 3a1d98c472
commit f8977d2f01
4 changed files with 23 additions and 0 deletions
+1
View File
@@ -18,6 +18,7 @@
- **API**
- Add `/sdapi/v1/lora?lora=<lora_name>` endpoint that returns full lora info and metadata
- Add `/sdapi/v1/controlnets?model_type=<model_type|all|None>` endpoints that returns list of available controlnets for specific model type
- **Fixes**
- IPEX with DPM2++ FlowMatch samplers
+1
View File
@@ -78,6 +78,7 @@ class Api:
self.add_api_route("/sdapi/v1/samplers", endpoints.get_samplers, methods=["GET"], response_model=List[models.ItemSampler])
self.add_api_route("/sdapi/v1/upscalers", endpoints.get_upscalers, methods=["GET"], response_model=List[models.ItemUpscaler])
self.add_api_route("/sdapi/v1/sd-models", endpoints.get_sd_models, methods=["GET"], response_model=List[models.ItemModel])
self.add_api_route("/sdapi/v1/controlnets", endpoints.get_controlnets, methods=["GET"], response_model=List[str])
self.add_api_route("/sdapi/v1/hypernetworks", endpoints.get_hypernetworks, methods=["GET"], response_model=List[models.ItemHypernetwork])
self.add_api_route("/sdapi/v1/face-restorers", endpoints.get_detailers, methods=["GET"], response_model=List[models.ItemDetailer])
self.add_api_route("/sdapi/v1/prompt-styles", endpoints.get_prompt_styles, methods=["GET"], response_model=List[models.ItemStyle])
+4
View File
@@ -23,6 +23,10 @@ def get_sd_models():
checkpoints.append({"title": v.title, "model_name": v.name, "filename": v.filename, "type": v.type, "hash": v.shorthash, "sha256": v.sha256, "config": sd_models_config.find_checkpoint_config_near_filename(v)})
return checkpoints
def get_controlnets(model_type: Optional[str] = None):
from modules.control.units.controlnet import api_list_models
return api_list_models()
def get_hypernetworks():
return [{"name": name, "path": shared.hypernetworks[name]} for name in shared.hypernetworks]
+17
View File
@@ -137,6 +137,23 @@ def find_models():
find_models()
def api_list_models(model_type: str = None):
import modules.shared
model_type = model_type or modules.shared.sd_model_type
model_list = []
if model_type == 'sd' or model_type == 'all':
model_list += list(predefined_sd15)
if model_type == 'sdxl' or model_type == 'all':
model_list += list(predefined_sdxl)
if model_type == 'f1' or model_type == 'all':
model_list += list(predefined_f1)
if model_type == 'sd3' or model_type == 'all':
model_list += list(predefined_sd3)
model_list += sorted(find_models())
return model_list
def list_models(refresh=False):
import modules.shared
global models # pylint: disable=global-statement