Stable Diffusion API implementieren #7

Open
opened 2023-09-24 11:46:06 +02:00 by lukas · 0 comments
Owner

Die Stable-Diffusion API ist wie folgt:

Wiki: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API
Request URL: https://gcp-sd.langrock.info/sdapi/v1/txt2img
Payload:

{
  "sd_model_checkpoint": "epicphotogasm-v4.safetensors [797dab5e63]",
  "prompt": "garden, cinematic, lightrays, fantasy",
  "negative_prompt": "",
  "seed": -1,
  "steps": 20,
  "cfg_scale": 7,
  "width": 1280,
  "height": 720
}

Response from API:

{
  "images": [
    "<base64-image>"
  ],
 "parameters": {
    ...
  },
  "info": "..."
}

curl Beispiel

curl -X 'POST' \
  'https://gcp-sd.langrock.info/sdapi/v1/txt2img' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "sd_model_checkpoint": "epicphotogasm-v4.safetensors [797dab5e63]",
  "prompt": "garden, cinematic, lightrays, fantasy",
  "negative_prompt": "",
  "seed": -1,
  "steps": 20,
  "cfg_scale": 7,
  "width": 1280,
  "height": 720
}'

Bild aus der response filtern mit JS Beispiel

response = requests.post(url=f'https://gcp-sd.langrock.info/sdapi/v1/txt2img', json=payload)
for i in r['images']:
    image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))
# Die Stable-Diffusion API ist wie folgt: Wiki: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API Request URL: https://gcp-sd.langrock.info/sdapi/v1/txt2img Payload: ``` json { "sd_model_checkpoint": "epicphotogasm-v4.safetensors [797dab5e63]", "prompt": "garden, cinematic, lightrays, fantasy", "negative_prompt": "", "seed": -1, "steps": 20, "cfg_scale": 7, "width": 1280, "height": 720 } ``` Response from API: ``` json { "images": [ "<base64-image>" ], "parameters": { ... }, "info": "..." } ``` ## curl Beispiel ``` curl -X 'POST' \ 'https://gcp-sd.langrock.info/sdapi/v1/txt2img' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "sd_model_checkpoint": "epicphotogasm-v4.safetensors [797dab5e63]", "prompt": "garden, cinematic, lightrays, fantasy", "negative_prompt": "", "seed": -1, "steps": 20, "cfg_scale": 7, "width": 1280, "height": 720 }' ``` ## Bild aus der response filtern mit JS Beispiel ``` js response = requests.post(url=f'https://gcp-sd.langrock.info/sdapi/v1/txt2img', json=payload) for i in r['images']: image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0]))) ```
lukas self-assigned this 2023-09-24 11:46:06 +02:00
finnf28 was assigned by lukas 2023-09-24 11:46:06 +02:00
leon was assigned by lukas 2023-09-24 11:46:06 +02:00
lukas added this to the Döner macht schöner project 2023-09-24 11:46:06 +02:00
This repo is archived. You cannot comment on issues.
No Milestone
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SpidgetStudios/GOA#7
No description provided.