mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
add /sdapi/v1/controlnets api endpoint
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user