Instructions to use snwy/SD1.5-DALLE-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use snwy/SD1.5-DALLE-2 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("snwy/SD1.5-DALLE-2", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
JBS.MD
Ensure reticulate is loaded
if (!requireNamespace("reticulate", quietly = TRUE)) {
install.packages("reticulate", repos = "https://cloud.r-project.org")
}
library(reticulate)
Install required packages dynamically
required_packages <- c("torch", "diffusers", "transformers", "accelerate", "omegaconf", "safetensors")
for (pkg in required_packages) {
if (!py_module_available(pkg)) {
message(paste("Installing missing package:", pkg))
reticulate::py_install(pkg, pip = TRUE)
}
}
Run the Python block in R
py_run_string('
import torch
from diffusers import StableDiffusionPipeline
Use CUDA for GPU acceleration if available
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.float16 if torch.cuda.is_available() else torch.float32
print(f"Loading model on device: {device} with dtype: {dtype}")
Load using from_single_file with proper repo and file parameter routing
pipe = StableDiffusionPipeline.from_single_file(
"snwy/SD1.5-DALLE-2",
checkpoint_file="SD1.5-DALLE-2.safetensors",
torch_dtype=dtype
)
pipe = pipe.to(device)
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]
image.save("dalle2_astronaut.png")
')
cat("Image generated and saved as dalle2_astronaut.png\n")