Giter VIP home page Giter VIP logo

stable-diffusion's Introduction

stable-diffusion

pure go ( cgo free ) for stable-diffusion and support cross-platform.

Go Reference

sd.go is a wrapper around stable-diffusion.cpp, which is an adaption of ggml.cpp.

Installation

go get github.com/seasonjs/stable-diffusion

AutoModel Compatibility

See deps folder for dylib compatibility, push request is welcome.

Windows NVIDIA GPU User may need check cuda architecture to get more information.

Windows AMD/ROCM GPU User may need check system requirements to get more information.

platform x32 x64 arm AMD/ROCM NVIDIA/CUDA
windows not support support avx/avx2/avx512 not support rocm5.5 support cuda12 support
linux not support support not support not support not support
darwin not support support support not support not support

AutoModel Dynamic Libraries Disclaimer

The Source of dynamic Libraries

These dynamic libraries come from stable-diffusion.cpp-build release, The dynamic library version can be obtained by viewing stable-diffusion.version file Anyone can check the consistency of the file by checksum ( MD5 ).

The Security Of Dynamic Libraries

All I can say is that the creation of the dynamic library is public and does not contain any subjective malicious logic. If you are worried about the security of the dynamic library during the use process, you can build it yourself.

I and any author related to dynamic libraries do not assume any problems, responsibilities or legal liability during use.

Usage

This stable-diffusion golang library provide two api Predict and ImagePredict.

Usually you can use NewAutoModel, so you don't need to load the dynamic library.

You can find a complete example in examples folder.

Here is a simple example:

package main

import (
	"github.com/seasonjs/hf-hub/api"
	sd "github.com/seasonjs/stable-diffusion"
	"io"
	"os"
)

func main() {
	options := sd.DefaultOptions

	model, err := sd.NewAutoModel(options)
	if err != nil {
		print(err.Error())
		return
	}
	defer model.Close()

	hapi, err := api.NewApi()
	if err != nil {
		print(err.Error())
		return
	}

	modelPath, err := hapi.Model("justinpinkney/miniSD").Get("miniSD.ckpt")
	if err != nil {
		print(err.Error())
		return
	}

	err = model.LoadFromFile(modelPath)
	if err != nil {
		print(err.Error())
		return
	}
	var writers []io.Writer
	filenames := []string{
		"../assets/love_cat0.png",
	}
	for _, filename := range filenames {
		file, err := os.Create(filename)
		if err != nil {
			print(err.Error())
			return
		}
		defer file.Close()
		writers = append(writers, file)
	}

	err = model.Predict("british short hair cat, high quality", sd.DefaultFullParams, writers)
	if err != nil {
		print(err.Error())
	}
}

Packaging

To ship a working program that includes this AI, you will need to include the following files:

  • libstable-diffusion.dylib / libstable-diffusion.so / stable-diffusion.dll (buildin)
  • the model file
  • the tokenizer file (buildin)
  • cuda runtime library, if you use cuda

Low level API

This package also provide low level Api which is same as stable-diffusion-cpp. See detail at stable-diffusion-doc.

Thanks

Successful Examples

License

Copyright (c) seasonjs. All rights reserved. Licensed under the MIT License. See License.txt in the project root for license information.

stable-diffusion's People

Contributors

cyberhan123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stable-diffusion's Issues

Error while using GPU

I have a NVIDIA 4090 and an Intel GPU on my machine. I want to load model to my 4090. However, it only checked my intel gpu and said it's now support.

How to use my NVIDIA GPU not the Intel One?

Thank you.

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.