stabilityAI
implements functions to connect with the API of stability.ai
You can install the development version of stabilityAI like so:
remotes::install_github("schochastics/stabilityAI")
After signing up at <stability.ai>, obtain an API key from
https://platform.stability.ai/account/keys and save it in your .Renviron
file (for example using usethis::edit_r_environ()
) as "STABILITYAI_TOKEN".
# this prompt generated the logo and describes how the package was implemented...
img <- generate_txt2img(
text_prompts = "A dude with no hair and a beard sitting in front of his laptop in a dark room",
style_preset = "pixel-art"
)
#API returns the image base64 encoded. Save it as png with
base64_to_img(img,"logo")
Good thread on Reddit about the parameters of stable diffusion and help with prompting