Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generates images from text prompts via Stable Diffusion using HuggingFace Diffusers locally or the Inference API.
Use this skill ↓73% 82%+9 ptsof test cases passed
Passed 18 of 22 test cases with the skill, and 16 of 22 without it.
Write Python code that takes a list of four PIL image objects returned from a diffusers pipeline call and writes them to disk with 1-based indexed filenames like variation_1.png.
The loop formats filenames as variation_{i+1}.png.
3 of 3 safety checks passed
Generate images from text prompts using Stable Diffusion locally via HuggingFace Diffusers, or via the HuggingFace Inference API for zero-install operation.
import requests, base64, os
def generate_image_api(prompt, output="output.png"):
api_url = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
headers = {"Authorization": f"Bearer {os.environ['HF_TOKEN']}"}
resp = requests.post(api_url, headers=headers, json={"inputs": prompt}, timeout=120)
resp.raise_for_status()
with open(output, "wb") as f:
f.write(resp.content)
print(f"Saved: {output}")
# Set HF_TOKEN in env: huggingface.co/settings/tokens
generate_image_api("a futuristic city at night, cyberpunk style, neon lights, 8k")
# pip install diffusers transformers accelerate torch
from diffusers import StableDiffusionXLPipeline
import torch
pipe = StableDiffusionXLPipeline.from_pretrained(
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.