Giter Site home page Giter Site logo

automatykajava / docker-diffusers-api-build-download Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kiri-art/docker-diffusers-api-build-download

0.0 0.0 0.0 6 KB

Builds diffusers-api with a pre-downloaded model

License: MIT License

Shell 23.40% Dockerfile 76.60%

docker-diffusers-api-build-download's Introduction

docker-diffusers-api-build-download

Copyright (c) 2022 by Gadi Cohen [email protected]. MIT Licensed.

What is it?

This is a small extension to docker-diffusers-api that pre-downloads a specific model during the build phase.

It works well with banana.dev.

Quick Start

Simply set the appropriate build-vars either in e.g. Banana's dashboard, or inside the Dockerfile, and deploy.

See the Dockerfile for all options.

NB: current known issue where build args don't override values I set previousy in the build, working on this, but please set any vars using ENV line only for now.

Example

# AnimeAnything v3, from HuggingFace "diffusers" branch/revision (an fp16 model)
MODEL_ID="Linaqruf/anything-v3.0"
MODEL_PRECISION="fp16"
MODEL_REVISION="diffusers"
# Download pre-built optimized image from our own S3-storage in default location
MODEL_URL="s3://"

Banana Info

Usage

const out = await banana.run(apiKey, modelKey, { "modelInputs": modelInputs, "callInputs": callInputs });

NB: if you're coming from another banana starter repo, note that we explicitly name modelInputs above, and send a bigger object (with modelInputs and callInputs keys) for the banana-sdk's "modelInputs" argument.

If provided, init_image and mask_image should be base64 encoded.

Optimization

We no longer support Banana's optimization system. We do however provide an alternative that offers even better performance, but requires either a pre-built image or S3-compatible storage (see this post for more info).

Build timing:

  • Primary build - takes about 8m.
  • Optimization step - takes much longer and of course will fail in the end - we don't use it - maybe we'll get a way to opt out of optimization in the future.

Cold boot timing:

  • Banana's optimization: 2.3-6.4s init time (usually around 3.0s)
  • Our method: 2.0-2.5s init time (usually around 2.1s)

Testing

# Run against deployed banana image (Nvidia A100)
$ export BANANA_API_KEY=XXX
$ BANANA_MODEL_KEY=XXX python3 test.py --banana txt2img
Running test: txt2img
Request took 19.4s (init: 2.5s, inference: 3.5s)
Saved /home/dragon/www/banana/banana-sd-base/tests/output/txt2img.png

# Note that 2nd runs are much faster (no init AND faster inference)
Request took 3.0s (inference: 2.1s)

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.