Renamed Image to StableDiffusionImage

This commit is contained in:
Darth Affe 2023-12-15 17:46:47 +01:00
parent bd4f90838d
commit cd62691709
3 changed files with 8 additions and 8 deletions

View File

@ -12,5 +12,5 @@ Run `build.bat` to build the native libs (modify params like CUDA-builds if need
```csharp
using StableDiffusionModel sd = new(@"<path_to_model>", new ModelParameter());
using StableDiffusionParameter parameter = new StableDiffusionParameter();
using Image image = sd.TextToImage("<prompt>", parameter);
using StableDiffusionImage image = sd.TextToImage("<prompt>", parameter);
```

View File

@ -41,22 +41,22 @@ public sealed unsafe class StableDiffusionModel : IDisposable
if (!success) throw new IOException("Failed to load model");
}
public Image TextToImage(string prompt, StableDiffusionParameter parameter)
public StableDiffusionImage TextToImage(string prompt, StableDiffusionParameter parameter)
{
ObjectDisposedException.ThrowIf(_disposed, this);
byte* result = Native.stable_diffusion_predict_image(_ctx, parameter.ParamPtr, prompt);
return new Image(result, parameter.Width, parameter.Height);
return new StableDiffusionImage(result, parameter.Width, parameter.Height);
}
public Image ImageToImage(string prompt, Span<byte> image, StableDiffusionParameter parameter)
public StableDiffusionImage ImageToImage(string prompt, Span<byte> image, StableDiffusionParameter parameter)
{
ObjectDisposedException.ThrowIf(_disposed, this);
fixed (byte* imagePtr = image)
{
byte* result = Native.stable_diffusion_image_predict_image(_ctx, parameter.ParamPtr, imagePtr, prompt);
return new Image(result, parameter.Width, parameter.Height);
return new StableDiffusionImage(result, parameter.Width, parameter.Height);
}
}

View File

@ -2,7 +2,7 @@
namespace StableDiffusion.NET;
public sealed unsafe class Image : IDisposable
public sealed unsafe class StableDiffusionImage : IDisposable
{
#region Constants
@ -33,14 +33,14 @@ public sealed unsafe class Image : IDisposable
#region Constructors
internal Image(byte* ptr, int width, int height)
internal StableDiffusionImage(byte* ptr, int width, int height)
{
this._imagePtr = ptr;
this.Width = width;
this.Height = height;
}
~Image() => Dispose();
~StableDiffusionImage() => Dispose();
#endregion