Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/analyticsinmotion/chatgpt-images-r-shiny

R Package to create and manage ChatGPT Images
https://github.com/analyticsinmotion/chatgpt-images-r-shiny

ai-generated-images analytics-in-motion dalle-2 dalle-images dalle2 image-generation image-generator image-generator-using-openai-api r-package r-programming r-shiny r-shiny-app r-studio

Last synced: 13 days ago
JSON representation

R Package to create and manage ChatGPT Images

Awesome Lists containing this project

README

        



![analytics-in-motion-chatgpt-images-r-shiny](https://github.com/analyticsinmotion/chatgpt-images-r-shiny/assets/52817125/1f00bace-ea56-45c3-ab62-17986e1602d2)

ChatGPT Images - R Shiny



![R](https://img.shields.io/badge/-4.2.2-blue?style=flat&labelColor=white&logo=r&logoColor=blue)  
[![Shiny](https://img.shields.io/badge/Shiny-1.7.4-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://shiny.rstudio.com)  
[![DALL·E](https://img.shields.io/badge/DALL·E-000000?style=badge&logo=openai&logoColor=white)](https://openai.com/dall-e-2/)  
[![MIT license](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/analyticsinmotion/chatgpt-images-r-shiny/blob/main/LICENSE.md)  
![Lifecycle:Maturing](https://img.shields.io/badge/Lifecycle-Maturing-007EC6)  
[![R-CMD-check](https://github.com/analyticsinmotion/chatgpt-images-r-shiny/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/analyticsinmotion/chatgpt-images-r-shiny/actions/workflows/R-CMD-check.yaml)  
[![test-coverage](https://github.com/analyticsinmotion/chatgpt-images-r-shiny/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/analyticsinmotion/chatgpt-images-r-shiny/actions/workflows/test-coverage.yaml)  
[![OpenAI](https://img.shields.io/badge/OpenAI-000000?style=badge&logo=openai&logoColor=white)](https://openai.com)  
[![Analytics in Motion](https://raw.githubusercontent.com/analyticsinmotion/.github/main/assets/images/analytics-in-motion-github-badge-rounded.svg)](https://www.analyticsinmotion.com)  





R Shiny Application/Package to create and manage images using ChatGPT.

## 1. Description
This application provides a simple web interface using Shiny to dynamically create images using OpenAI's ChatGPT models.

https://user-images.githubusercontent.com/52817125/218607251-d3ca7d49-f95f-4f36-8d74-752755bba3d1.mp4

## 2. Getting Started
### 2.1 Dependencies
- Requires an OpenAI API Key (create an account and get API Key at https://chat.openai.com)
- Requires the following packages:
- shiny (>= 1.7.4)
- golem (>= 0.3.5)
- shinydashboard (>= 0.7.2)
- openai (>= 0.3.0)
- config (>= 0.3.1)
- testthat (>= 3.0.0)

Please be aware of the [costs](https://openai.com/pricing) associated with using the OpenAI API when utilizing this project.

### 2.2 Launching the Project

*Step 1* - Download the repository

*Step 2* - Open the project file chatgptimages.Rproj in RStudio

*Step 3* - Open the run_dev.R file in the dev directory (see Section 5 - Directory Structure if you are unable to locate)

*Step 4* - Run the run_dev.R file

Your default browser should open with the application



## 3. Instructions

The application has 4 basic screens to navigate - *Instructions*, *Create Image*, *Image Gallery*, and *Settings*.






### 3.1 Instructions Page
The instructions page is the default page that is shown when the application is run. It provides a complte run down of how to use the application.




### 3.2 Settings: - Enter API Key
In order to use this application a user must have an API Key from OpenAI. This can be done by creating an account from the following link: https://chat.openai.com. Once a user has got their API Key it can be added into the app and saved.



**Please Note:** Depending on how this application is deployed, the API Keys will be kept in persistant storage. That means they will persist until overwritten, even after shutting down the app. If you are deploying this in a production environment please read the [Best practices for API packages](https://cran.r-project.org/web/packages/httr/vignettes/api-packages.html).


### 3.3 Create Image
In the text box, type a description of the image you want ChatGPT to create.
The generator can create images in 3 different sizes:
- 256x256
- 512x512
- 1024x1024.

This can be selected in the dropdown box.
Then click the *Create Image* button. In 2-3 seconds the image will appear.




### 3.4 Image Gallery
All images that a user creates will be stored in the gallery.




## 4. Top 10 Image Creation Ideas
If you are stuck for inspiration try one of these creation prompts:
```
1. Oil painting mountains and water
2. watercolor landscape
3. Pointillism trees
4. Futuristic cars
5. Mona Lisa laughing
6. An astronaut riding a horse in a photorealistic style
7. Fantasy artwork
8. Family Christmas photo
9. Painting of a kangaroo cartoon style
10. A funny image that makes me laugh
```



## 5. Directory Structure

This project follows the golem/R Packages architecture.

chatgptimages
├── DESCRIPTION
├── NAMESPACE
├── LICENSE
├── LICENSE.md
├── chatgptimages.Rproj
├── .Renviron
├── R
│ ├── app_config.R
│ ├── app_server.R
│ ├── app_ui.R
│ ├── fct_get_filename.R
│ ├── fct_get_images.R
│ ├── fct_get_url.R
│ ├── fct_set_apikey.R
│ ├── golem_utils_server.R
│ ├── golem_utils_ui.R
│ ├── mod_create_image.R
│ ├── mod_input_apikey.R
│ ├── mod_show_gallery.R
│ ├── mod_show_instructions.R
│ └── run_app.R
├── tests
│ ├── testthat
│ │ ├── test-golem_utils_server.R
│ │ ├── test-golem_utils_ui.R
│ │ ├── test-golem-recommended.R
│ │ ├── test-mod_create_image.R
│ │ ├── test-mod_input_apikey.R
│ │ ├── test-mod_show_gallery.R
│ │ └── test-mod_show_instructions
│ ├── spelling.R
│ ├── app_configtestthat.R
├── dev
│ ├── 01_start.R
│ ├── 02_dev.R
│ ├── 03_deploy.R
│ └── run_dev.R
├── inst
│ ├── app
│ │ └── www
│ │ └── favicon.ico
│ ├── golem-config.yml
│ └── WORDLIST
└── man
└── run_app.Rd

## 6. Best Practices for API Key Safety

Your OpenAI APIKEY key/s should be kept secure and private at all times.

Please follow the best practices guide for API security from OpenAI


https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety