summaryrefslogtreecommitdiff
path: root/stable_diffusion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'stable_diffusion.cpp')
-rw-r--r--stable_diffusion.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/stable_diffusion.cpp b/stable_diffusion.cpp
new file mode 100644
index 0000000..0c42f03
--- /dev/null
+++ b/stable_diffusion.cpp
@@ -0,0 +1,28 @@
+
+static void
+SD_Txt2Txt(sd_state *SD)
+{
+ char JSONPayload[1024];
+ char CurlCommand[1024];
+ char *Test[] = { "prompt", "negative_prompt", "steps", "width", "height", "cfg_scale" };
+ void *Test2[6] = { (void *)SD->Prompt, (void *)SD->NegPrompt,
+ (void *)&SD->Steps, (void *)&SD->Width,
+ (void *)&SD->Height, (void *)&SD->CFG };
+ int Type[6] = { 0, 0, 1, 1, 1, 2};
+ sprintf(JSONPayload, "%s{\n", JSONPayload);
+ for (int i = 0; i < 6; i++) {
+ if (Type[i] == 0) {
+ sprintf(JSONPayload, "%s\"%s\": \"%s\",\n", JSONPayload, Test[i], (char *)Test2[i]);
+ } else if (Type[i] == 1) {
+ sprintf(JSONPayload, "%s\"%s\": %i,\n", JSONPayload, Test[i], *(int *)Test2[i]);
+ } else if (Type[i] == 2) {
+ sprintf(JSONPayload, "%s\"%s\": %.2f,\n", JSONPayload, Test[i], *(real32 *)Test2[i]);
+ } else {
+ Assert(0);
+ }
+ }
+ sprintf(JSONPayload, "%s}\n", JSONPayload);
+ sprintf(CurlCommand, "curl -X POST -H 'Content-Type: application/json' -i '%s/sdapi/v1/txt2img' --data '%s'",
+ SD->ServerAddress, JSONPayload);
+ printf("%s\n", CurlCommand);
+};