Giter VIP home page Giter VIP logo

stablediffusion.ai's Introduction

Stable Diffusion AI

  • This is an unofficial library just for developers to get stable diffusion web api easily,net standard 2.0

    used as shown below

  • 1.generate image by text

   string apiKey = "<your-private-key>";
   string prompt = "a cute rabbit with sunglasses";
   string negativePrompt = "low quality";
   string outPutFilePath = "<your-file-path>";
   File.Delete(outPutFilePath);
   var service = new StableDiffusionService(apiKey);
   var response = await service.V1.GenerateImagesAsync(Model.X1, prompt, negativePrompt);
   Console.WriteLine(response);
   File.WriteAllBytes(outPutFilePath, response?.FirstOrDefault());
  • 2.generate image by image
   string apiKey = "<your-private-key>";
   string outPutFilePath = "<your-file-path>";
   string _inputFilePath = "<your-input-file-path>";
   File.Delete(outPutFilePath);
   var service = new StableDiffusionService(_apiKey);
   using var fileStream = File.OpenRead(_inputFilePath);
   var byteData = new byte[fileStream.Length];
   fileStream.Read(byteData, 0, byteData.Length);
   var response = await service.V1.GenerateImagesAsync(Model.X1, new List<Prompt> { new() { Text = "green,land,grass", Weight = 0.5 } }, byteData);
   Console.WriteLine(response);
   File.WriteAllBytes(_outPutFilePath, response?.FirstOrDefault());
   Assert.IsTrue(File.Exists(_outPutFilePath));

a cute rabbit with sunglasses

There is a newer version called V2Beta used by stability AI,but it has some bugs requested by C#.I will merge them after they are fixed

stablediffusion.ai's People

Contributors

maxwell60701 avatar

Stargazers

 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.