Skip to content

SDCN is an infrastructure that allows people to share and use Stable Diffusion computing power easily.

License

Notifications You must be signed in to change notification settings

fiatrete/SDCN-Stable-Diffusion-Computing-Network

Repository files navigation

SDCN logo

License PRs Welcome GitHub Contributors Last Commit

Website | Playground | API Docs

Overview

SDCN is an infrastructure for sharing Stable Diffusion computing power

  • Decentralization: By running the SDCN node program, users can register their idle computing resources with the SDCN network
  • Trustlessness: SDCN abstracts the capabilities of Stable Diffusion into a set of atomic interface calls and hides the computing process from application developers
  • Powerful: Application developers can quickly develop their own applications based on the Stable Diffusion related capabilities provided by SDCN, without worrying about how these interfaces are implemented or how computing power is provided

SDCN structure

  • SDCN Node
    • Executes image generation tasks
    • Use Stable Diffusion WebUI with API mode directly
  • SDCN Server
    • Manage and route image generation tasks to SDCN Nodes
    • Hide the image generating details and expose a standard interface to application developers
    • Implement SDCN server with openresty
  • API
    • txt2img
    • img2img
    • integrate
    • more APIs under developing

Why SDCN?

  • Everyone should have the ability to use AI freely, AI will be a public good
  • For the public, the cost of trying various ways of stable diffusion is too high
    • It's difficult to set up a stable diffusion runtime environment on your own
    • Computer performance may not support it
    • Downloading code from GitHub and running Stable Diffusion WebUI is beyond the ability of most non-programmers(even programmers)
    • Learning about models and prompt knowledge requires high learning costs
  • More application developers should be supported in popularizing AI capabilities to the public
  • For application developers, the cost of building a publicly available image generation service is too high
    • Application developers should focus on implementing business requirements
  • The utilization of GPU computing power for home and cloud procurement is very low, leading to significant wastage

Getting Started

Try out SDCN functionalities in SDCN website.

🎈Feel free to file tickets for bugs or feature requests.


📱 How-to: try out SDCN API

SDCN provide SaaS-like API from https://api.sdcn.info

Using dan_run.py script

Try the sample code in example folder.

You can modify the example/params-xxx.json to experiment with different parameter combinations.

python3 dan_run.py txt2img params-txt2img.json OUTPUT_IMAGE.png
python3 dan_run.py img2img params-img2img.json ORIGINAL_IMAGE.png OUTPUT_IMAGE.png

Using curl

  1. Install curl and jq
brew install curl jq
  1. Enter example folder and execute
cd example
cat params-txt2img.json \
| curl --location --request POST 'https://api.sdcn.info/api/sd/txt2img' \
--header 'Content-Type: application/json' -d @- \
| jq '.data.images[0]' |tr -d '\"' | tr -d '\\' | base64 -d > out.png

👉 SDCN API refer to API Docs


🌐 How-to: contribute computing power to sdcn.info

  1. Register a donor account on sdcn.info
  2. Install lastest Stable Diffusion WebUI on your PC or Server
  3. Start according to README.md in the dan-node file

🔨 How-to: run dan-server locally in Docker

  1. Install lastest Stable Diffusion WebUI and Docker on your PC or Server

  2. Register a donor account on sdcn.info

  3. Start according to README.md in the dan-node file

  4. Register a new github OAuth Application set callback url: http://localhost:6006/api/user/connect/github. Get the github client ID and SECRET:, then set in the docker-compose.yml.

  5. Start dan-server locally in docker with Docker Compose:

docker-compose up -d 

Now your dan-server is available on "http://127.0.0.1:6006"

  1. Register your Stable Diffusion WebUI instance as a SDCN node:
  • Login your account using SDCN's web page: http://127.0.0.1:6006;
  • Navigate to Nodes -> Donate Node
  • Enter your worker node's address
  • Click Donate

⚠️ Please note that you must use non-loopback IP address in your node's address! You cannot use 127.0.0.1 or 'localhost' since our docker container's hostnet is not enabled.

  1. Config SERVICE_PREFIX in example/dan_run.py to "http://127.0.0.1:6006".
SERVICE_PREFIX = 'http://127.0.0.1:6006'
  1. Execute the example with your local dan-server:
python3 dan_run.py txt2img params-txt2img.json OUTPUT_IMAGE.png

Roadmap

  • Rename project to SDCN
  • Management GUI for computing power donors
    • Add login to the SDCN website
    • CRUD management of computing power provided by donors
  • Workload ranking page
    • Node-based workload ranking
    • Donor-based workload ranking
    • Model-based workload ranking
    • API-based workload ranking
  • Basic SDCN functional interfaces
    • Scale interface
    • Inpaint interface
    • Support for controlnet
  • Enrich examples in the playground
    • 2D to 3D style conversion
    • 3D to 2D style conversion
  • One-click installation of Stable Diffusion WebUI as an SDCN node (Windows & Linux supported)
    • Customize Stable Diffusion WebUI installer
    • Automatically download necessary model files
    • Customize SDCN node daemon as intermediary for communication between Stable Diffusion WebUI and SDCN server
  • Image Stream (user generated by the SDCN tool and share to sdcn.info)
    • Sharing mechanisms for images generated through API or playground
    • A page to display shared images in a waterfall flow
  • Constraints for the use of computing resources
    • API-Key mechanism
    • honor(credit) system
  • Task scheduling mechanism
    • Schedule to nodes with required models already loaded
    • Global load balancing

License

This project is licensed under the MIT license


Credits

About

SDCN is an infrastructure that allows people to share and use Stable Diffusion computing power easily.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published