Skip to content

Commit b5b57e9

Browse files
committed
refactor: adjust sd api
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent cc3bf55 commit b5b57e9

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

stable-diffusion.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,6 @@ sample_method_t sd_get_default_sample_method(sd_ctx_t* sd_ctx) {
16561656
}
16571657
switch (sd_ctx->sd->version) {
16581658
case VERSION_SD1:
1659-
return IPNDM;
16601659
case VERSION_SD2:
16611660
return EULER_A;
16621661
case VERSION_SDXL:
@@ -1672,13 +1671,33 @@ sample_method_t sd_get_default_sample_method(sd_ctx_t* sd_ctx) {
16721671
}
16731672
}
16741673

1674+
int sd_get_default_sample_steps(sd_ctx_t* sd_ctx) {
1675+
if (sd_ctx == NULL) {
1676+
return 10;
1677+
}
1678+
switch (sd_ctx->sd->version) {
1679+
case VERSION_SD1:
1680+
case VERSION_SD2:
1681+
return 20;
1682+
case VERSION_SDXL:
1683+
case VERSION_SDXL_REFINER:
1684+
case VERSION_SD3_MEDIUM:
1685+
case VERSION_SD3_5_MEDIUM:
1686+
case VERSION_SD3_5_LARGE:
1687+
case VERSION_FLUX_DEV:
1688+
case VERSION_FLUX_SCHNELL:
1689+
return 10;
1690+
default:
1691+
return 10;
1692+
}
1693+
}
1694+
16751695
float sd_get_default_cfg_scale(sd_ctx_t* sd_ctx) {
16761696
if (sd_ctx == NULL) {
16771697
return 1.0f;
16781698
}
16791699
switch (sd_ctx->sd->version) {
16801700
case VERSION_SD1:
1681-
return 7.0f;
16821701
case VERSION_SD2:
16831702
return 9.0f;
16841703
case VERSION_SDXL:

stable-diffusion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ SD_API sd_image_t* img2img(sd_ctx_t* sd_ctx,
185185

186186
SD_API int sd_get_version(sd_ctx_t* sd_ctx);
187187
SD_API sample_method_t sd_get_default_sample_method(sd_ctx_t* sd_ctx);
188+
SD_API int sd_get_default_sample_steps(sd_ctx_t* sd_ctx);
188189
SD_API float sd_get_default_cfg_scale(sd_ctx_t* sd_ctx);
189190

190191
typedef struct upscaler_ctx_t upscaler_ctx_t;

0 commit comments

Comments
 (0)