Artificial Intelligence (AI)-based image generation techniques are revolutionizing various fields, and this package brings those capabilities into the R environment. This package provides a seamless interface to integrate the 'Stable Diffusion' Web APIs (see https://platform.stability.ai/docs/getting-started) into R, allowing users to leverage advanced image transformation methods. Specifically, this package includes functions for text-to-image (txt2img or t2i) and image-to-image (img2img or i2i) transformations using the 'Stable Diffusion' APIs, enabling creative and analytical applications in data visualization and more.
This package was separated from the chatAI4R project.
- AI integration with R
- Stable Diffusion API / DreamStudio (txt2img, img2img, up-scaling/Super-resolution)
- DALL·E 2 / OpenAI API (txt2img, img2img)
# CRAN-version installation (not yet)
install.packages("BiocManager", repos="http://cran.r-project.org")
BiocManager::install("EBImage")
#install.packages("stableDiffusion4R")
#library(stableDiffusion4R)
# Dev-version installation
install.packages(c("devtools", "BiocManager"), repos="http://cran.r-project.org")
BiocManager::install("EBImage")
devtools::install_github("kumeS/stableDiffusion4R")
library(stableDiffusion4R)
For example, to obtain a DreamStudio API key, please register as a member on the DreamStudio website (https://dreamstudio.ai/generate) and obtain your API key.
# Set your key for the DreamStudio API
Sys.setenv(DreamStudio_API_KEY = "Your API key")
Create an .Rprofile file in your home directory and add your API key (using the code above) into it.
# Create a file
file.create("~/.Rprofile")
# [MacOS X] Open the file and edit it
system(paste("open ~/.Rprofile"))
Note: Please be aware of newline character inconsistencies across different operating systems.
File | Description | Prompt |
---|---|---|
A prompt to analyze themes for unified imagery | Prompt |
Function | Description | Script | Flowchart |
---|---|---|---|
txt2img4R | Text-to-image generator using Stable Diffusion | Script | |
img2img4R | Image to Image Transformation using Stable Diffusion | Script | |
img2img_upscale4R | Stable Diffusion Image to Image Up-scaling Transformation | Script |
Function | Description | Script | Flowchart |
---|---|---|---|
generateImage4R | Generate Images Using OpenAI API | Script | |
editImage4R | Edit or Extend Images with OpenAI API | Script | |
imageVariation4R | Generate Image Variations using OpenAI API | Script | |
createImagePrompt_v1 | create a prompt for generating an image from text using an AI model | Script | |
createImagePrompt_v2 | create a more complex prompt by considering additional attributes | Script |
Function | Description | Script | Flowchart |
---|---|---|---|
Display | Display images and optionally write them into image files | Script | |
createHEX | Create Hex Stickers for R Packages (experimental) | Script | Flowchart |
Function | Description | Script | Flowchart |
---|---|---|---|
imgDisplay | Display images and optionally write them into image files | Script | |
imgDisplayAsMovie | Display Images as a Movie | Script |
Copyright (c) 2023 Satoshi Kume. Released under the Artistic License 2.0.
Kume S. (2023) stableDiffusion4R: R Interface to 'Stable Diffusion' APIs for AI-Driven Creative Image Transformations
#BibTeX
@misc{Kume2023stableDiffusion4R,
title={stableDiffusion4R: R Interface to 'Stable Diffusion' APIs for AI-Driven Creative Image Transformations},
author={Kume, Satoshi}, year={2023},
publisher={GitHub}, note={R Package},
howpublished={\url{https://github.com/kumeS/stableDiffusion4R}},
}
- Satoshi Kume