Giter VIP home page Giter VIP logo

stablediffusion-upscaler-cli's Introduction

Stable Diffusion 1024x1024 Pixel Image Generator (CLI)

Upscaled generated images

Fig.1 Generated Images (1024×1024) using this code: (a) Futuristic Forest Details, (b) Cosmic Constellation Map, (c) Paint Strokes of a Virtual Reality Art (d) Augmented Human Eye, (e) Architectural Marvels in a Smart City, (f) Macro Shot of a Nano-Insect, (g) Interactive Globe Details, (h) Clockwork of a Time Machine

▶ Generated image files (1024×1024) and a pre-upscaled image file (512×512) are located in this directory. Upscaled generated images (pick up) Fig.2 Comparison of Resolution Before and After Processing: (left) 512×512, (right) 1024×1024

Overview

This project aims to generate high-resolution 1024x1024 pixel images using the Stable Diffusion model 1.4/1.5 and an advanced upsampler prototype. It is specifically designed to meet the requirements of strategically important clients who demand higher image resolutions than what is currently available in the standard Stable Diffusion packages.

Currently, a researcher at Stability AI has released it on Colab. However, it only works in a notebook environment. Therefore, I have prepared a program that can generate 1024x1024 pixel images in a Linux environment by providing prompts through command line arguments

▼ Related Tweet

Features

  • Generate 1024x1024 pixel images from given prompts.
  • Utilizes Stable Diffusion 1.4/1.5 model.
  • Runs locally on Linux.

Requirements

  • Python 3.8 or higher
  • Version 0.0.15 of the k-diffusion package
  • Version 4.31.0 of the transformers package
  • Docker (for DevContainer support)

Installation

Using DevContainer in Visual Studio Code

  1. Clone this repository.

    git clone https://github.com/hogaku/StableDiffusion-Upscaler-CLI.git
  2. Open the project folder in Visual Studio Code.

    cd StableDiffusion-Upscaler-CLI
    code .
  3. When Visual Studio Code prompts you to reopen the folder in a DevContainer, click "Reopen in Container". Alternatively, you can press F1 and select the "Remote-Containers: Reopen Folder in Container" command. This will build the DevContainer defined in the .devcontainer folder, installing all the required dependencies automatically.

Manual Installation

  1. Clone this repository.
    git clone https://github.com/hogaku/StableDiffusion-Upscaler-CLI.git
  2. Open the project folder in Visual Studio Code.
    cd StableDiffusion-Upscaler-CLI
    code .
  3. Install required packages.
    pip install -r requirements.txt
  4. Run the setup script.
    ./setup.sh

Usage

First, Rename the .env.example`` file to .envand configure the Stable Diffusion Engine and API key as appropriate. Example.env` configuration:

SD_ENGINE_ID="stable-diffusion-v1-5"
SD_API_SECRET_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Run the following command on your Linux terminal to generate a 1024x1024 pixel image.

python main.py --seed=<YOUR_SEED> --prompt=<YOUR_PROMPT>

or

python main.py -s=<YOUR_SEED> -p=<YOUR_PROMPT>

Replace <YOUR_SEED> and <YOUR_PROMPT> with the desired seed and prompt for image generation.

Example:

python main.py --seed=12345 --prompt="A beautiful sunset over the mountains."

This will produce a 1024x1024 pixel image based on the prompt and seed provided.

(Others) Standalone Execution for 512x512 Pixel Image Generation

The code for generating 512×512 pixel images using stable-diffusion-v1-5 can operate independently.

Pattern1: CLI Execution

python generate.py <ENGINE_ID> <YOUR_PROMPT>

Pattern2: Class Invocation(No Return Value)

from generate import SDImageGenerator
engine_id = os.getenv('SD_ENGINE_ID')
generator_key = os.getenv('SD_API_SECRET_KEY')
engine_id = "stable-diffusion-v1-5"
generator = SDImageGenerator(engine_id, generator_key)
# No return value
generator.generate_image(prompt, <OUTPUT_SAVE_DIR>)

Pattern3: Class Invocation (Return Value: PIL Image)

from generate import SDImageGenerator
engine_id = os.getenv('SD_ENGINE_ID')
generator_key = os.getenv('SD_API_SECRET_KEY')
engine_id = "stable-diffusion-v1-5"
generator = SDImageGenerator(engine_id, generator_key)
# Return value: PIL Image
output_image = generator.generate_image(prompt, <OUTPUT_SAVE_DIR>, return_image_data=True)

stablediffusion-upscaler-cli's People

Contributors

hogaku avatar

Watchers

 avatar

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.