Coder Social home page Coder Social logo

openaiimagegenerator's Introduction

OpenAI DALL·E Image Generator

This is a sample NodeJS application for generating images. The user is prompted to write a simple description, which the application will use to generate a corresponding image.

a cat and a dog image

The generation is provided using OpenAI's Images API and DALL·E models.

Prerequisites

To get started you will need:

  • Docker installed on your local machine.
  • Node, version v16.16 or later.
  • NPM package manager, version 8.11 or later.
  • An IDE for building the application such as Visual Studio
  • An account with OpenAI to use their API service. You can get a free account for personal use (with limited API calls).
  • An OpenAI API Key is required to access the API needed for image generation. Store it under .env file in the format provided under .env.example (assigned under OPENAI_API_KEY variable)

Running Locally (using npm)

To get started, first install dependencies:

npm i

Then, start the application:

npm run start

Running Locally (using docker build)

You can build your own Docker image as provided below. Since node provide multiarch option, we use buildx to build architectures available for node container image. You may choose to build an individual arch otherwise.

docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag {your image name}:{your tag} .

You can now run the built image using the following command:

docker run -p 3000:3000 --env-file ./.env {your image name}:{your tag}

You will then be able to access the application on your browser under the following URL: http://localhost:3000

Running Locally (using public image)

The image already exists publicly in DockerHub:

docker run -p 3000:3000 --env-file ./.env youngjeong46/chatgpt-image-generator:alpine

You will then be able to access the application on your browser under the following URL: http://localhost:3000

Running on ECS Fargate

The AWS CDK for Typescript is used to deploy the application to ECS Fargate. Follow the instructions in the README.md.

Running on Kubernetes

First, you will need to generate a Base64 encoded string of your OpenAI API key:

echo -n <your API key> | base64

Take the output and place it in the secret data inside kubernetes-manifests/apisecret.yaml.

To deploy to an existing Kubernetes cluster, run the following command to apply the manifests:

kubectl apply -f kubernetes-manifests/

The application.yaml manifest doesn't expose the service via a load balancer so in order to test do something like this:

kubectl -n chatgpt-apps port-forward svc/image-generator 3000:80 

You can access the application via http://localhost:3000.

openaiimagegenerator's People

Contributors

youngjeong46 avatar

Stargazers

 avatar David avatar  avatar 小迪同学 avatar  avatar  avatar Ibo avatar Elijah Kulpinski avatar Vijayant Katyal avatar Gabriel Costa avatar  avatar TheMattaBase avatar

Watchers

 avatar Kostas Georgiou avatar

Forkers

neom-im garphy47

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.