TensorStack-AI / OnnxStack

C# Stable Diffusion using ONNX Runtime
Apache License 2.0
221 stars 33 forks source link

Major: API Refactor #107

Closed saddam213 closed 9 months ago

saddam213 commented 10 months ago

Breaking Changes

Now that most of the large parts are in place its time to tidy up and refactor the API, the biggest change is the removal of the ModelService and the ModelSet, when i first started these made sense as I thought all models would share the same lifetime, however it seems this is not the case, there are many advantages to sharing models across pipelines, caching etc

The Pipeline classes have been extended and act as the old ModelSet, Dependency injection has been removed from the Pipeline class downwards allowing for easier use when not using DI

Diffusers Style API

With the new changes we can now make a Diffusers like API, I will start this in the PR but will complete over the new few versions

var pipeline = StableDiffusionPipeline.CreatePipeline("D:\\Repositories\\stable-diffusion-v1-5");
var promptOptions = new PromptOptions { Prompt = "Photo of a cute dog." };
var result = await pipeline.RunAsync(promptOptions);
var image = result.ToImage();
await image.SaveAsPngAsync("D:\\Results\\Image.png");

Task List