Giter Site home page Giter Site logo

notune / worker-sdxl-lightning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from runpod-workers/worker-sdxl-turbo

1.0 0.0 0.0 30 KB

Template for building custom RunPod Endpoint API workers using SDXL Lightning for image generation.

License: MIT License

Shell 28.04% Python 38.10% Dockerfile 33.86%

worker-sdxl-lightning's Introduction

SDXL Lightning Worker Template

A specialized worker template for building custom RunPod Endpoint API workers utilizing the SDXL Lightning model.

Setup

Prerequisites: Docker & git installed, an sdxl-lightning model as .safetensors file

  1. test the model pipeline/config in src/handler.py locally and make adjustments if necessary
  2. git clone https://github.com/notune/worker-sdxl-lightning.git
  3. cd worker-sdxl-lightning
  4. Add model.safetensors to root directory (optional: if you named it differently change the line ADD model.safetensors / in Dockerfile and pipe = StableDiffusionXLPipeline.from_single_file("/model.safetensors", torch_dtype=torch.float16, variant="fp16") in src/handler.py)
  5. sudo DOCKER_BUILDKIT=1 docker build .
  6. For Docker Hub: Create Repo on https://hub.docker.com/
  7. docker login --username=yourhubusername
  8. Copy image-id from recently built image: docker images
  9. Tag image: docker tag <image-id> yourhubusername/sdxll-custom:1.0.0
  10. docker push yourhubusername/sdxll-custom:1.0.0
  11. create serverless worker on runpod with container image name yourhubusername/sdxll-custom:1.0.0

Example Request

import requests
import base64
from PIL import Image
import io

url = "https://api.runpod.ai/v2/<YOUR_RUNPOD_ID>/runsync"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN_HERE>"
}
data = {
    "input": {
        "prompt": "a cute 3d animated cat, pixar style"
    }
}

response = requests.post(url, headers=headers, json=data)

# Check if the response is successful
if response.status_code == 200:
    response_data = response.json()
    if response_data['status'] == 'COMPLETED':
        # Decode the base64 image data
        base64_string = response_data['output']
        image_data = base64.b64decode(base64_string)
        image = Image.open(io.BytesIO(image_data))
        image.show()  # Display the image
        image.save("output_image.png")  # Save the image as a PNG file
    else:
        print("Request was not completed successfully.")
else:
    print(f"Failed to get a valid response. Status code: {response.status_code}")

worker-sdxl-lightning's People

Contributors

notune avatar justinmerrell avatar

Stargazers

Jonathon W. Marshall 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.