Prediction
stability-ai/stable-diffusion:f178fa7a1ae43a9a9af01b833b9d2ecf97b1bcb0acfd2dc5dd04895e042863f1Input
- width
- "512"
- height
- "512"
- prompt
- astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed
- scheduler
- K_EULER
- num_outputs
- "4"
- guidance_scale
- 7.5
- prompt_strength
- 0.8
- num_inference_steps
- 50
{
"width": "512",
"height": "512",
"prompt": "astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed",
"scheduler": "K_EULER",
"num_outputs": "4",
"guidance_scale": 7.5,
"prompt_strength": 0.8,
"num_inference_steps": 50
}
npm install replicate
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run stability-ai/stable-diffusion using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"stability-ai/stable-diffusion:f178fa7a1ae43a9a9af01b833b9d2ecf97b1bcb0acfd2dc5dd04895e042863f1",
{
input: {
width: "512",
height: "512",
prompt: "astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed",
scheduler: "K_EULER",
num_outputs: "4",
guidance_scale: 7.5,
prompt_strength: 0.8,
num_inference_steps: 50
}
}
);
// To access the file URL:
console.log(output[0].url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output[0]);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
import replicate
Run stability-ai/stable-diffusion using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"stability-ai/stable-diffusion:f178fa7a1ae43a9a9af01b833b9d2ecf97b1bcb0acfd2dc5dd04895e042863f1",
input={
"width": "512",
"height": "512",
"prompt": "astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed",
"scheduler": "K_EULER",
"num_outputs": "4",
"guidance_scale": 7.5,
"prompt_strength": 0.8,
"num_inference_steps": 50
}
)
print(output)
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Run stability-ai/stable-diffusion using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "f178fa7a1ae43a9a9af01b833b9d2ecf97b1bcb0acfd2dc5dd04895e042863f1",
"input": {
"width": "512",
"height": "512",
"prompt": "astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed",
"scheduler": "K_EULER",
"num_outputs": "4",
"guidance_scale": 7.5,
"prompt_strength": 0.8,
"num_inference_steps": 50
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
brew install cog
If you don’t have Homebrew, there are other installation options available.
Run this to download the model and run it in your local environment:
cog predict r8.im/stability-ai/stable-diffusion@sha256:f178fa7a1ae43a9a9af01b833b9d2ecf97b1bcb0acfd2dc5dd04895e042863f1 \
-i 'width="512"' \
-i 'height="512"' \
-i 'prompt="astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed"' \
-i 'scheduler="K_EULER"' \
-i 'num_outputs="4"' \
-i 'guidance_scale=7.5' \
-i 'prompt_strength=0.8' \
-i 'num_inference_steps=50'
To learn more, take a look at the Cog documentation.
Run this to download the model and run it in your local environment:
docker run -d -p 5000:5000 --gpus=all r8.im/stability-ai/stable-diffusion@sha256:f178fa7a1ae43a9a9af01b833b9d2ecf97b1bcb0acfd2dc5dd04895e042863f1
curl -s -X POST \ -H "Content-Type: application/json" \ -d $'{ "input": { "width": "512", "height": "512", "prompt": "astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed", "scheduler": "K_EULER", "num_outputs": "4", "guidance_scale": 7.5, "prompt_strength": 0.8, "num_inference_steps": 50 } }' \ http://localhost:5000/predictions
To learn more, take a look at the Cog documentation.
Output
{
"completed_at": "2023-02-15T17:22:55.682956Z",
"created_at": "2023-02-15T17:22:35.220695Z",
"data_removed": false,
"error": null,
"id": "dc5qehlh3nc6vmttezm3jwreq4",
"input": {
"width": "512",
"height": "512",
"prompt": "astronaut riding a horse on mars, painting, impressionistic style, oil, highly detailed",
"scheduler": "K_EULER",
"num_outputs": "4",
"guidance_scale": 7.5,
"prompt_strength": 0.8,
"num_inference_steps": 50
},
"logs": "Using seed: 57948\n 0%| | 0/50 [00:00<?, ?it/s]\n 2%|▏ | 1/50 [00:00<00:14, 3.35it/s]\n 4%|▍ | 2/50 [00:00<00:14, 3.36it/s]\n 6%|▌ | 3/50 [00:00<00:13, 3.36it/s]\n 8%|▊ | 4/50 [00:01<00:13, 3.36it/s]\n 10%|█ | 5/50 [00:01<00:13, 3.36it/s]\n 12%|█▏ | 6/50 [00:01<00:13, 3.36it/s]\n 14%|█▍ | 7/50 [00:02<00:12, 3.36it/s]\n 16%|█▌ | 8/50 [00:02<00:12, 3.36it/s]\n 18%|█▊ | 9/50 [00:02<00:12, 3.36it/s]\n 20%|██ | 10/50 [00:02<00:11, 3.36it/s]\n 22%|██▏ | 11/50 [00:03<00:11, 3.36it/s]\n 24%|██▍ | 12/50 [00:03<00:11, 3.36it/s]\n 26%|██▌ | 13/50 [00:03<00:11, 3.36it/s]\n 28%|██▊ | 14/50 [00:04<00:10, 3.36it/s]\n 30%|███ | 15/50 [00:04<00:10, 3.36it/s]\n 32%|███▏ | 16/50 [00:04<00:10, 3.36it/s]\n 34%|███▍ | 17/50 [00:05<00:09, 3.36it/s]\n 36%|███▌ | 18/50 [00:05<00:09, 3.36it/s]\n 38%|███▊ | 19/50 [00:05<00:09, 3.36it/s]\n 40%|████ | 20/50 [00:05<00:08, 3.36it/s]\n 42%|████▏ | 21/50 [00:06<00:08, 3.37it/s]\n 44%|████▍ | 22/50 [00:06<00:08, 3.37it/s]\n 46%|████▌ | 23/50 [00:06<00:08, 3.37it/s]\n 48%|████▊ | 24/50 [00:07<00:07, 3.37it/s]\n 50%|█████ | 25/50 [00:07<00:07, 3.37it/s]\n 52%|█████▏ | 26/50 [00:07<00:07, 3.37it/s]\n 54%|█████▍ | 27/50 [00:08<00:06, 3.37it/s]\n 56%|█████▌ | 28/50 [00:08<00:06, 3.37it/s]\n 58%|█████▊ | 29/50 [00:08<00:06, 3.37it/s]\n 60%|██████ | 30/50 [00:08<00:05, 3.37it/s]\n 62%|██████▏ | 31/50 [00:09<00:05, 3.37it/s]\n 64%|██████▍ | 32/50 [00:09<00:05, 3.37it/s]\n 66%|██████▌ | 33/50 [00:09<00:05, 3.38it/s]\n 68%|██████▊ | 34/50 [00:10<00:04, 3.38it/s]\n 70%|███████ | 35/50 [00:10<00:04, 3.38it/s]\n 72%|███████▏ | 36/50 [00:10<00:04, 3.38it/s]\n 74%|███████▍ | 37/50 [00:10<00:03, 3.38it/s]\n 76%|███████▌ | 38/50 [00:11<00:03, 3.38it/s]\n 78%|███████▊ | 39/50 [00:11<00:03, 3.38it/s]\n 80%|████████ | 40/50 [00:11<00:02, 3.38it/s]\n 82%|████████▏ | 41/50 [00:12<00:02, 3.38it/s]\n 84%|████████▍ | 42/50 [00:12<00:02, 3.38it/s]\n 86%|████████▌ | 43/50 [00:12<00:02, 3.38it/s]\n 88%|████████▊ | 44/50 [00:13<00:01, 3.38it/s]\n 90%|█████████ | 45/50 [00:13<00:01, 3.38it/s]\n 92%|█████████▏| 46/50 [00:13<00:01, 3.38it/s]\n 94%|█████████▍| 47/50 [00:13<00:00, 3.38it/s]\n 96%|█████████▌| 48/50 [00:14<00:00, 3.38it/s]\n 98%|█████████▊| 49/50 [00:14<00:00, 3.38it/s]\n100%|██████████| 50/50 [00:14<00:00, 3.38it/s]\n100%|██████████| 50/50 [00:14<00:00, 3.37it/s]",
"metrics": {
"predict_time": 18.269242,
"total_time": 20.462261
},
"output": [
"https://replicate.delivery/pbxt/EmeCviSAKzw5FKGDhUrqrkHUjL5ueXu5MnE2EBVzWnttbsegA/out-0.png",
"https://replicate.delivery/pbxt/IqGyqOZkkcr6JBgVf1UqTFphY1eQDeRfhALSwusVyBW0ux6BB/out-1.png",
"https://replicate.delivery/pbxt/5QiCSkQpF9oWDl80PA0ggiacDnBjsRIp0uLGwnXiqeP3NWPIA/out-2.png",
"https://replicate.delivery/pbxt/McqyRlKbIP5fTi3OLmTwTRY5NOzlayZEmr83u45QOdt3NWPIA/out-3.png"
],
"started_at": "2023-02-15T17:22:37.413714Z",
"status": "succeeded",
"urls": {
"get": "https://api.replicate.com/v1/predictions/dc5qehlh3nc6vmttezm3jwreq4",
"cancel": "https://api.replicate.com/v1/predictions/dc5qehlh3nc6vmttezm3jwreq4/cancel"
},
"version": "f178fa7a1ae43a9a9af01b833b9d2ecf97b1bcb0acfd2dc5dd04895e042863f1"
}
Using seed: 57948
0%| | 0/50 [00:00<?, ?it/s]
2%|▏ | 1/50 [00:00<00:14, 3.35it/s]
4%|▍ | 2/50 [00:00<00:14, 3.36it/s]
6%|▌ | 3/50 [00:00<00:13, 3.36it/s]
8%|▊ | 4/50 [00:01<00:13, 3.36it/s]
10%|█ | 5/50 [00:01<00:13, 3.36it/s]
12%|█▏ | 6/50 [00:01<00:13, 3.36it/s]
14%|█▍ | 7/50 [00:02<00:12, 3.36it/s]
16%|█▌ | 8/50 [00:02<00:12, 3.36it/s]
18%|█▊ | 9/50 [00:02<00:12, 3.36it/s]
20%|██ | 10/50 [00:02<00:11, 3.36it/s]
22%|██▏ | 11/50 [00:03<00:11, 3.36it/s]
24%|██▍ | 12/50 [00:03<00:11, 3.36it/s]
26%|██▌ | 13/50 [00:03<00:11, 3.36it/s]
28%|██▊ | 14/50 [00:04<00:10, 3.36it/s]
30%|███ | 15/50 [00:04<00:10, 3.36it/s]
32%|███▏ | 16/50 [00:04<00:10, 3.36it/s]
34%|███▍ | 17/50 [00:05<00:09, 3.36it/s]
36%|███▌ | 18/50 [00:05<00:09, 3.36it/s]
38%|███▊ | 19/50 [00:05<00:09, 3.36it/s]
40%|████ | 20/50 [00:05<00:08, 3.36it/s]
42%|████▏ | 21/50 [00:06<00:08, 3.37it/s]
44%|████▍ | 22/50 [00:06<00:08, 3.37it/s]
46%|████▌ | 23/50 [00:06<00:08, 3.37it/s]
48%|████▊ | 24/50 [00:07<00:07, 3.37it/s]
50%|█████ | 25/50 [00:07<00:07, 3.37it/s]
52%|█████▏ | 26/50 [00:07<00:07, 3.37it/s]
54%|█████▍ | 27/50 [00:08<00:06, 3.37it/s]
56%|█████▌ | 28/50 [00:08<00:06, 3.37it/s]
58%|█████▊ | 29/50 [00:08<00:06, 3.37it/s]
60%|██████ | 30/50 [00:08<00:05, 3.37it/s]
62%|██████▏ | 31/50 [00:09<00:05, 3.37it/s]
64%|██████▍ | 32/50 [00:09<00:05, 3.37it/s]
66%|██████▌ | 33/50 [00:09<00:05, 3.38it/s]
68%|██████▊ | 34/50 [00:10<00:04, 3.38it/s]
70%|███████ | 35/50 [00:10<00:04, 3.38it/s]
72%|███████▏ | 36/50 [00:10<00:04, 3.38it/s]
74%|███████▍ | 37/50 [00:10<00:03, 3.38it/s]
76%|███████▌ | 38/50 [00:11<00:03, 3.38it/s]
78%|███████▊ | 39/50 [00:11<00:03, 3.38it/s]
80%|████████ | 40/50 [00:11<00:02, 3.38it/s]
82%|████████▏ | 41/50 [00:12<00:02, 3.38it/s]
84%|████████▍ | 42/50 [00:12<00:02, 3.38it/s]
86%|████████▌ | 43/50 [00:12<00:02, 3.38it/s]
88%|████████▊ | 44/50 [00:13<00:01, 3.38it/s]
90%|█████████ | 45/50 [00:13<00:01, 3.38it/s]
92%|█████████▏| 46/50 [00:13<00:01, 3.38it/s]
94%|█████████▍| 47/50 [00:13<00:00, 3.38it/s]
96%|█████████▌| 48/50 [00:14<00:00, 3.38it/s]
98%|█████████▊| 49/50 [00:14<00:00, 3.38it/s]
100%|██████████| 50/50 [00:14<00:00, 3.38it/s]
100%|██████████| 50/50 [00:14<00:00, 3.37it/s]